babylon.module.d.ts 5.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Color3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * 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".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * 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"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * 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"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * 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)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * 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
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. 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;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. 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;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * 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"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * 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".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * 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"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * 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".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * 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.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * 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.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * 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).
  4329. * 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.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @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.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** 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 */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** 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 */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** 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 */
  4500. static readonly GEQUAL: number;
  4501. /** 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 */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * 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.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * 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.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Engines/IPipelineContext" {
  5234. /**
  5235. * Class used to store and describe the pipeline context associated with an effect
  5236. */
  5237. export interface IPipelineContext {
  5238. /**
  5239. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5240. */
  5241. isAsync: boolean;
  5242. /**
  5243. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5244. */
  5245. isReady: boolean;
  5246. /** @hidden */
  5247. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5248. }
  5249. }
  5250. declare module "babylonjs/Meshes/dataBuffer" {
  5251. /**
  5252. * Class used to store gfx data (like WebGLBuffer)
  5253. */
  5254. export class DataBuffer {
  5255. /**
  5256. * Gets or sets the number of objects referencing this buffer
  5257. */
  5258. references: number;
  5259. /** Gets or sets the size of the underlying buffer */
  5260. capacity: number;
  5261. /**
  5262. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5263. */
  5264. is32Bits: boolean;
  5265. /**
  5266. * Gets the underlying buffer
  5267. */
  5268. readonly underlyingResource: any;
  5269. }
  5270. }
  5271. declare module "babylonjs/Misc/performanceMonitor" {
  5272. /**
  5273. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5274. */
  5275. export class PerformanceMonitor {
  5276. private _enabled;
  5277. private _rollingFrameTime;
  5278. private _lastFrameTimeMs;
  5279. /**
  5280. * constructor
  5281. * @param frameSampleSize The number of samples required to saturate the sliding window
  5282. */
  5283. constructor(frameSampleSize?: number);
  5284. /**
  5285. * Samples current frame
  5286. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5287. */
  5288. sampleFrame(timeMs?: number): void;
  5289. /**
  5290. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5291. */
  5292. readonly averageFrameTime: number;
  5293. /**
  5294. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5295. */
  5296. readonly averageFrameTimeVariance: number;
  5297. /**
  5298. * Returns the frame time of the most recent frame
  5299. */
  5300. readonly instantaneousFrameTime: number;
  5301. /**
  5302. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5303. */
  5304. readonly averageFPS: number;
  5305. /**
  5306. * Returns the average framerate in frames per second using the most recent frame time
  5307. */
  5308. readonly instantaneousFPS: number;
  5309. /**
  5310. * Returns true if enough samples have been taken to completely fill the sliding window
  5311. */
  5312. readonly isSaturated: boolean;
  5313. /**
  5314. * Enables contributions to the sliding window sample set
  5315. */
  5316. enable(): void;
  5317. /**
  5318. * Disables contributions to the sliding window sample set
  5319. * Samples will not be interpolated over the disabled period
  5320. */
  5321. disable(): void;
  5322. /**
  5323. * Returns true if sampling is enabled
  5324. */
  5325. readonly isEnabled: boolean;
  5326. /**
  5327. * Resets performance monitor
  5328. */
  5329. reset(): void;
  5330. }
  5331. /**
  5332. * RollingAverage
  5333. *
  5334. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5335. */
  5336. export class RollingAverage {
  5337. /**
  5338. * Current average
  5339. */
  5340. average: number;
  5341. /**
  5342. * Current variance
  5343. */
  5344. variance: number;
  5345. protected _samples: Array<number>;
  5346. protected _sampleCount: number;
  5347. protected _pos: number;
  5348. protected _m2: number;
  5349. /**
  5350. * constructor
  5351. * @param length The number of samples required to saturate the sliding window
  5352. */
  5353. constructor(length: number);
  5354. /**
  5355. * Adds a sample to the sample set
  5356. * @param v The sample value
  5357. */
  5358. add(v: number): void;
  5359. /**
  5360. * Returns previously added values or null if outside of history or outside the sliding window domain
  5361. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5362. * @return Value previously recorded with add() or null if outside of range
  5363. */
  5364. history(i: number): number;
  5365. /**
  5366. * Returns true if enough samples have been taken to completely fill the sliding window
  5367. * @return true if sample-set saturated
  5368. */
  5369. isSaturated(): boolean;
  5370. /**
  5371. * Resets the rolling average (equivalent to 0 samples taken so far)
  5372. */
  5373. reset(): void;
  5374. /**
  5375. * Wraps a value around the sample range boundaries
  5376. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5377. * @return Wrapped position in sample range
  5378. */
  5379. protected _wrapPosition(i: number): number;
  5380. }
  5381. }
  5382. declare module "babylonjs/Misc/stringDictionary" {
  5383. import { Nullable } from "babylonjs/types";
  5384. /**
  5385. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5386. * The underlying implementation relies on an associative array to ensure the best performances.
  5387. * The value can be anything including 'null' but except 'undefined'
  5388. */
  5389. export class StringDictionary<T> {
  5390. /**
  5391. * This will clear this dictionary and copy the content from the 'source' one.
  5392. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5393. * @param source the dictionary to take the content from and copy to this dictionary
  5394. */
  5395. copyFrom(source: StringDictionary<T>): void;
  5396. /**
  5397. * Get a value based from its key
  5398. * @param key the given key to get the matching value from
  5399. * @return the value if found, otherwise undefined is returned
  5400. */
  5401. get(key: string): T | undefined;
  5402. /**
  5403. * Get a value from its key or add it if it doesn't exist.
  5404. * This method will ensure you that a given key/data will be present in the dictionary.
  5405. * @param key the given key to get the matching value from
  5406. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5407. * The factory will only be invoked if there's no data for the given key.
  5408. * @return the value corresponding to the key.
  5409. */
  5410. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5411. /**
  5412. * Get a value from its key if present in the dictionary otherwise add it
  5413. * @param key the key to get the value from
  5414. * @param val if there's no such key/value pair in the dictionary add it with this value
  5415. * @return the value corresponding to the key
  5416. */
  5417. getOrAdd(key: string, val: T): T;
  5418. /**
  5419. * Check if there's a given key in the dictionary
  5420. * @param key the key to check for
  5421. * @return true if the key is present, false otherwise
  5422. */
  5423. contains(key: string): boolean;
  5424. /**
  5425. * Add a new key and its corresponding value
  5426. * @param key the key to add
  5427. * @param value the value corresponding to the key
  5428. * @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
  5429. */
  5430. add(key: string, value: T): boolean;
  5431. /**
  5432. * Update a specific value associated to a key
  5433. * @param key defines the key to use
  5434. * @param value defines the value to store
  5435. * @returns true if the value was updated (or false if the key was not found)
  5436. */
  5437. set(key: string, value: T): boolean;
  5438. /**
  5439. * Get the element of the given key and remove it from the dictionary
  5440. * @param key defines the key to search
  5441. * @returns the value associated with the key or null if not found
  5442. */
  5443. getAndRemove(key: string): Nullable<T>;
  5444. /**
  5445. * Remove a key/value from the dictionary.
  5446. * @param key the key to remove
  5447. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5448. */
  5449. remove(key: string): boolean;
  5450. /**
  5451. * Clear the whole content of the dictionary
  5452. */
  5453. clear(): void;
  5454. /**
  5455. * Gets the current count
  5456. */
  5457. readonly count: number;
  5458. /**
  5459. * Execute a callback on each key/val of the dictionary.
  5460. * Note that you can remove any element in this dictionary in the callback implementation
  5461. * @param callback the callback to execute on a given key/value pair
  5462. */
  5463. forEach(callback: (key: string, val: T) => void): void;
  5464. /**
  5465. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5466. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5467. * Note that you can remove any element in this dictionary in the callback implementation
  5468. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5469. * @returns the first item
  5470. */
  5471. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5472. private _count;
  5473. private _data;
  5474. }
  5475. }
  5476. declare module "babylonjs/Misc/promise" {
  5477. /**
  5478. * Helper class that provides a small promise polyfill
  5479. */
  5480. export class PromisePolyfill {
  5481. /**
  5482. * Static function used to check if the polyfill is required
  5483. * If this is the case then the function will inject the polyfill to window.Promise
  5484. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5485. */
  5486. static Apply(force?: boolean): void;
  5487. }
  5488. }
  5489. declare module "babylonjs/Meshes/buffer" {
  5490. import { Nullable, DataArray } from "babylonjs/types";
  5491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5492. /**
  5493. * Class used to store data that will be store in GPU memory
  5494. */
  5495. export class Buffer {
  5496. private _engine;
  5497. private _buffer;
  5498. /** @hidden */
  5499. _data: Nullable<DataArray>;
  5500. private _updatable;
  5501. private _instanced;
  5502. /**
  5503. * Gets the byte stride.
  5504. */
  5505. readonly byteStride: number;
  5506. /**
  5507. * Constructor
  5508. * @param engine the engine
  5509. * @param data the data to use for this buffer
  5510. * @param updatable whether the data is updatable
  5511. * @param stride the stride (optional)
  5512. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5513. * @param instanced whether the buffer is instanced (optional)
  5514. * @param useBytes set to true if the stride in in bytes (optional)
  5515. */
  5516. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5517. /**
  5518. * Create a new VertexBuffer based on the current buffer
  5519. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5520. * @param offset defines offset in the buffer (0 by default)
  5521. * @param size defines the size in floats of attributes (position is 3 for instance)
  5522. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5523. * @param instanced defines if the vertex buffer contains indexed data
  5524. * @param useBytes defines if the offset and stride are in bytes
  5525. * @returns the new vertex buffer
  5526. */
  5527. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5528. /**
  5529. * Gets a boolean indicating if the Buffer is updatable?
  5530. * @returns true if the buffer is updatable
  5531. */
  5532. isUpdatable(): boolean;
  5533. /**
  5534. * Gets current buffer's data
  5535. * @returns a DataArray or null
  5536. */
  5537. getData(): Nullable<DataArray>;
  5538. /**
  5539. * Gets underlying native buffer
  5540. * @returns underlying native buffer
  5541. */
  5542. getBuffer(): Nullable<DataBuffer>;
  5543. /**
  5544. * Gets the stride in float32 units (i.e. byte stride / 4).
  5545. * May not be an integer if the byte stride is not divisible by 4.
  5546. * DEPRECATED. Use byteStride instead.
  5547. * @returns the stride in float32 units
  5548. */
  5549. getStrideSize(): number;
  5550. /**
  5551. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5552. * @param data defines the data to store
  5553. */
  5554. create(data?: Nullable<DataArray>): void;
  5555. /** @hidden */
  5556. _rebuild(): void;
  5557. /**
  5558. * Update current buffer data
  5559. * @param data defines the data to store
  5560. */
  5561. update(data: DataArray): void;
  5562. /**
  5563. * Updates the data directly.
  5564. * @param data the new data
  5565. * @param offset the new offset
  5566. * @param vertexCount the vertex count (optional)
  5567. * @param useBytes set to true if the offset is in bytes
  5568. */
  5569. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5570. /**
  5571. * Release all resources
  5572. */
  5573. dispose(): void;
  5574. }
  5575. /**
  5576. * Specialized buffer used to store vertex data
  5577. */
  5578. export class VertexBuffer {
  5579. /** @hidden */
  5580. _buffer: Buffer;
  5581. private _kind;
  5582. private _size;
  5583. private _ownsBuffer;
  5584. private _instanced;
  5585. private _instanceDivisor;
  5586. /**
  5587. * The byte type.
  5588. */
  5589. static readonly BYTE: number;
  5590. /**
  5591. * The unsigned byte type.
  5592. */
  5593. static readonly UNSIGNED_BYTE: number;
  5594. /**
  5595. * The short type.
  5596. */
  5597. static readonly SHORT: number;
  5598. /**
  5599. * The unsigned short type.
  5600. */
  5601. static readonly UNSIGNED_SHORT: number;
  5602. /**
  5603. * The integer type.
  5604. */
  5605. static readonly INT: number;
  5606. /**
  5607. * The unsigned integer type.
  5608. */
  5609. static readonly UNSIGNED_INT: number;
  5610. /**
  5611. * The float type.
  5612. */
  5613. static readonly FLOAT: number;
  5614. /**
  5615. * Gets or sets the instance divisor when in instanced mode
  5616. */
  5617. instanceDivisor: number;
  5618. /**
  5619. * Gets the byte stride.
  5620. */
  5621. readonly byteStride: number;
  5622. /**
  5623. * Gets the byte offset.
  5624. */
  5625. readonly byteOffset: number;
  5626. /**
  5627. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5628. */
  5629. readonly normalized: boolean;
  5630. /**
  5631. * Gets the data type of each component in the array.
  5632. */
  5633. readonly type: number;
  5634. /**
  5635. * Constructor
  5636. * @param engine the engine
  5637. * @param data the data to use for this vertex buffer
  5638. * @param kind the vertex buffer kind
  5639. * @param updatable whether the data is updatable
  5640. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5641. * @param stride the stride (optional)
  5642. * @param instanced whether the buffer is instanced (optional)
  5643. * @param offset the offset of the data (optional)
  5644. * @param size the number of components (optional)
  5645. * @param type the type of the component (optional)
  5646. * @param normalized whether the data contains normalized data (optional)
  5647. * @param useBytes set to true if stride and offset are in bytes (optional)
  5648. */
  5649. 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);
  5650. /** @hidden */
  5651. _rebuild(): void;
  5652. /**
  5653. * Returns the kind of the VertexBuffer (string)
  5654. * @returns a string
  5655. */
  5656. getKind(): string;
  5657. /**
  5658. * Gets a boolean indicating if the VertexBuffer is updatable?
  5659. * @returns true if the buffer is updatable
  5660. */
  5661. isUpdatable(): boolean;
  5662. /**
  5663. * Gets current buffer's data
  5664. * @returns a DataArray or null
  5665. */
  5666. getData(): Nullable<DataArray>;
  5667. /**
  5668. * Gets underlying native buffer
  5669. * @returns underlying native buffer
  5670. */
  5671. getBuffer(): Nullable<DataBuffer>;
  5672. /**
  5673. * Gets the stride in float32 units (i.e. byte stride / 4).
  5674. * May not be an integer if the byte stride is not divisible by 4.
  5675. * DEPRECATED. Use byteStride instead.
  5676. * @returns the stride in float32 units
  5677. */
  5678. getStrideSize(): number;
  5679. /**
  5680. * Returns the offset as a multiple of the type byte length.
  5681. * DEPRECATED. Use byteOffset instead.
  5682. * @returns the offset in bytes
  5683. */
  5684. getOffset(): number;
  5685. /**
  5686. * Returns the number of components per vertex attribute (integer)
  5687. * @returns the size in float
  5688. */
  5689. getSize(): number;
  5690. /**
  5691. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5692. * @returns true if this buffer is instanced
  5693. */
  5694. getIsInstanced(): boolean;
  5695. /**
  5696. * Returns the instancing divisor, zero for non-instanced (integer).
  5697. * @returns a number
  5698. */
  5699. getInstanceDivisor(): number;
  5700. /**
  5701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5702. * @param data defines the data to store
  5703. */
  5704. create(data?: DataArray): void;
  5705. /**
  5706. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5707. * This function will create a new buffer if the current one is not updatable
  5708. * @param data defines the data to store
  5709. */
  5710. update(data: DataArray): void;
  5711. /**
  5712. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5713. * Returns the directly updated WebGLBuffer.
  5714. * @param data the new data
  5715. * @param offset the new offset
  5716. * @param useBytes set to true if the offset is in bytes
  5717. */
  5718. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5719. /**
  5720. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5721. */
  5722. dispose(): void;
  5723. /**
  5724. * Enumerates each value of this vertex buffer as numbers.
  5725. * @param count the number of values to enumerate
  5726. * @param callback the callback function called for each value
  5727. */
  5728. forEach(count: number, callback: (value: number, index: number) => void): void;
  5729. /**
  5730. * Positions
  5731. */
  5732. static readonly PositionKind: string;
  5733. /**
  5734. * Normals
  5735. */
  5736. static readonly NormalKind: string;
  5737. /**
  5738. * Tangents
  5739. */
  5740. static readonly TangentKind: string;
  5741. /**
  5742. * Texture coordinates
  5743. */
  5744. static readonly UVKind: string;
  5745. /**
  5746. * Texture coordinates 2
  5747. */
  5748. static readonly UV2Kind: string;
  5749. /**
  5750. * Texture coordinates 3
  5751. */
  5752. static readonly UV3Kind: string;
  5753. /**
  5754. * Texture coordinates 4
  5755. */
  5756. static readonly UV4Kind: string;
  5757. /**
  5758. * Texture coordinates 5
  5759. */
  5760. static readonly UV5Kind: string;
  5761. /**
  5762. * Texture coordinates 6
  5763. */
  5764. static readonly UV6Kind: string;
  5765. /**
  5766. * Colors
  5767. */
  5768. static readonly ColorKind: string;
  5769. /**
  5770. * Matrix indices (for bones)
  5771. */
  5772. static readonly MatricesIndicesKind: string;
  5773. /**
  5774. * Matrix weights (for bones)
  5775. */
  5776. static readonly MatricesWeightsKind: string;
  5777. /**
  5778. * Additional matrix indices (for bones)
  5779. */
  5780. static readonly MatricesIndicesExtraKind: string;
  5781. /**
  5782. * Additional matrix weights (for bones)
  5783. */
  5784. static readonly MatricesWeightsExtraKind: string;
  5785. /**
  5786. * Deduces the stride given a kind.
  5787. * @param kind The kind string to deduce
  5788. * @returns The deduced stride
  5789. */
  5790. static DeduceStride(kind: string): number;
  5791. /**
  5792. * Gets the byte length of the given type.
  5793. * @param type the type
  5794. * @returns the number of bytes
  5795. */
  5796. static GetTypeByteLength(type: number): number;
  5797. /**
  5798. * Enumerates each value of the given parameters as numbers.
  5799. * @param data the data to enumerate
  5800. * @param byteOffset the byte offset of the data
  5801. * @param byteStride the byte stride of the data
  5802. * @param componentCount the number of components per element
  5803. * @param componentType the type of the component
  5804. * @param count the total number of components
  5805. * @param normalized whether the data is normalized
  5806. * @param callback the callback function called for each value
  5807. */
  5808. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5809. private static _GetFloatValue;
  5810. }
  5811. }
  5812. declare module "babylonjs/Maths/sphericalPolynomial" {
  5813. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5814. /**
  5815. * Class representing spherical harmonics coefficients to the 3rd degree
  5816. */
  5817. export class SphericalHarmonics {
  5818. /**
  5819. * Defines whether or not the harmonics have been prescaled for rendering.
  5820. */
  5821. preScaled: boolean;
  5822. /**
  5823. * The l0,0 coefficients of the spherical harmonics
  5824. */
  5825. l00: Vector3;
  5826. /**
  5827. * The l1,-1 coefficients of the spherical harmonics
  5828. */
  5829. l1_1: Vector3;
  5830. /**
  5831. * The l1,0 coefficients of the spherical harmonics
  5832. */
  5833. l10: Vector3;
  5834. /**
  5835. * The l1,1 coefficients of the spherical harmonics
  5836. */
  5837. l11: Vector3;
  5838. /**
  5839. * The l2,-2 coefficients of the spherical harmonics
  5840. */
  5841. l2_2: Vector3;
  5842. /**
  5843. * The l2,-1 coefficients of the spherical harmonics
  5844. */
  5845. l2_1: Vector3;
  5846. /**
  5847. * The l2,0 coefficients of the spherical harmonics
  5848. */
  5849. l20: Vector3;
  5850. /**
  5851. * The l2,1 coefficients of the spherical harmonics
  5852. */
  5853. l21: Vector3;
  5854. /**
  5855. * The l2,2 coefficients of the spherical harmonics
  5856. */
  5857. l22: Vector3;
  5858. /**
  5859. * Adds a light to the spherical harmonics
  5860. * @param direction the direction of the light
  5861. * @param color the color of the light
  5862. * @param deltaSolidAngle the delta solid angle of the light
  5863. */
  5864. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5865. /**
  5866. * Scales the spherical harmonics by the given amount
  5867. * @param scale the amount to scale
  5868. */
  5869. scaleInPlace(scale: number): void;
  5870. /**
  5871. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5872. *
  5873. * ```
  5874. * E_lm = A_l * L_lm
  5875. * ```
  5876. *
  5877. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5878. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5879. * the scaling factors are given in equation 9.
  5880. */
  5881. convertIncidentRadianceToIrradiance(): void;
  5882. /**
  5883. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5884. *
  5885. * ```
  5886. * L = (1/pi) * E * rho
  5887. * ```
  5888. *
  5889. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5890. */
  5891. convertIrradianceToLambertianRadiance(): void;
  5892. /**
  5893. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5894. * required operations at run time.
  5895. *
  5896. * This is simply done by scaling back the SH with Ylm constants parameter.
  5897. * The trigonometric part being applied by the shader at run time.
  5898. */
  5899. preScaleForRendering(): void;
  5900. /**
  5901. * Constructs a spherical harmonics from an array.
  5902. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5903. * @returns the spherical harmonics
  5904. */
  5905. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5906. /**
  5907. * Gets the spherical harmonics from polynomial
  5908. * @param polynomial the spherical polynomial
  5909. * @returns the spherical harmonics
  5910. */
  5911. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5912. }
  5913. /**
  5914. * Class representing spherical polynomial coefficients to the 3rd degree
  5915. */
  5916. export class SphericalPolynomial {
  5917. private _harmonics;
  5918. /**
  5919. * The spherical harmonics used to create the polynomials.
  5920. */
  5921. readonly preScaledHarmonics: SphericalHarmonics;
  5922. /**
  5923. * The x coefficients of the spherical polynomial
  5924. */
  5925. x: Vector3;
  5926. /**
  5927. * The y coefficients of the spherical polynomial
  5928. */
  5929. y: Vector3;
  5930. /**
  5931. * The z coefficients of the spherical polynomial
  5932. */
  5933. z: Vector3;
  5934. /**
  5935. * The xx coefficients of the spherical polynomial
  5936. */
  5937. xx: Vector3;
  5938. /**
  5939. * The yy coefficients of the spherical polynomial
  5940. */
  5941. yy: Vector3;
  5942. /**
  5943. * The zz coefficients of the spherical polynomial
  5944. */
  5945. zz: Vector3;
  5946. /**
  5947. * The xy coefficients of the spherical polynomial
  5948. */
  5949. xy: Vector3;
  5950. /**
  5951. * The yz coefficients of the spherical polynomial
  5952. */
  5953. yz: Vector3;
  5954. /**
  5955. * The zx coefficients of the spherical polynomial
  5956. */
  5957. zx: Vector3;
  5958. /**
  5959. * Adds an ambient color to the spherical polynomial
  5960. * @param color the color to add
  5961. */
  5962. addAmbient(color: Color3): void;
  5963. /**
  5964. * Scales the spherical polynomial by the given amount
  5965. * @param scale the amount to scale
  5966. */
  5967. scaleInPlace(scale: number): void;
  5968. /**
  5969. * Gets the spherical polynomial from harmonics
  5970. * @param harmonics the spherical harmonics
  5971. * @returns the spherical polynomial
  5972. */
  5973. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5974. /**
  5975. * Constructs a spherical polynomial from an array.
  5976. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5977. * @returns the spherical polynomial
  5978. */
  5979. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5983. import { Nullable } from "babylonjs/types";
  5984. /**
  5985. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5986. */
  5987. export interface CubeMapInfo {
  5988. /**
  5989. * The pixel array for the front face.
  5990. * This is stored in format, left to right, up to down format.
  5991. */
  5992. front: Nullable<ArrayBufferView>;
  5993. /**
  5994. * The pixel array for the back face.
  5995. * This is stored in format, left to right, up to down format.
  5996. */
  5997. back: Nullable<ArrayBufferView>;
  5998. /**
  5999. * The pixel array for the left face.
  6000. * This is stored in format, left to right, up to down format.
  6001. */
  6002. left: Nullable<ArrayBufferView>;
  6003. /**
  6004. * The pixel array for the right face.
  6005. * This is stored in format, left to right, up to down format.
  6006. */
  6007. right: Nullable<ArrayBufferView>;
  6008. /**
  6009. * The pixel array for the up face.
  6010. * This is stored in format, left to right, up to down format.
  6011. */
  6012. up: Nullable<ArrayBufferView>;
  6013. /**
  6014. * The pixel array for the down face.
  6015. * This is stored in format, left to right, up to down format.
  6016. */
  6017. down: Nullable<ArrayBufferView>;
  6018. /**
  6019. * The size of the cubemap stored.
  6020. *
  6021. * Each faces will be size * size pixels.
  6022. */
  6023. size: number;
  6024. /**
  6025. * The format of the texture.
  6026. *
  6027. * RGBA, RGB.
  6028. */
  6029. format: number;
  6030. /**
  6031. * The type of the texture data.
  6032. *
  6033. * UNSIGNED_INT, FLOAT.
  6034. */
  6035. type: number;
  6036. /**
  6037. * Specifies whether the texture is in gamma space.
  6038. */
  6039. gammaSpace: boolean;
  6040. }
  6041. /**
  6042. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6043. */
  6044. export class PanoramaToCubeMapTools {
  6045. private static FACE_FRONT;
  6046. private static FACE_BACK;
  6047. private static FACE_RIGHT;
  6048. private static FACE_LEFT;
  6049. private static FACE_DOWN;
  6050. private static FACE_UP;
  6051. /**
  6052. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6053. *
  6054. * @param float32Array The source data.
  6055. * @param inputWidth The width of the input panorama.
  6056. * @param inputHeight The height of the input panorama.
  6057. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6058. * @return The cubemap data
  6059. */
  6060. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6061. private static CreateCubemapTexture;
  6062. private static CalcProjectionSpherical;
  6063. }
  6064. }
  6065. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6066. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6068. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6069. /**
  6070. * Helper class dealing with the extraction of spherical polynomial dataArray
  6071. * from a cube map.
  6072. */
  6073. export class CubeMapToSphericalPolynomialTools {
  6074. private static FileFaces;
  6075. /**
  6076. * Converts a texture to the according Spherical Polynomial data.
  6077. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6078. *
  6079. * @param texture The texture to extract the information from.
  6080. * @return The Spherical Polynomial data.
  6081. */
  6082. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6083. /**
  6084. * Converts a cubemap to the according Spherical Polynomial data.
  6085. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6086. *
  6087. * @param cubeInfo The Cube map to extract the information from.
  6088. * @return The Spherical Polynomial data.
  6089. */
  6090. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6091. }
  6092. }
  6093. declare module "babylonjs/Engines/engineStore" {
  6094. import { Nullable } from "babylonjs/types";
  6095. import { Engine } from "babylonjs/Engines/engine";
  6096. import { Scene } from "babylonjs/scene";
  6097. /**
  6098. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6099. * during the life time of the application.
  6100. */
  6101. export class EngineStore {
  6102. /** Gets the list of created engines */
  6103. static Instances: import("babylonjs/Engines/engine").Engine[];
  6104. /** @hidden */
  6105. static _LastCreatedScene: Nullable<Scene>;
  6106. /**
  6107. * Gets the latest created engine
  6108. */
  6109. static readonly LastCreatedEngine: Nullable<Engine>;
  6110. /**
  6111. * Gets the latest created scene
  6112. */
  6113. static readonly LastCreatedScene: Nullable<Scene>;
  6114. }
  6115. }
  6116. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6117. /**
  6118. * Define options used to create a render target texture
  6119. */
  6120. export class RenderTargetCreationOptions {
  6121. /**
  6122. * Specifies is mipmaps must be generated
  6123. */
  6124. generateMipMaps?: boolean;
  6125. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6126. generateDepthBuffer?: boolean;
  6127. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6128. generateStencilBuffer?: boolean;
  6129. /** Defines texture type (int by default) */
  6130. type?: number;
  6131. /** Defines sampling mode (trilinear by default) */
  6132. samplingMode?: number;
  6133. /** Defines format (RGBA by default) */
  6134. format?: number;
  6135. }
  6136. }
  6137. declare module "babylonjs/States/alphaCullingState" {
  6138. /**
  6139. * @hidden
  6140. **/
  6141. export class _AlphaState {
  6142. private _isAlphaBlendDirty;
  6143. private _isBlendFunctionParametersDirty;
  6144. private _isBlendEquationParametersDirty;
  6145. private _isBlendConstantsDirty;
  6146. private _alphaBlend;
  6147. private _blendFunctionParameters;
  6148. private _blendEquationParameters;
  6149. private _blendConstants;
  6150. /**
  6151. * Initializes the state.
  6152. */
  6153. constructor();
  6154. readonly isDirty: boolean;
  6155. alphaBlend: boolean;
  6156. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6157. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6158. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6159. reset(): void;
  6160. apply(gl: WebGLRenderingContext): void;
  6161. }
  6162. }
  6163. declare module "babylonjs/States/depthCullingState" {
  6164. import { Nullable } from "babylonjs/types";
  6165. /**
  6166. * @hidden
  6167. **/
  6168. export class _DepthCullingState {
  6169. private _isDepthTestDirty;
  6170. private _isDepthMaskDirty;
  6171. private _isDepthFuncDirty;
  6172. private _isCullFaceDirty;
  6173. private _isCullDirty;
  6174. private _isZOffsetDirty;
  6175. private _isFrontFaceDirty;
  6176. private _depthTest;
  6177. private _depthMask;
  6178. private _depthFunc;
  6179. private _cull;
  6180. private _cullFace;
  6181. private _zOffset;
  6182. private _frontFace;
  6183. /**
  6184. * Initializes the state.
  6185. */
  6186. constructor();
  6187. readonly isDirty: boolean;
  6188. zOffset: number;
  6189. cullFace: Nullable<number>;
  6190. cull: Nullable<boolean>;
  6191. depthFunc: Nullable<number>;
  6192. depthMask: boolean;
  6193. depthTest: boolean;
  6194. frontFace: Nullable<number>;
  6195. reset(): void;
  6196. apply(gl: WebGLRenderingContext): void;
  6197. }
  6198. }
  6199. declare module "babylonjs/States/stencilState" {
  6200. /**
  6201. * @hidden
  6202. **/
  6203. export class _StencilState {
  6204. /** 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 */
  6205. static readonly ALWAYS: number;
  6206. /** Passed to stencilOperation to specify that stencil value must be kept */
  6207. static readonly KEEP: number;
  6208. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6209. static readonly REPLACE: number;
  6210. private _isStencilTestDirty;
  6211. private _isStencilMaskDirty;
  6212. private _isStencilFuncDirty;
  6213. private _isStencilOpDirty;
  6214. private _stencilTest;
  6215. private _stencilMask;
  6216. private _stencilFunc;
  6217. private _stencilFuncRef;
  6218. private _stencilFuncMask;
  6219. private _stencilOpStencilFail;
  6220. private _stencilOpDepthFail;
  6221. private _stencilOpStencilDepthPass;
  6222. readonly isDirty: boolean;
  6223. stencilFunc: number;
  6224. stencilFuncRef: number;
  6225. stencilFuncMask: number;
  6226. stencilOpStencilFail: number;
  6227. stencilOpDepthFail: number;
  6228. stencilOpStencilDepthPass: number;
  6229. stencilMask: number;
  6230. stencilTest: boolean;
  6231. constructor();
  6232. reset(): void;
  6233. apply(gl: WebGLRenderingContext): void;
  6234. }
  6235. }
  6236. declare module "babylonjs/States/index" {
  6237. export * from "babylonjs/States/alphaCullingState";
  6238. export * from "babylonjs/States/depthCullingState";
  6239. export * from "babylonjs/States/stencilState";
  6240. }
  6241. declare module "babylonjs/Instrumentation/timeToken" {
  6242. import { Nullable } from "babylonjs/types";
  6243. /**
  6244. * @hidden
  6245. **/
  6246. export class _TimeToken {
  6247. _startTimeQuery: Nullable<WebGLQuery>;
  6248. _endTimeQuery: Nullable<WebGLQuery>;
  6249. _timeElapsedQuery: Nullable<WebGLQuery>;
  6250. _timeElapsedQueryEnded: boolean;
  6251. }
  6252. }
  6253. declare module "babylonjs/Materials/Textures/internalTexture" {
  6254. import { Observable } from "babylonjs/Misc/observable";
  6255. import { Nullable, int } from "babylonjs/types";
  6256. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6257. import { Engine } from "babylonjs/Engines/engine";
  6258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6259. /**
  6260. * Class used to store data associated with WebGL texture data for the engine
  6261. * This class should not be used directly
  6262. */
  6263. export class InternalTexture {
  6264. /** hidden */
  6265. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6266. /**
  6267. * The source of the texture data is unknown
  6268. */
  6269. static DATASOURCE_UNKNOWN: number;
  6270. /**
  6271. * Texture data comes from an URL
  6272. */
  6273. static DATASOURCE_URL: number;
  6274. /**
  6275. * Texture data is only used for temporary storage
  6276. */
  6277. static DATASOURCE_TEMP: number;
  6278. /**
  6279. * Texture data comes from raw data (ArrayBuffer)
  6280. */
  6281. static DATASOURCE_RAW: number;
  6282. /**
  6283. * Texture content is dynamic (video or dynamic texture)
  6284. */
  6285. static DATASOURCE_DYNAMIC: number;
  6286. /**
  6287. * Texture content is generated by rendering to it
  6288. */
  6289. static DATASOURCE_RENDERTARGET: number;
  6290. /**
  6291. * Texture content is part of a multi render target process
  6292. */
  6293. static DATASOURCE_MULTIRENDERTARGET: number;
  6294. /**
  6295. * Texture data comes from a cube data file
  6296. */
  6297. static DATASOURCE_CUBE: number;
  6298. /**
  6299. * Texture data comes from a raw cube data
  6300. */
  6301. static DATASOURCE_CUBERAW: number;
  6302. /**
  6303. * Texture data come from a prefiltered cube data file
  6304. */
  6305. static DATASOURCE_CUBEPREFILTERED: number;
  6306. /**
  6307. * Texture content is raw 3D data
  6308. */
  6309. static DATASOURCE_RAW3D: number;
  6310. /**
  6311. * Texture content is a depth texture
  6312. */
  6313. static DATASOURCE_DEPTHTEXTURE: number;
  6314. /**
  6315. * Texture data comes from a raw cube data encoded with RGBD
  6316. */
  6317. static DATASOURCE_CUBERAW_RGBD: number;
  6318. /**
  6319. * Defines if the texture is ready
  6320. */
  6321. isReady: boolean;
  6322. /**
  6323. * Defines if the texture is a cube texture
  6324. */
  6325. isCube: boolean;
  6326. /**
  6327. * Defines if the texture contains 3D data
  6328. */
  6329. is3D: boolean;
  6330. /**
  6331. * Defines if the texture contains multiview data
  6332. */
  6333. isMultiview: boolean;
  6334. /**
  6335. * Gets the URL used to load this texture
  6336. */
  6337. url: string;
  6338. /**
  6339. * Gets the sampling mode of the texture
  6340. */
  6341. samplingMode: number;
  6342. /**
  6343. * Gets a boolean indicating if the texture needs mipmaps generation
  6344. */
  6345. generateMipMaps: boolean;
  6346. /**
  6347. * Gets the number of samples used by the texture (WebGL2+ only)
  6348. */
  6349. samples: number;
  6350. /**
  6351. * Gets the type of the texture (int, float...)
  6352. */
  6353. type: number;
  6354. /**
  6355. * Gets the format of the texture (RGB, RGBA...)
  6356. */
  6357. format: number;
  6358. /**
  6359. * Observable called when the texture is loaded
  6360. */
  6361. onLoadedObservable: Observable<InternalTexture>;
  6362. /**
  6363. * Gets the width of the texture
  6364. */
  6365. width: number;
  6366. /**
  6367. * Gets the height of the texture
  6368. */
  6369. height: number;
  6370. /**
  6371. * Gets the depth of the texture
  6372. */
  6373. depth: number;
  6374. /**
  6375. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6376. */
  6377. baseWidth: number;
  6378. /**
  6379. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6380. */
  6381. baseHeight: number;
  6382. /**
  6383. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6384. */
  6385. baseDepth: number;
  6386. /**
  6387. * Gets a boolean indicating if the texture is inverted on Y axis
  6388. */
  6389. invertY: boolean;
  6390. /** @hidden */
  6391. _invertVScale: boolean;
  6392. /** @hidden */
  6393. _associatedChannel: number;
  6394. /** @hidden */
  6395. _dataSource: number;
  6396. /** @hidden */
  6397. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6398. /** @hidden */
  6399. _bufferView: Nullable<ArrayBufferView>;
  6400. /** @hidden */
  6401. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6402. /** @hidden */
  6403. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6404. /** @hidden */
  6405. _size: number;
  6406. /** @hidden */
  6407. _extension: string;
  6408. /** @hidden */
  6409. _files: Nullable<string[]>;
  6410. /** @hidden */
  6411. _workingCanvas: Nullable<HTMLCanvasElement>;
  6412. /** @hidden */
  6413. _workingContext: Nullable<CanvasRenderingContext2D>;
  6414. /** @hidden */
  6415. _framebuffer: Nullable<WebGLFramebuffer>;
  6416. /** @hidden */
  6417. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6418. /** @hidden */
  6419. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6420. /** @hidden */
  6421. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6422. /** @hidden */
  6423. _attachments: Nullable<number[]>;
  6424. /** @hidden */
  6425. _cachedCoordinatesMode: Nullable<number>;
  6426. /** @hidden */
  6427. _cachedWrapU: Nullable<number>;
  6428. /** @hidden */
  6429. _cachedWrapV: Nullable<number>;
  6430. /** @hidden */
  6431. _cachedWrapR: Nullable<number>;
  6432. /** @hidden */
  6433. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6434. /** @hidden */
  6435. _isDisabled: boolean;
  6436. /** @hidden */
  6437. _compression: Nullable<string>;
  6438. /** @hidden */
  6439. _generateStencilBuffer: boolean;
  6440. /** @hidden */
  6441. _generateDepthBuffer: boolean;
  6442. /** @hidden */
  6443. _comparisonFunction: number;
  6444. /** @hidden */
  6445. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6446. /** @hidden */
  6447. _lodGenerationScale: number;
  6448. /** @hidden */
  6449. _lodGenerationOffset: number;
  6450. /** @hidden */
  6451. _colorTextureArray: Nullable<WebGLTexture>;
  6452. /** @hidden */
  6453. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6454. /** @hidden */
  6455. _lodTextureHigh: Nullable<BaseTexture>;
  6456. /** @hidden */
  6457. _lodTextureMid: Nullable<BaseTexture>;
  6458. /** @hidden */
  6459. _lodTextureLow: Nullable<BaseTexture>;
  6460. /** @hidden */
  6461. _isRGBD: boolean;
  6462. /** @hidden */
  6463. _webGLTexture: Nullable<WebGLTexture>;
  6464. /** @hidden */
  6465. _references: number;
  6466. private _engine;
  6467. /**
  6468. * Gets the Engine the texture belongs to.
  6469. * @returns The babylon engine
  6470. */
  6471. getEngine(): Engine;
  6472. /**
  6473. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6474. */
  6475. readonly dataSource: number;
  6476. /**
  6477. * Creates a new InternalTexture
  6478. * @param engine defines the engine to use
  6479. * @param dataSource defines the type of data that will be used
  6480. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6481. */
  6482. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6483. /**
  6484. * Increments the number of references (ie. the number of Texture that point to it)
  6485. */
  6486. incrementReferences(): void;
  6487. /**
  6488. * Change the size of the texture (not the size of the content)
  6489. * @param width defines the new width
  6490. * @param height defines the new height
  6491. * @param depth defines the new depth (1 by default)
  6492. */
  6493. updateSize(width: int, height: int, depth?: int): void;
  6494. /** @hidden */
  6495. _rebuild(): void;
  6496. /** @hidden */
  6497. _swapAndDie(target: InternalTexture): void;
  6498. /**
  6499. * Dispose the current allocated resources
  6500. */
  6501. dispose(): void;
  6502. }
  6503. }
  6504. declare module "babylonjs/Animations/easing" {
  6505. /**
  6506. * This represents the main contract an easing function should follow.
  6507. * Easing functions are used throughout the animation system.
  6508. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6509. */
  6510. export interface IEasingFunction {
  6511. /**
  6512. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6513. * of the easing function.
  6514. * The link below provides some of the most common examples of easing functions.
  6515. * @see https://easings.net/
  6516. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6517. * @returns the corresponding value on the curve defined by the easing function
  6518. */
  6519. ease(gradient: number): number;
  6520. }
  6521. /**
  6522. * Base class used for every default easing function.
  6523. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6524. */
  6525. export class EasingFunction implements IEasingFunction {
  6526. /**
  6527. * Interpolation follows the mathematical formula associated with the easing function.
  6528. */
  6529. static readonly EASINGMODE_EASEIN: number;
  6530. /**
  6531. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6532. */
  6533. static readonly EASINGMODE_EASEOUT: number;
  6534. /**
  6535. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6536. */
  6537. static readonly EASINGMODE_EASEINOUT: number;
  6538. private _easingMode;
  6539. /**
  6540. * Sets the easing mode of the current function.
  6541. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6542. */
  6543. setEasingMode(easingMode: number): void;
  6544. /**
  6545. * Gets the current easing mode.
  6546. * @returns the easing mode
  6547. */
  6548. getEasingMode(): number;
  6549. /**
  6550. * @hidden
  6551. */
  6552. easeInCore(gradient: number): number;
  6553. /**
  6554. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6555. * of the easing function.
  6556. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6557. * @returns the corresponding value on the curve defined by the easing function
  6558. */
  6559. ease(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with a circle shape (see link below).
  6563. * @see https://easings.net/#easeInCirc
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class CircleEase extends EasingFunction implements IEasingFunction {
  6567. /** @hidden */
  6568. easeInCore(gradient: number): number;
  6569. }
  6570. /**
  6571. * Easing function with a ease back shape (see link below).
  6572. * @see https://easings.net/#easeInBack
  6573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6574. */
  6575. export class BackEase extends EasingFunction implements IEasingFunction {
  6576. /** Defines the amplitude of the function */
  6577. amplitude: number;
  6578. /**
  6579. * Instantiates a back ease easing
  6580. * @see https://easings.net/#easeInBack
  6581. * @param amplitude Defines the amplitude of the function
  6582. */
  6583. constructor(
  6584. /** Defines the amplitude of the function */
  6585. amplitude?: number);
  6586. /** @hidden */
  6587. easeInCore(gradient: number): number;
  6588. }
  6589. /**
  6590. * Easing function with a bouncing shape (see link below).
  6591. * @see https://easings.net/#easeInBounce
  6592. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6593. */
  6594. export class BounceEase extends EasingFunction implements IEasingFunction {
  6595. /** Defines the number of bounces */
  6596. bounces: number;
  6597. /** Defines the amplitude of the bounce */
  6598. bounciness: number;
  6599. /**
  6600. * Instantiates a bounce easing
  6601. * @see https://easings.net/#easeInBounce
  6602. * @param bounces Defines the number of bounces
  6603. * @param bounciness Defines the amplitude of the bounce
  6604. */
  6605. constructor(
  6606. /** Defines the number of bounces */
  6607. bounces?: number,
  6608. /** Defines the amplitude of the bounce */
  6609. bounciness?: number);
  6610. /** @hidden */
  6611. easeInCore(gradient: number): number;
  6612. }
  6613. /**
  6614. * Easing function with a power of 3 shape (see link below).
  6615. * @see https://easings.net/#easeInCubic
  6616. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6617. */
  6618. export class CubicEase extends EasingFunction implements IEasingFunction {
  6619. /** @hidden */
  6620. easeInCore(gradient: number): number;
  6621. }
  6622. /**
  6623. * Easing function with an elastic shape (see link below).
  6624. * @see https://easings.net/#easeInElastic
  6625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6626. */
  6627. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6628. /** Defines the number of oscillations*/
  6629. oscillations: number;
  6630. /** Defines the amplitude of the oscillations*/
  6631. springiness: number;
  6632. /**
  6633. * Instantiates an elastic easing function
  6634. * @see https://easings.net/#easeInElastic
  6635. * @param oscillations Defines the number of oscillations
  6636. * @param springiness Defines the amplitude of the oscillations
  6637. */
  6638. constructor(
  6639. /** Defines the number of oscillations*/
  6640. oscillations?: number,
  6641. /** Defines the amplitude of the oscillations*/
  6642. springiness?: number);
  6643. /** @hidden */
  6644. easeInCore(gradient: number): number;
  6645. }
  6646. /**
  6647. * Easing function with an exponential shape (see link below).
  6648. * @see https://easings.net/#easeInExpo
  6649. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6650. */
  6651. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6652. /** Defines the exponent of the function */
  6653. exponent: number;
  6654. /**
  6655. * Instantiates an exponential easing function
  6656. * @see https://easings.net/#easeInExpo
  6657. * @param exponent Defines the exponent of the function
  6658. */
  6659. constructor(
  6660. /** Defines the exponent of the function */
  6661. exponent?: number);
  6662. /** @hidden */
  6663. easeInCore(gradient: number): number;
  6664. }
  6665. /**
  6666. * Easing function with a power shape (see link below).
  6667. * @see https://easings.net/#easeInQuad
  6668. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6669. */
  6670. export class PowerEase extends EasingFunction implements IEasingFunction {
  6671. /** Defines the power of the function */
  6672. power: number;
  6673. /**
  6674. * Instantiates an power base easing function
  6675. * @see https://easings.net/#easeInQuad
  6676. * @param power Defines the power of the function
  6677. */
  6678. constructor(
  6679. /** Defines the power of the function */
  6680. power?: number);
  6681. /** @hidden */
  6682. easeInCore(gradient: number): number;
  6683. }
  6684. /**
  6685. * Easing function with a power of 2 shape (see link below).
  6686. * @see https://easings.net/#easeInQuad
  6687. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6688. */
  6689. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6690. /** @hidden */
  6691. easeInCore(gradient: number): number;
  6692. }
  6693. /**
  6694. * Easing function with a power of 4 shape (see link below).
  6695. * @see https://easings.net/#easeInQuart
  6696. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6697. */
  6698. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6699. /** @hidden */
  6700. easeInCore(gradient: number): number;
  6701. }
  6702. /**
  6703. * Easing function with a power of 5 shape (see link below).
  6704. * @see https://easings.net/#easeInQuint
  6705. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6706. */
  6707. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6708. /** @hidden */
  6709. easeInCore(gradient: number): number;
  6710. }
  6711. /**
  6712. * Easing function with a sin shape (see link below).
  6713. * @see https://easings.net/#easeInSine
  6714. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6715. */
  6716. export class SineEase extends EasingFunction implements IEasingFunction {
  6717. /** @hidden */
  6718. easeInCore(gradient: number): number;
  6719. }
  6720. /**
  6721. * Easing function with a bezier shape (see link below).
  6722. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6723. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6724. */
  6725. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6726. /** Defines the x component of the start tangent in the bezier curve */
  6727. x1: number;
  6728. /** Defines the y component of the start tangent in the bezier curve */
  6729. y1: number;
  6730. /** Defines the x component of the end tangent in the bezier curve */
  6731. x2: number;
  6732. /** Defines the y component of the end tangent in the bezier curve */
  6733. y2: number;
  6734. /**
  6735. * Instantiates a bezier function
  6736. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6737. * @param x1 Defines the x component of the start tangent in the bezier curve
  6738. * @param y1 Defines the y component of the start tangent in the bezier curve
  6739. * @param x2 Defines the x component of the end tangent in the bezier curve
  6740. * @param y2 Defines the y component of the end tangent in the bezier curve
  6741. */
  6742. constructor(
  6743. /** Defines the x component of the start tangent in the bezier curve */
  6744. x1?: number,
  6745. /** Defines the y component of the start tangent in the bezier curve */
  6746. y1?: number,
  6747. /** Defines the x component of the end tangent in the bezier curve */
  6748. x2?: number,
  6749. /** Defines the y component of the end tangent in the bezier curve */
  6750. y2?: number);
  6751. /** @hidden */
  6752. easeInCore(gradient: number): number;
  6753. }
  6754. }
  6755. declare module "babylonjs/Animations/animationKey" {
  6756. /**
  6757. * Defines an interface which represents an animation key frame
  6758. */
  6759. export interface IAnimationKey {
  6760. /**
  6761. * Frame of the key frame
  6762. */
  6763. frame: number;
  6764. /**
  6765. * Value at the specifies key frame
  6766. */
  6767. value: any;
  6768. /**
  6769. * The input tangent for the cubic hermite spline
  6770. */
  6771. inTangent?: any;
  6772. /**
  6773. * The output tangent for the cubic hermite spline
  6774. */
  6775. outTangent?: any;
  6776. /**
  6777. * The animation interpolation type
  6778. */
  6779. interpolation?: AnimationKeyInterpolation;
  6780. }
  6781. /**
  6782. * Enum for the animation key frame interpolation type
  6783. */
  6784. export enum AnimationKeyInterpolation {
  6785. /**
  6786. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6787. */
  6788. STEP = 1
  6789. }
  6790. }
  6791. declare module "babylonjs/Animations/animationRange" {
  6792. /**
  6793. * Represents the range of an animation
  6794. */
  6795. export class AnimationRange {
  6796. /**The name of the animation range**/
  6797. name: string;
  6798. /**The starting frame of the animation */
  6799. from: number;
  6800. /**The ending frame of the animation*/
  6801. to: number;
  6802. /**
  6803. * Initializes the range of an animation
  6804. * @param name The name of the animation range
  6805. * @param from The starting frame of the animation
  6806. * @param to The ending frame of the animation
  6807. */
  6808. constructor(
  6809. /**The name of the animation range**/
  6810. name: string,
  6811. /**The starting frame of the animation */
  6812. from: number,
  6813. /**The ending frame of the animation*/
  6814. to: number);
  6815. /**
  6816. * Makes a copy of the animation range
  6817. * @returns A copy of the animation range
  6818. */
  6819. clone(): AnimationRange;
  6820. }
  6821. }
  6822. declare module "babylonjs/Animations/animationEvent" {
  6823. /**
  6824. * Composed of a frame, and an action function
  6825. */
  6826. export class AnimationEvent {
  6827. /** The frame for which the event is triggered **/
  6828. frame: number;
  6829. /** The event to perform when triggered **/
  6830. action: (currentFrame: number) => void;
  6831. /** Specifies if the event should be triggered only once**/
  6832. onlyOnce?: boolean | undefined;
  6833. /**
  6834. * Specifies if the animation event is done
  6835. */
  6836. isDone: boolean;
  6837. /**
  6838. * Initializes the animation event
  6839. * @param frame The frame for which the event is triggered
  6840. * @param action The event to perform when triggered
  6841. * @param onlyOnce Specifies if the event should be triggered only once
  6842. */
  6843. constructor(
  6844. /** The frame for which the event is triggered **/
  6845. frame: number,
  6846. /** The event to perform when triggered **/
  6847. action: (currentFrame: number) => void,
  6848. /** Specifies if the event should be triggered only once**/
  6849. onlyOnce?: boolean | undefined);
  6850. /** @hidden */
  6851. _clone(): AnimationEvent;
  6852. }
  6853. }
  6854. declare module "babylonjs/Behaviors/behavior" {
  6855. import { Nullable } from "babylonjs/types";
  6856. /**
  6857. * Interface used to define a behavior
  6858. */
  6859. export interface Behavior<T> {
  6860. /** gets or sets behavior's name */
  6861. name: string;
  6862. /**
  6863. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6864. */
  6865. init(): void;
  6866. /**
  6867. * Called when the behavior is attached to a target
  6868. * @param target defines the target where the behavior is attached to
  6869. */
  6870. attach(target: T): void;
  6871. /**
  6872. * Called when the behavior is detached from its target
  6873. */
  6874. detach(): void;
  6875. }
  6876. /**
  6877. * Interface implemented by classes supporting behaviors
  6878. */
  6879. export interface IBehaviorAware<T> {
  6880. /**
  6881. * Attach a behavior
  6882. * @param behavior defines the behavior to attach
  6883. * @returns the current host
  6884. */
  6885. addBehavior(behavior: Behavior<T>): T;
  6886. /**
  6887. * Remove a behavior from the current object
  6888. * @param behavior defines the behavior to detach
  6889. * @returns the current host
  6890. */
  6891. removeBehavior(behavior: Behavior<T>): T;
  6892. /**
  6893. * Gets a behavior using its name to search
  6894. * @param name defines the name to search
  6895. * @returns the behavior or null if not found
  6896. */
  6897. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6898. }
  6899. }
  6900. declare module "babylonjs/Collisions/intersectionInfo" {
  6901. import { Nullable } from "babylonjs/types";
  6902. /**
  6903. * @hidden
  6904. */
  6905. export class IntersectionInfo {
  6906. bu: Nullable<number>;
  6907. bv: Nullable<number>;
  6908. distance: number;
  6909. faceId: number;
  6910. subMeshId: number;
  6911. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6912. }
  6913. }
  6914. declare module "babylonjs/Culling/boundingSphere" {
  6915. import { DeepImmutable } from "babylonjs/types";
  6916. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6917. /**
  6918. * Class used to store bounding sphere information
  6919. */
  6920. export class BoundingSphere {
  6921. /**
  6922. * Gets the center of the bounding sphere in local space
  6923. */
  6924. readonly center: Vector3;
  6925. /**
  6926. * Radius of the bounding sphere in local space
  6927. */
  6928. radius: number;
  6929. /**
  6930. * Gets the center of the bounding sphere in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Radius of the bounding sphere in world space
  6935. */
  6936. radiusWorld: number;
  6937. /**
  6938. * Gets the minimum vector in local space
  6939. */
  6940. readonly minimum: Vector3;
  6941. /**
  6942. * Gets the maximum vector in local space
  6943. */
  6944. readonly maximum: Vector3;
  6945. private _worldMatrix;
  6946. private static readonly TmpVector3;
  6947. /**
  6948. * Creates a new bounding sphere
  6949. * @param min defines the minimum vector (in local space)
  6950. * @param max defines the maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6954. /**
  6955. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6956. * @param min defines the new minimum vector (in local space)
  6957. * @param max defines the new maximum vector (in local space)
  6958. * @param worldMatrix defines the new world matrix
  6959. */
  6960. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6961. /**
  6962. * Scale the current bounding sphere by applying a scale factor
  6963. * @param factor defines the scale factor to apply
  6964. * @returns the current bounding box
  6965. */
  6966. scale(factor: number): BoundingSphere;
  6967. /**
  6968. * Gets the world matrix of the bounding box
  6969. * @returns a matrix
  6970. */
  6971. getWorldMatrix(): DeepImmutable<Matrix>;
  6972. /** @hidden */
  6973. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6974. /**
  6975. * Tests if the bounding sphere is intersecting the frustum planes
  6976. * @param frustumPlanes defines the frustum planes to test
  6977. * @returns true if there is an intersection
  6978. */
  6979. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6980. /**
  6981. * Tests if the bounding sphere center is in between the frustum planes.
  6982. * Used for optimistic fast inclusion.
  6983. * @param frustumPlanes defines the frustum planes to test
  6984. * @returns true if the sphere center is in between the frustum planes
  6985. */
  6986. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6987. /**
  6988. * Tests if a point is inside the bounding sphere
  6989. * @param point defines the point to test
  6990. * @returns true if the point is inside the bounding sphere
  6991. */
  6992. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6993. /**
  6994. * Checks if two sphere intersct
  6995. * @param sphere0 sphere 0
  6996. * @param sphere1 sphere 1
  6997. * @returns true if the speres intersect
  6998. */
  6999. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7000. }
  7001. }
  7002. declare module "babylonjs/Culling/boundingBox" {
  7003. import { DeepImmutable } from "babylonjs/types";
  7004. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7005. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7006. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7007. /**
  7008. * Class used to store bounding box information
  7009. */
  7010. export class BoundingBox implements ICullable {
  7011. /**
  7012. * Gets the 8 vectors representing the bounding box in local space
  7013. */
  7014. readonly vectors: Vector3[];
  7015. /**
  7016. * Gets the center of the bounding box in local space
  7017. */
  7018. readonly center: Vector3;
  7019. /**
  7020. * Gets the center of the bounding box in world space
  7021. */
  7022. readonly centerWorld: Vector3;
  7023. /**
  7024. * Gets the extend size in local space
  7025. */
  7026. readonly extendSize: Vector3;
  7027. /**
  7028. * Gets the extend size in world space
  7029. */
  7030. readonly extendSizeWorld: Vector3;
  7031. /**
  7032. * Gets the OBB (object bounding box) directions
  7033. */
  7034. readonly directions: Vector3[];
  7035. /**
  7036. * Gets the 8 vectors representing the bounding box in world space
  7037. */
  7038. readonly vectorsWorld: Vector3[];
  7039. /**
  7040. * Gets the minimum vector in world space
  7041. */
  7042. readonly minimumWorld: Vector3;
  7043. /**
  7044. * Gets the maximum vector in world space
  7045. */
  7046. readonly maximumWorld: Vector3;
  7047. /**
  7048. * Gets the minimum vector in local space
  7049. */
  7050. readonly minimum: Vector3;
  7051. /**
  7052. * Gets the maximum vector in local space
  7053. */
  7054. readonly maximum: Vector3;
  7055. private _worldMatrix;
  7056. private static readonly TmpVector3;
  7057. /**
  7058. * @hidden
  7059. */
  7060. _tag: number;
  7061. /**
  7062. * Creates a new bounding box
  7063. * @param min defines the minimum vector (in local space)
  7064. * @param max defines the maximum vector (in local space)
  7065. * @param worldMatrix defines the new world matrix
  7066. */
  7067. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7068. /**
  7069. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7070. * @param min defines the new minimum vector (in local space)
  7071. * @param max defines the new maximum vector (in local space)
  7072. * @param worldMatrix defines the new world matrix
  7073. */
  7074. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7075. /**
  7076. * Scale the current bounding box by applying a scale factor
  7077. * @param factor defines the scale factor to apply
  7078. * @returns the current bounding box
  7079. */
  7080. scale(factor: number): BoundingBox;
  7081. /**
  7082. * Gets the world matrix of the bounding box
  7083. * @returns a matrix
  7084. */
  7085. getWorldMatrix(): DeepImmutable<Matrix>;
  7086. /** @hidden */
  7087. _update(world: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * Tests if the bounding box is intersecting the frustum planes
  7090. * @param frustumPlanes defines the frustum planes to test
  7091. * @returns true if there is an intersection
  7092. */
  7093. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7094. /**
  7095. * Tests if the bounding box is entirely inside the frustum planes
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if there is an inclusion
  7098. */
  7099. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if a point is inside the bounding box
  7102. * @param point defines the point to test
  7103. * @returns true if the point is inside the bounding box
  7104. */
  7105. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7106. /**
  7107. * Tests if the bounding box intersects with a bounding sphere
  7108. * @param sphere defines the sphere to test
  7109. * @returns true if there is an intersection
  7110. */
  7111. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7112. /**
  7113. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7114. * @param min defines the min vector to use
  7115. * @param max defines the max vector to use
  7116. * @returns true if there is an intersection
  7117. */
  7118. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7119. /**
  7120. * Tests if two bounding boxes are intersections
  7121. * @param box0 defines the first box to test
  7122. * @param box1 defines the second box to test
  7123. * @returns true if there is an intersection
  7124. */
  7125. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7126. /**
  7127. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7128. * @param minPoint defines the minimum vector of the bounding box
  7129. * @param maxPoint defines the maximum vector of the bounding box
  7130. * @param sphereCenter defines the sphere center
  7131. * @param sphereRadius defines the sphere radius
  7132. * @returns true if there is an intersection
  7133. */
  7134. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7135. /**
  7136. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7137. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7138. * @param frustumPlanes defines the frustum planes to test
  7139. * @return true if there is an inclusion
  7140. */
  7141. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7142. /**
  7143. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7144. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7145. * @param frustumPlanes defines the frustum planes to test
  7146. * @return true if there is an intersection
  7147. */
  7148. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7149. }
  7150. }
  7151. declare module "babylonjs/Collisions/collider" {
  7152. import { Nullable, IndicesArray } from "babylonjs/types";
  7153. import { Vector3, Plane } from "babylonjs/Maths/math";
  7154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7155. /** @hidden */
  7156. export class Collider {
  7157. /** Define if a collision was found */
  7158. collisionFound: boolean;
  7159. /**
  7160. * Define last intersection point in local space
  7161. */
  7162. intersectionPoint: Vector3;
  7163. /**
  7164. * Define last collided mesh
  7165. */
  7166. collidedMesh: Nullable<AbstractMesh>;
  7167. private _collisionPoint;
  7168. private _planeIntersectionPoint;
  7169. private _tempVector;
  7170. private _tempVector2;
  7171. private _tempVector3;
  7172. private _tempVector4;
  7173. private _edge;
  7174. private _baseToVertex;
  7175. private _destinationPoint;
  7176. private _slidePlaneNormal;
  7177. private _displacementVector;
  7178. /** @hidden */
  7179. _radius: Vector3;
  7180. /** @hidden */
  7181. _retry: number;
  7182. private _velocity;
  7183. private _basePoint;
  7184. private _epsilon;
  7185. /** @hidden */
  7186. _velocityWorldLength: number;
  7187. /** @hidden */
  7188. _basePointWorld: Vector3;
  7189. private _velocityWorld;
  7190. private _normalizedVelocity;
  7191. /** @hidden */
  7192. _initialVelocity: Vector3;
  7193. /** @hidden */
  7194. _initialPosition: Vector3;
  7195. private _nearestDistance;
  7196. private _collisionMask;
  7197. collisionMask: number;
  7198. /**
  7199. * Gets the plane normal used to compute the sliding response (in local space)
  7200. */
  7201. readonly slidePlaneNormal: Vector3;
  7202. /** @hidden */
  7203. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7204. /** @hidden */
  7205. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7206. /** @hidden */
  7207. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7208. /** @hidden */
  7209. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7210. /** @hidden */
  7211. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7212. /** @hidden */
  7213. _getResponse(pos: Vector3, vel: Vector3): void;
  7214. }
  7215. }
  7216. declare module "babylonjs/Culling/boundingInfo" {
  7217. import { DeepImmutable } from "babylonjs/types";
  7218. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7219. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7220. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7221. import { Collider } from "babylonjs/Collisions/collider";
  7222. /**
  7223. * Interface for cullable objects
  7224. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7225. */
  7226. export interface ICullable {
  7227. /**
  7228. * Checks if the object or part of the object is in the frustum
  7229. * @param frustumPlanes Camera near/planes
  7230. * @returns true if the object is in frustum otherwise false
  7231. */
  7232. isInFrustum(frustumPlanes: Plane[]): boolean;
  7233. /**
  7234. * Checks if a cullable object (mesh...) is in the camera frustum
  7235. * Unlike isInFrustum this cheks the full bounding box
  7236. * @param frustumPlanes Camera near/planes
  7237. * @returns true if the object is in frustum otherwise false
  7238. */
  7239. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7240. }
  7241. /**
  7242. * Info for a bounding data of a mesh
  7243. */
  7244. export class BoundingInfo implements ICullable {
  7245. /**
  7246. * Bounding box for the mesh
  7247. */
  7248. readonly boundingBox: BoundingBox;
  7249. /**
  7250. * Bounding sphere for the mesh
  7251. */
  7252. readonly boundingSphere: BoundingSphere;
  7253. private _isLocked;
  7254. private static readonly TmpVector3;
  7255. /**
  7256. * Constructs bounding info
  7257. * @param minimum min vector of the bounding box/sphere
  7258. * @param maximum max vector of the bounding box/sphere
  7259. * @param worldMatrix defines the new world matrix
  7260. */
  7261. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7262. /**
  7263. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7264. * @param min defines the new minimum vector (in local space)
  7265. * @param max defines the new maximum vector (in local space)
  7266. * @param worldMatrix defines the new world matrix
  7267. */
  7268. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7269. /**
  7270. * min vector of the bounding box/sphere
  7271. */
  7272. readonly minimum: Vector3;
  7273. /**
  7274. * max vector of the bounding box/sphere
  7275. */
  7276. readonly maximum: Vector3;
  7277. /**
  7278. * If the info is locked and won't be updated to avoid perf overhead
  7279. */
  7280. isLocked: boolean;
  7281. /**
  7282. * Updates the bounding sphere and box
  7283. * @param world world matrix to be used to update
  7284. */
  7285. update(world: DeepImmutable<Matrix>): void;
  7286. /**
  7287. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7288. * @param center New center of the bounding info
  7289. * @param extend New extend of the bounding info
  7290. * @returns the current bounding info
  7291. */
  7292. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7293. /**
  7294. * Scale the current bounding info by applying a scale factor
  7295. * @param factor defines the scale factor to apply
  7296. * @returns the current bounding info
  7297. */
  7298. scale(factor: number): BoundingInfo;
  7299. /**
  7300. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7301. * @param frustumPlanes defines the frustum to test
  7302. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7303. * @returns true if the bounding info is in the frustum planes
  7304. */
  7305. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7306. /**
  7307. * Gets the world distance between the min and max points of the bounding box
  7308. */
  7309. readonly diagonalLength: number;
  7310. /**
  7311. * Checks if a cullable object (mesh...) is in the camera frustum
  7312. * Unlike isInFrustum this cheks the full bounding box
  7313. * @param frustumPlanes Camera near/planes
  7314. * @returns true if the object is in frustum otherwise false
  7315. */
  7316. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7317. /** @hidden */
  7318. _checkCollision(collider: Collider): boolean;
  7319. /**
  7320. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7321. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7322. * @param point the point to check intersection with
  7323. * @returns if the point intersects
  7324. */
  7325. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7326. /**
  7327. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7328. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7329. * @param boundingInfo the bounding info to check intersection with
  7330. * @param precise if the intersection should be done using OBB
  7331. * @returns if the bounding info intersects
  7332. */
  7333. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7334. }
  7335. }
  7336. declare module "babylonjs/Misc/smartArray" {
  7337. /**
  7338. * Defines an array and its length.
  7339. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7340. */
  7341. export interface ISmartArrayLike<T> {
  7342. /**
  7343. * The data of the array.
  7344. */
  7345. data: Array<T>;
  7346. /**
  7347. * The active length of the array.
  7348. */
  7349. length: number;
  7350. }
  7351. /**
  7352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7353. */
  7354. export class SmartArray<T> implements ISmartArrayLike<T> {
  7355. /**
  7356. * The full set of data from the array.
  7357. */
  7358. data: Array<T>;
  7359. /**
  7360. * The active length of the array.
  7361. */
  7362. length: number;
  7363. protected _id: number;
  7364. /**
  7365. * Instantiates a Smart Array.
  7366. * @param capacity defines the default capacity of the array.
  7367. */
  7368. constructor(capacity: number);
  7369. /**
  7370. * Pushes a value at the end of the active data.
  7371. * @param value defines the object to push in the array.
  7372. */
  7373. push(value: T): void;
  7374. /**
  7375. * Iterates over the active data and apply the lambda to them.
  7376. * @param func defines the action to apply on each value.
  7377. */
  7378. forEach(func: (content: T) => void): void;
  7379. /**
  7380. * Sorts the full sets of data.
  7381. * @param compareFn defines the comparison function to apply.
  7382. */
  7383. sort(compareFn: (a: T, b: T) => number): void;
  7384. /**
  7385. * Resets the active data to an empty array.
  7386. */
  7387. reset(): void;
  7388. /**
  7389. * Releases all the data from the array as well as the array.
  7390. */
  7391. dispose(): void;
  7392. /**
  7393. * Concats the active data with a given array.
  7394. * @param array defines the data to concatenate with.
  7395. */
  7396. concat(array: any): void;
  7397. /**
  7398. * Returns the position of a value in the active data.
  7399. * @param value defines the value to find the index for
  7400. * @returns the index if found in the active data otherwise -1
  7401. */
  7402. indexOf(value: T): number;
  7403. /**
  7404. * Returns whether an element is part of the active data.
  7405. * @param value defines the value to look for
  7406. * @returns true if found in the active data otherwise false
  7407. */
  7408. contains(value: T): boolean;
  7409. private static _GlobalId;
  7410. }
  7411. /**
  7412. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7413. * The data in this array can only be present once
  7414. */
  7415. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7416. private _duplicateId;
  7417. /**
  7418. * Pushes a value at the end of the active data.
  7419. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7420. * @param value defines the object to push in the array.
  7421. */
  7422. push(value: T): void;
  7423. /**
  7424. * Pushes a value at the end of the active data.
  7425. * If the data is already present, it won t be added again
  7426. * @param value defines the object to push in the array.
  7427. * @returns true if added false if it was already present
  7428. */
  7429. pushNoDuplicate(value: T): boolean;
  7430. /**
  7431. * Resets the active data to an empty array.
  7432. */
  7433. reset(): void;
  7434. /**
  7435. * Concats the active data with a given array.
  7436. * This ensures no dupplicate will be present in the result.
  7437. * @param array defines the data to concatenate with.
  7438. */
  7439. concatWithNoDuplicate(array: any): void;
  7440. }
  7441. }
  7442. declare module "babylonjs/Materials/multiMaterial" {
  7443. import { Nullable } from "babylonjs/types";
  7444. import { Scene } from "babylonjs/scene";
  7445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7446. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7447. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7448. import { Material } from "babylonjs/Materials/material";
  7449. /**
  7450. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7451. * separate meshes. This can be use to improve performances.
  7452. * @see http://doc.babylonjs.com/how_to/multi_materials
  7453. */
  7454. export class MultiMaterial extends Material {
  7455. private _subMaterials;
  7456. /**
  7457. * Gets or Sets the list of Materials used within the multi material.
  7458. * They need to be ordered according to the submeshes order in the associated mesh
  7459. */
  7460. subMaterials: Nullable<Material>[];
  7461. /**
  7462. * Function used to align with Node.getChildren()
  7463. * @returns the list of Materials used within the multi material
  7464. */
  7465. getChildren(): Nullable<Material>[];
  7466. /**
  7467. * Instantiates a new Multi Material
  7468. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7469. * separate meshes. This can be use to improve performances.
  7470. * @see http://doc.babylonjs.com/how_to/multi_materials
  7471. * @param name Define the name in the scene
  7472. * @param scene Define the scene the material belongs to
  7473. */
  7474. constructor(name: string, scene: Scene);
  7475. private _hookArray;
  7476. /**
  7477. * Get one of the submaterial by its index in the submaterials array
  7478. * @param index The index to look the sub material at
  7479. * @returns The Material if the index has been defined
  7480. */
  7481. getSubMaterial(index: number): Nullable<Material>;
  7482. /**
  7483. * Get the list of active textures for the whole sub materials list.
  7484. * @returns All the textures that will be used during the rendering
  7485. */
  7486. getActiveTextures(): BaseTexture[];
  7487. /**
  7488. * Gets the current class name of the material e.g. "MultiMaterial"
  7489. * Mainly use in serialization.
  7490. * @returns the class name
  7491. */
  7492. getClassName(): string;
  7493. /**
  7494. * Checks if the material is ready to render the requested sub mesh
  7495. * @param mesh Define the mesh the submesh belongs to
  7496. * @param subMesh Define the sub mesh to look readyness for
  7497. * @param useInstances Define whether or not the material is used with instances
  7498. * @returns true if ready, otherwise false
  7499. */
  7500. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7501. /**
  7502. * Clones the current material and its related sub materials
  7503. * @param name Define the name of the newly cloned material
  7504. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7505. * @returns the cloned material
  7506. */
  7507. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7508. /**
  7509. * Serializes the materials into a JSON representation.
  7510. * @returns the JSON representation
  7511. */
  7512. serialize(): any;
  7513. /**
  7514. * Dispose the material and release its associated resources
  7515. * @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)
  7516. * @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)
  7517. * @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)
  7518. */
  7519. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7520. /**
  7521. * Creates a MultiMaterial from parsed MultiMaterial data.
  7522. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7523. * @param scene defines the hosting scene
  7524. * @returns a new MultiMaterial
  7525. */
  7526. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7527. }
  7528. }
  7529. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7530. /**
  7531. * Class used to represent data loading progression
  7532. */
  7533. export class SceneLoaderFlags {
  7534. private static _ForceFullSceneLoadingForIncremental;
  7535. private static _ShowLoadingScreen;
  7536. private static _CleanBoneMatrixWeights;
  7537. private static _loggingLevel;
  7538. /**
  7539. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7540. */
  7541. static ForceFullSceneLoadingForIncremental: boolean;
  7542. /**
  7543. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7544. */
  7545. static ShowLoadingScreen: boolean;
  7546. /**
  7547. * Defines the current logging level (while loading the scene)
  7548. * @ignorenaming
  7549. */
  7550. static loggingLevel: number;
  7551. /**
  7552. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7553. */
  7554. static CleanBoneMatrixWeights: boolean;
  7555. }
  7556. }
  7557. declare module "babylonjs/Meshes/transformNode" {
  7558. import { DeepImmutable } from "babylonjs/types";
  7559. import { Observable } from "babylonjs/Misc/observable";
  7560. import { Nullable } from "babylonjs/types";
  7561. import { Camera } from "babylonjs/Cameras/camera";
  7562. import { Scene } from "babylonjs/scene";
  7563. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7564. import { Node } from "babylonjs/node";
  7565. import { Bone } from "babylonjs/Bones/bone";
  7566. /**
  7567. * 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.
  7568. * @see https://doc.babylonjs.com/how_to/transformnode
  7569. */
  7570. export class TransformNode extends Node {
  7571. /**
  7572. * Object will not rotate to face the camera
  7573. */
  7574. static BILLBOARDMODE_NONE: number;
  7575. /**
  7576. * Object will rotate to face the camera but only on the x axis
  7577. */
  7578. static BILLBOARDMODE_X: number;
  7579. /**
  7580. * Object will rotate to face the camera but only on the y axis
  7581. */
  7582. static BILLBOARDMODE_Y: number;
  7583. /**
  7584. * Object will rotate to face the camera but only on the z axis
  7585. */
  7586. static BILLBOARDMODE_Z: number;
  7587. /**
  7588. * Object will rotate to face the camera
  7589. */
  7590. static BILLBOARDMODE_ALL: number;
  7591. private _forward;
  7592. private _forwardInverted;
  7593. private _up;
  7594. private _right;
  7595. private _rightInverted;
  7596. private _position;
  7597. private _rotation;
  7598. private _rotationQuaternion;
  7599. protected _scaling: Vector3;
  7600. protected _isDirty: boolean;
  7601. private _transformToBoneReferal;
  7602. private _billboardMode;
  7603. /**
  7604. * Gets or sets the billboard mode. Default is 0.
  7605. *
  7606. * | Value | Type | Description |
  7607. * | --- | --- | --- |
  7608. * | 0 | BILLBOARDMODE_NONE | |
  7609. * | 1 | BILLBOARDMODE_X | |
  7610. * | 2 | BILLBOARDMODE_Y | |
  7611. * | 4 | BILLBOARDMODE_Z | |
  7612. * | 7 | BILLBOARDMODE_ALL | |
  7613. *
  7614. */
  7615. billboardMode: number;
  7616. private _preserveParentRotationForBillboard;
  7617. /**
  7618. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7619. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7620. */
  7621. preserveParentRotationForBillboard: boolean;
  7622. /**
  7623. * 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
  7624. */
  7625. scalingDeterminant: number;
  7626. private _infiniteDistance;
  7627. /**
  7628. * Gets or sets the distance of the object to max, often used by skybox
  7629. */
  7630. infiniteDistance: boolean;
  7631. /**
  7632. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7633. * By default the system will update normals to compensate
  7634. */
  7635. ignoreNonUniformScaling: boolean;
  7636. /**
  7637. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7638. */
  7639. reIntegrateRotationIntoRotationQuaternion: boolean;
  7640. /** @hidden */
  7641. _poseMatrix: Nullable<Matrix>;
  7642. /** @hidden */
  7643. _localMatrix: Matrix;
  7644. private _usePivotMatrix;
  7645. private _absolutePosition;
  7646. private _pivotMatrix;
  7647. private _pivotMatrixInverse;
  7648. protected _postMultiplyPivotMatrix: boolean;
  7649. protected _isWorldMatrixFrozen: boolean;
  7650. /** @hidden */
  7651. _indexInSceneTransformNodesArray: number;
  7652. /**
  7653. * An event triggered after the world matrix is updated
  7654. */
  7655. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7656. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7657. /**
  7658. * Gets a string identifying the name of the class
  7659. * @returns "TransformNode" string
  7660. */
  7661. getClassName(): string;
  7662. /**
  7663. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7664. */
  7665. position: Vector3;
  7666. /**
  7667. * 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)).
  7668. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7669. */
  7670. rotation: Vector3;
  7671. /**
  7672. * 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)).
  7673. */
  7674. scaling: Vector3;
  7675. /**
  7676. * 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).
  7677. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7678. */
  7679. rotationQuaternion: Nullable<Quaternion>;
  7680. /**
  7681. * The forward direction of that transform in world space.
  7682. */
  7683. readonly forward: Vector3;
  7684. /**
  7685. * The up direction of that transform in world space.
  7686. */
  7687. readonly up: Vector3;
  7688. /**
  7689. * The right direction of that transform in world space.
  7690. */
  7691. readonly right: Vector3;
  7692. /**
  7693. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7694. * @param matrix the matrix to copy the pose from
  7695. * @returns this TransformNode.
  7696. */
  7697. updatePoseMatrix(matrix: Matrix): TransformNode;
  7698. /**
  7699. * Returns the mesh Pose matrix.
  7700. * @returns the pose matrix
  7701. */
  7702. getPoseMatrix(): Matrix;
  7703. /** @hidden */
  7704. _isSynchronized(): boolean;
  7705. /** @hidden */
  7706. _initCache(): void;
  7707. /**
  7708. * Flag the transform node as dirty (Forcing it to update everything)
  7709. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7710. * @returns this transform node
  7711. */
  7712. markAsDirty(property: string): TransformNode;
  7713. /**
  7714. * Returns the current mesh absolute position.
  7715. * Returns a Vector3.
  7716. */
  7717. readonly absolutePosition: Vector3;
  7718. /**
  7719. * Sets a new matrix to apply before all other transformation
  7720. * @param matrix defines the transform matrix
  7721. * @returns the current TransformNode
  7722. */
  7723. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7724. /**
  7725. * Sets a new pivot matrix to the current node
  7726. * @param matrix defines the new pivot matrix to use
  7727. * @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
  7728. * @returns the current TransformNode
  7729. */
  7730. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7731. /**
  7732. * Returns the mesh pivot matrix.
  7733. * Default : Identity.
  7734. * @returns the matrix
  7735. */
  7736. getPivotMatrix(): Matrix;
  7737. /**
  7738. * Prevents the World matrix to be computed any longer.
  7739. * @returns the TransformNode.
  7740. */
  7741. freezeWorldMatrix(): TransformNode;
  7742. /**
  7743. * Allows back the World matrix computation.
  7744. * @returns the TransformNode.
  7745. */
  7746. unfreezeWorldMatrix(): this;
  7747. /**
  7748. * True if the World matrix has been frozen.
  7749. */
  7750. readonly isWorldMatrixFrozen: boolean;
  7751. /**
  7752. * Retuns the mesh absolute position in the World.
  7753. * @returns a Vector3.
  7754. */
  7755. getAbsolutePosition(): Vector3;
  7756. /**
  7757. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7758. * @param absolutePosition the absolute position to set
  7759. * @returns the TransformNode.
  7760. */
  7761. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7762. /**
  7763. * Sets the mesh position in its local space.
  7764. * @param vector3 the position to set in localspace
  7765. * @returns the TransformNode.
  7766. */
  7767. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7768. /**
  7769. * Returns the mesh position in the local space from the current World matrix values.
  7770. * @returns a new Vector3.
  7771. */
  7772. getPositionExpressedInLocalSpace(): Vector3;
  7773. /**
  7774. * Translates the mesh along the passed Vector3 in its local space.
  7775. * @param vector3 the distance to translate in localspace
  7776. * @returns the TransformNode.
  7777. */
  7778. locallyTranslate(vector3: Vector3): TransformNode;
  7779. private static _lookAtVectorCache;
  7780. /**
  7781. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7782. * @param targetPoint the position (must be in same space as current mesh) to look at
  7783. * @param yawCor optional yaw (y-axis) correction in radians
  7784. * @param pitchCor optional pitch (x-axis) correction in radians
  7785. * @param rollCor optional roll (z-axis) correction in radians
  7786. * @param space the choosen space of the target
  7787. * @returns the TransformNode.
  7788. */
  7789. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7790. /**
  7791. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7792. * This Vector3 is expressed in the World space.
  7793. * @param localAxis axis to rotate
  7794. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7795. */
  7796. getDirection(localAxis: Vector3): Vector3;
  7797. /**
  7798. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7799. * localAxis is expressed in the mesh local space.
  7800. * result is computed in the Wordl space from the mesh World matrix.
  7801. * @param localAxis axis to rotate
  7802. * @param result the resulting transformnode
  7803. * @returns this TransformNode.
  7804. */
  7805. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7806. /**
  7807. * Sets this transform node rotation to the given local axis.
  7808. * @param localAxis the axis in local space
  7809. * @param yawCor optional yaw (y-axis) correction in radians
  7810. * @param pitchCor optional pitch (x-axis) correction in radians
  7811. * @param rollCor optional roll (z-axis) correction in radians
  7812. * @returns this TransformNode
  7813. */
  7814. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7815. /**
  7816. * Sets a new pivot point to the current node
  7817. * @param point defines the new pivot point to use
  7818. * @param space defines if the point is in world or local space (local by default)
  7819. * @returns the current TransformNode
  7820. */
  7821. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7822. /**
  7823. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7824. * @returns the pivot point
  7825. */
  7826. getPivotPoint(): Vector3;
  7827. /**
  7828. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7829. * @param result the vector3 to store the result
  7830. * @returns this TransformNode.
  7831. */
  7832. getPivotPointToRef(result: Vector3): TransformNode;
  7833. /**
  7834. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7835. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7836. */
  7837. getAbsolutePivotPoint(): Vector3;
  7838. /**
  7839. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7840. * @param result vector3 to store the result
  7841. * @returns this TransformNode.
  7842. */
  7843. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7844. /**
  7845. * Defines the passed node as the parent of the current node.
  7846. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7847. * @see https://doc.babylonjs.com/how_to/parenting
  7848. * @param node the node ot set as the parent
  7849. * @returns this TransformNode.
  7850. */
  7851. setParent(node: Nullable<Node>): TransformNode;
  7852. private _nonUniformScaling;
  7853. /**
  7854. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7855. */
  7856. readonly nonUniformScaling: boolean;
  7857. /** @hidden */
  7858. _updateNonUniformScalingState(value: boolean): boolean;
  7859. /**
  7860. * Attach the current TransformNode to another TransformNode associated with a bone
  7861. * @param bone Bone affecting the TransformNode
  7862. * @param affectedTransformNode TransformNode associated with the bone
  7863. * @returns this object
  7864. */
  7865. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7866. /**
  7867. * Detach the transform node if its associated with a bone
  7868. * @returns this object
  7869. */
  7870. detachFromBone(): TransformNode;
  7871. private static _rotationAxisCache;
  7872. /**
  7873. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7874. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7875. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7876. * The passed axis is also normalized.
  7877. * @param axis the axis to rotate around
  7878. * @param amount the amount to rotate in radians
  7879. * @param space Space to rotate in (Default: local)
  7880. * @returns the TransformNode.
  7881. */
  7882. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7883. /**
  7884. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7885. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7886. * The passed axis is also normalized. .
  7887. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7888. * @param point the point to rotate around
  7889. * @param axis the axis to rotate around
  7890. * @param amount the amount to rotate in radians
  7891. * @returns the TransformNode
  7892. */
  7893. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7894. /**
  7895. * Translates the mesh along the axis vector for the passed distance in the given space.
  7896. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7897. * @param axis the axis to translate in
  7898. * @param distance the distance to translate
  7899. * @param space Space to rotate in (Default: local)
  7900. * @returns the TransformNode.
  7901. */
  7902. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7903. /**
  7904. * Adds a rotation step to the mesh current rotation.
  7905. * x, y, z are Euler angles expressed in radians.
  7906. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7907. * This means this rotation is made in the mesh local space only.
  7908. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7909. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7910. * ```javascript
  7911. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7912. * ```
  7913. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7914. * 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.
  7915. * @param x Rotation to add
  7916. * @param y Rotation to add
  7917. * @param z Rotation to add
  7918. * @returns the TransformNode.
  7919. */
  7920. addRotation(x: number, y: number, z: number): TransformNode;
  7921. /**
  7922. * @hidden
  7923. */
  7924. protected _getEffectiveParent(): Nullable<Node>;
  7925. /**
  7926. * Computes the world matrix of the node
  7927. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7928. * @returns the world matrix
  7929. */
  7930. computeWorldMatrix(force?: boolean): Matrix;
  7931. protected _afterComputeWorldMatrix(): void;
  7932. /**
  7933. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7934. * @param func callback function to add
  7935. *
  7936. * @returns the TransformNode.
  7937. */
  7938. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7939. /**
  7940. * Removes a registered callback function.
  7941. * @param func callback function to remove
  7942. * @returns the TransformNode.
  7943. */
  7944. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7945. /**
  7946. * Gets the position of the current mesh in camera space
  7947. * @param camera defines the camera to use
  7948. * @returns a position
  7949. */
  7950. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7951. /**
  7952. * Returns the distance from the mesh to the active camera
  7953. * @param camera defines the camera to use
  7954. * @returns the distance
  7955. */
  7956. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7957. /**
  7958. * Clone the current transform node
  7959. * @param name Name of the new clone
  7960. * @param newParent New parent for the clone
  7961. * @param doNotCloneChildren Do not clone children hierarchy
  7962. * @returns the new transform node
  7963. */
  7964. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7965. /**
  7966. * Serializes the objects information.
  7967. * @param currentSerializationObject defines the object to serialize in
  7968. * @returns the serialized object
  7969. */
  7970. serialize(currentSerializationObject?: any): any;
  7971. /**
  7972. * Returns a new TransformNode object parsed from the source provided.
  7973. * @param parsedTransformNode is the source.
  7974. * @param scene the scne the object belongs to
  7975. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7976. * @returns a new TransformNode object parsed from the source provided.
  7977. */
  7978. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7979. /**
  7980. * Get all child-transformNodes of this node
  7981. * @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
  7982. * @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
  7983. * @returns an array of TransformNode
  7984. */
  7985. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7986. /**
  7987. * Releases resources associated with this transform node.
  7988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7990. */
  7991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7992. }
  7993. }
  7994. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7995. /**
  7996. * Class used to override all child animations of a given target
  7997. */
  7998. export class AnimationPropertiesOverride {
  7999. /**
  8000. * Gets or sets a value indicating if animation blending must be used
  8001. */
  8002. enableBlending: boolean;
  8003. /**
  8004. * Gets or sets the blending speed to use when enableBlending is true
  8005. */
  8006. blendingSpeed: number;
  8007. /**
  8008. * Gets or sets the default loop mode to use
  8009. */
  8010. loopMode: number;
  8011. }
  8012. }
  8013. declare module "babylonjs/Bones/bone" {
  8014. import { Skeleton } from "babylonjs/Bones/skeleton";
  8015. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8016. import { Nullable } from "babylonjs/types";
  8017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8019. import { Node } from "babylonjs/node";
  8020. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8021. /**
  8022. * Class used to store bone information
  8023. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8024. */
  8025. export class Bone extends Node {
  8026. /**
  8027. * defines the bone name
  8028. */
  8029. name: string;
  8030. private static _tmpVecs;
  8031. private static _tmpQuat;
  8032. private static _tmpMats;
  8033. /**
  8034. * Gets the list of child bones
  8035. */
  8036. children: Bone[];
  8037. /** Gets the animations associated with this bone */
  8038. animations: import("babylonjs/Animations/animation").Animation[];
  8039. /**
  8040. * Gets or sets bone length
  8041. */
  8042. length: number;
  8043. /**
  8044. * @hidden Internal only
  8045. * Set this value to map this bone to a different index in the transform matrices
  8046. * Set this value to -1 to exclude the bone from the transform matrices
  8047. */
  8048. _index: Nullable<number>;
  8049. private _skeleton;
  8050. private _localMatrix;
  8051. private _restPose;
  8052. private _baseMatrix;
  8053. private _absoluteTransform;
  8054. private _invertedAbsoluteTransform;
  8055. private _parent;
  8056. private _scalingDeterminant;
  8057. private _worldTransform;
  8058. private _localScaling;
  8059. private _localRotation;
  8060. private _localPosition;
  8061. private _needToDecompose;
  8062. private _needToCompose;
  8063. /** @hidden */
  8064. _linkedTransformNode: Nullable<TransformNode>;
  8065. /** @hidden */
  8066. _waitingTransformNodeId: Nullable<string>;
  8067. /** @hidden */
  8068. /** @hidden */
  8069. _matrix: Matrix;
  8070. /**
  8071. * Create a new bone
  8072. * @param name defines the bone name
  8073. * @param skeleton defines the parent skeleton
  8074. * @param parentBone defines the parent (can be null if the bone is the root)
  8075. * @param localMatrix defines the local matrix
  8076. * @param restPose defines the rest pose matrix
  8077. * @param baseMatrix defines the base matrix
  8078. * @param index defines index of the bone in the hiearchy
  8079. */
  8080. constructor(
  8081. /**
  8082. * defines the bone name
  8083. */
  8084. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8085. /**
  8086. * Gets the current object class name.
  8087. * @return the class name
  8088. */
  8089. getClassName(): string;
  8090. /**
  8091. * Gets the parent skeleton
  8092. * @returns a skeleton
  8093. */
  8094. getSkeleton(): Skeleton;
  8095. /**
  8096. * Gets parent bone
  8097. * @returns a bone or null if the bone is the root of the bone hierarchy
  8098. */
  8099. getParent(): Nullable<Bone>;
  8100. /**
  8101. * Returns an array containing the root bones
  8102. * @returns an array containing the root bones
  8103. */
  8104. getChildren(): Array<Bone>;
  8105. /**
  8106. * Sets the parent bone
  8107. * @param parent defines the parent (can be null if the bone is the root)
  8108. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8109. */
  8110. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8111. /**
  8112. * Gets the local matrix
  8113. * @returns a matrix
  8114. */
  8115. getLocalMatrix(): Matrix;
  8116. /**
  8117. * Gets the base matrix (initial matrix which remains unchanged)
  8118. * @returns a matrix
  8119. */
  8120. getBaseMatrix(): Matrix;
  8121. /**
  8122. * Gets the rest pose matrix
  8123. * @returns a matrix
  8124. */
  8125. getRestPose(): Matrix;
  8126. /**
  8127. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8128. */
  8129. getWorldMatrix(): Matrix;
  8130. /**
  8131. * Sets the local matrix to rest pose matrix
  8132. */
  8133. returnToRest(): void;
  8134. /**
  8135. * Gets the inverse of the absolute transform matrix.
  8136. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8137. * @returns a matrix
  8138. */
  8139. getInvertedAbsoluteTransform(): Matrix;
  8140. /**
  8141. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8142. * @returns a matrix
  8143. */
  8144. getAbsoluteTransform(): Matrix;
  8145. /**
  8146. * Links with the given transform node.
  8147. * The local matrix of this bone is copied from the transform node every frame.
  8148. * @param transformNode defines the transform node to link to
  8149. */
  8150. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8151. /** Gets or sets current position (in local space) */
  8152. position: Vector3;
  8153. /** Gets or sets current rotation (in local space) */
  8154. rotation: Vector3;
  8155. /** Gets or sets current rotation quaternion (in local space) */
  8156. rotationQuaternion: Quaternion;
  8157. /** Gets or sets current scaling (in local space) */
  8158. scaling: Vector3;
  8159. /**
  8160. * Gets the animation properties override
  8161. */
  8162. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8163. private _decompose;
  8164. private _compose;
  8165. /**
  8166. * Update the base and local matrices
  8167. * @param matrix defines the new base or local matrix
  8168. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8169. * @param updateLocalMatrix defines if the local matrix should be updated
  8170. */
  8171. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8172. /** @hidden */
  8173. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8174. /**
  8175. * Flag the bone as dirty (Forcing it to update everything)
  8176. */
  8177. markAsDirty(): void;
  8178. private _markAsDirtyAndCompose;
  8179. private _markAsDirtyAndDecompose;
  8180. /**
  8181. * Translate the bone in local or world space
  8182. * @param vec The amount to translate the bone
  8183. * @param space The space that the translation is in
  8184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8185. */
  8186. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8187. /**
  8188. * Set the postion of the bone in local or world space
  8189. * @param position The position to set the bone
  8190. * @param space The space that the position is in
  8191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8192. */
  8193. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8194. /**
  8195. * Set the absolute position of the bone (world space)
  8196. * @param position The position to set the bone
  8197. * @param mesh The mesh that this bone is attached to
  8198. */
  8199. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8200. /**
  8201. * Scale the bone on the x, y and z axes (in local space)
  8202. * @param x The amount to scale the bone on the x axis
  8203. * @param y The amount to scale the bone on the y axis
  8204. * @param z The amount to scale the bone on the z axis
  8205. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8206. */
  8207. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8208. /**
  8209. * Set the bone scaling in local space
  8210. * @param scale defines the scaling vector
  8211. */
  8212. setScale(scale: Vector3): void;
  8213. /**
  8214. * Gets the current scaling in local space
  8215. * @returns the current scaling vector
  8216. */
  8217. getScale(): Vector3;
  8218. /**
  8219. * Gets the current scaling in local space and stores it in a target vector
  8220. * @param result defines the target vector
  8221. */
  8222. getScaleToRef(result: Vector3): void;
  8223. /**
  8224. * Set the yaw, pitch, and roll of the bone in local or world space
  8225. * @param yaw The rotation of the bone on the y axis
  8226. * @param pitch The rotation of the bone on the x axis
  8227. * @param roll The rotation of the bone on the z axis
  8228. * @param space The space that the axes of rotation are in
  8229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8230. */
  8231. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8232. /**
  8233. * Add a rotation to the bone on an axis in local or world space
  8234. * @param axis The axis to rotate the bone on
  8235. * @param amount The amount to rotate the bone
  8236. * @param space The space that the axis is in
  8237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8238. */
  8239. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8240. /**
  8241. * Set the rotation of the bone to a particular axis angle in local or world space
  8242. * @param axis The axis to rotate the bone on
  8243. * @param angle The angle that the bone should be rotated to
  8244. * @param space The space that the axis is in
  8245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8246. */
  8247. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8248. /**
  8249. * Set the euler rotation of the bone in local of world space
  8250. * @param rotation The euler rotation that the bone should be set to
  8251. * @param space The space that the rotation is in
  8252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8253. */
  8254. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8255. /**
  8256. * Set the quaternion rotation of the bone in local of world space
  8257. * @param quat The quaternion rotation that the bone should be set to
  8258. * @param space The space that the rotation is in
  8259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8260. */
  8261. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8262. /**
  8263. * Set the rotation matrix of the bone in local of world space
  8264. * @param rotMat The rotation matrix that the bone should be set to
  8265. * @param space The space that the rotation is in
  8266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8267. */
  8268. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8269. private _rotateWithMatrix;
  8270. private _getNegativeRotationToRef;
  8271. /**
  8272. * Get the position of the bone in local or world space
  8273. * @param space The space that the returned position is in
  8274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8275. * @returns The position of the bone
  8276. */
  8277. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8278. /**
  8279. * Copy the position of the bone to a vector3 in local or world space
  8280. * @param space The space that the returned position is in
  8281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8282. * @param result The vector3 to copy the position to
  8283. */
  8284. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8285. /**
  8286. * Get the absolute position of the bone (world space)
  8287. * @param mesh The mesh that this bone is attached to
  8288. * @returns The absolute position of the bone
  8289. */
  8290. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8291. /**
  8292. * Copy the absolute position of the bone (world space) to the result param
  8293. * @param mesh The mesh that this bone is attached to
  8294. * @param result The vector3 to copy the absolute position to
  8295. */
  8296. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8297. /**
  8298. * Compute the absolute transforms of this bone and its children
  8299. */
  8300. computeAbsoluteTransforms(): void;
  8301. /**
  8302. * Get the world direction from an axis that is in the local space of the bone
  8303. * @param localAxis The local direction that is used to compute the world direction
  8304. * @param mesh The mesh that this bone is attached to
  8305. * @returns The world direction
  8306. */
  8307. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8308. /**
  8309. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8310. * @param localAxis The local direction that is used to compute the world direction
  8311. * @param mesh The mesh that this bone is attached to
  8312. * @param result The vector3 that the world direction will be copied to
  8313. */
  8314. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8315. /**
  8316. * Get the euler rotation of the bone in local or world space
  8317. * @param space The space that the rotation should be in
  8318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8319. * @returns The euler rotation
  8320. */
  8321. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8322. /**
  8323. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8324. * @param space The space that the rotation should be in
  8325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8326. * @param result The vector3 that the rotation should be copied to
  8327. */
  8328. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8329. /**
  8330. * Get the quaternion rotation of the bone in either local or world space
  8331. * @param space The space that the rotation should be in
  8332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8333. * @returns The quaternion rotation
  8334. */
  8335. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8336. /**
  8337. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8338. * @param space The space that the rotation should be in
  8339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8340. * @param result The quaternion that the rotation should be copied to
  8341. */
  8342. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8343. /**
  8344. * Get the rotation matrix of the bone in local or world space
  8345. * @param space The space that the rotation should be in
  8346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8347. * @returns The rotation matrix
  8348. */
  8349. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8350. /**
  8351. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8352. * @param space The space that the rotation should be in
  8353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8354. * @param result The quaternion that the rotation should be copied to
  8355. */
  8356. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8357. /**
  8358. * Get the world position of a point that is in the local space of the bone
  8359. * @param position The local position
  8360. * @param mesh The mesh that this bone is attached to
  8361. * @returns The world position
  8362. */
  8363. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8364. /**
  8365. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8366. * @param position The local position
  8367. * @param mesh The mesh that this bone is attached to
  8368. * @param result The vector3 that the world position should be copied to
  8369. */
  8370. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8371. /**
  8372. * Get the local position of a point that is in world space
  8373. * @param position The world position
  8374. * @param mesh The mesh that this bone is attached to
  8375. * @returns The local position
  8376. */
  8377. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8378. /**
  8379. * Get the local position of a point that is in world space and copy it to the result param
  8380. * @param position The world position
  8381. * @param mesh The mesh that this bone is attached to
  8382. * @param result The vector3 that the local position should be copied to
  8383. */
  8384. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8385. }
  8386. }
  8387. declare module "babylonjs/Misc/iInspectable" {
  8388. /**
  8389. * Enum that determines the text-wrapping mode to use.
  8390. */
  8391. export enum InspectableType {
  8392. /**
  8393. * Checkbox for booleans
  8394. */
  8395. Checkbox = 0,
  8396. /**
  8397. * Sliders for numbers
  8398. */
  8399. Slider = 1,
  8400. /**
  8401. * Vector3
  8402. */
  8403. Vector3 = 2,
  8404. /**
  8405. * Quaternions
  8406. */
  8407. Quaternion = 3,
  8408. /**
  8409. * Color3
  8410. */
  8411. Color3 = 4
  8412. }
  8413. /**
  8414. * Interface used to define custom inspectable properties.
  8415. * This interface is used by the inspector to display custom property grids
  8416. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8417. */
  8418. export interface IInspectable {
  8419. /**
  8420. * Gets the label to display
  8421. */
  8422. label: string;
  8423. /**
  8424. * Gets the name of the property to edit
  8425. */
  8426. propertyName: string;
  8427. /**
  8428. * Gets the type of the editor to use
  8429. */
  8430. type: InspectableType;
  8431. /**
  8432. * Gets the minimum value of the property when using in "slider" mode
  8433. */
  8434. min?: number;
  8435. /**
  8436. * Gets the maximum value of the property when using in "slider" mode
  8437. */
  8438. max?: number;
  8439. /**
  8440. * Gets the setp to use when using in "slider" mode
  8441. */
  8442. step?: number;
  8443. }
  8444. }
  8445. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8446. import { Nullable } from "babylonjs/types";
  8447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8448. /**
  8449. * This represents the required contract to create a new type of texture loader.
  8450. */
  8451. export interface IInternalTextureLoader {
  8452. /**
  8453. * Defines wether the loader supports cascade loading the different faces.
  8454. */
  8455. supportCascades: boolean;
  8456. /**
  8457. * This returns if the loader support the current file information.
  8458. * @param extension defines the file extension of the file being loaded
  8459. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8460. * @param fallback defines the fallback internal texture if any
  8461. * @param isBase64 defines whether the texture is encoded as a base64
  8462. * @param isBuffer defines whether the texture data are stored as a buffer
  8463. * @returns true if the loader can load the specified file
  8464. */
  8465. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8466. /**
  8467. * Transform the url before loading if required.
  8468. * @param rootUrl the url of the texture
  8469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8470. * @returns the transformed texture
  8471. */
  8472. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8473. /**
  8474. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8475. * @param rootUrl the url of the texture
  8476. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8477. * @returns the fallback texture
  8478. */
  8479. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8480. /**
  8481. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8482. * @param data contains the texture data
  8483. * @param texture defines the BabylonJS internal texture
  8484. * @param createPolynomials will be true if polynomials have been requested
  8485. * @param onLoad defines the callback to trigger once the texture is ready
  8486. * @param onError defines the callback to trigger in case of error
  8487. */
  8488. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8489. /**
  8490. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8491. * @param data contains the texture data
  8492. * @param texture defines the BabylonJS internal texture
  8493. * @param callback defines the method to call once ready to upload
  8494. */
  8495. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8496. }
  8497. }
  8498. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8499. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8500. import { Nullable } from "babylonjs/types";
  8501. import { Scene } from "babylonjs/scene";
  8502. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8503. module "babylonjs/Engines/engine" {
  8504. interface Engine {
  8505. /**
  8506. * Creates a depth stencil cube texture.
  8507. * This is only available in WebGL 2.
  8508. * @param size The size of face edge in the cube texture.
  8509. * @param options The options defining the cube texture.
  8510. * @returns The cube texture
  8511. */
  8512. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8513. /**
  8514. * Creates a cube texture
  8515. * @param rootUrl defines the url where the files to load is located
  8516. * @param scene defines the current scene
  8517. * @param files defines the list of files to load (1 per face)
  8518. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8519. * @param onLoad defines an optional callback raised when the texture is loaded
  8520. * @param onError defines an optional callback raised if there is an issue to load the texture
  8521. * @param format defines the format of the data
  8522. * @param forcedExtension defines the extension to use to pick the right loader
  8523. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8524. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8525. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8526. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8527. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8528. * @returns the cube texture as an InternalTexture
  8529. */
  8530. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8531. /**
  8532. * Creates a cube texture
  8533. * @param rootUrl defines the url where the files to load is located
  8534. * @param scene defines the current scene
  8535. * @param files defines the list of files to load (1 per face)
  8536. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8537. * @param onLoad defines an optional callback raised when the texture is loaded
  8538. * @param onError defines an optional callback raised if there is an issue to load the texture
  8539. * @param format defines the format of the data
  8540. * @param forcedExtension defines the extension to use to pick the right loader
  8541. * @returns the cube texture as an InternalTexture
  8542. */
  8543. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8544. /**
  8545. * Creates a cube texture
  8546. * @param rootUrl defines the url where the files to load is located
  8547. * @param scene defines the current scene
  8548. * @param files defines the list of files to load (1 per face)
  8549. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8550. * @param onLoad defines an optional callback raised when the texture is loaded
  8551. * @param onError defines an optional callback raised if there is an issue to load the texture
  8552. * @param format defines the format of the data
  8553. * @param forcedExtension defines the extension to use to pick the right loader
  8554. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8555. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8556. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8557. * @returns the cube texture as an InternalTexture
  8558. */
  8559. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8560. /** @hidden */
  8561. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8562. /** @hidden */
  8563. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8564. /** @hidden */
  8565. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8566. /** @hidden */
  8567. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8568. }
  8569. }
  8570. }
  8571. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8572. import { Nullable } from "babylonjs/types";
  8573. import { Scene } from "babylonjs/scene";
  8574. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8576. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8577. /**
  8578. * Class for creating a cube texture
  8579. */
  8580. export class CubeTexture extends BaseTexture {
  8581. private _delayedOnLoad;
  8582. /**
  8583. * The url of the texture
  8584. */
  8585. url: string;
  8586. /**
  8587. * Gets or sets the center of the bounding box associated with the cube texture.
  8588. * It must define where the camera used to render the texture was set
  8589. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8590. */
  8591. boundingBoxPosition: Vector3;
  8592. private _boundingBoxSize;
  8593. /**
  8594. * Gets or sets the size of the bounding box associated with the cube texture
  8595. * When defined, the cubemap will switch to local mode
  8596. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8597. * @example https://www.babylonjs-playground.com/#RNASML
  8598. */
  8599. /**
  8600. * Returns the bounding box size
  8601. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8602. */
  8603. boundingBoxSize: Vector3;
  8604. protected _rotationY: number;
  8605. /**
  8606. * Sets texture matrix rotation angle around Y axis in radians.
  8607. */
  8608. /**
  8609. * Gets texture matrix rotation angle around Y axis radians.
  8610. */
  8611. rotationY: number;
  8612. /**
  8613. * Are mip maps generated for this texture or not.
  8614. */
  8615. readonly noMipmap: boolean;
  8616. private _noMipmap;
  8617. private _files;
  8618. private _extensions;
  8619. private _textureMatrix;
  8620. private _format;
  8621. private _createPolynomials;
  8622. /** @hidden */
  8623. _prefiltered: boolean;
  8624. /**
  8625. * Creates a cube texture from an array of image urls
  8626. * @param files defines an array of image urls
  8627. * @param scene defines the hosting scene
  8628. * @param noMipmap specifies if mip maps are not used
  8629. * @returns a cube texture
  8630. */
  8631. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8632. /**
  8633. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8634. * @param url defines the url of the prefiltered texture
  8635. * @param scene defines the scene the texture is attached to
  8636. * @param forcedExtension defines the extension of the file if different from the url
  8637. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8638. * @return the prefiltered texture
  8639. */
  8640. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8641. /**
  8642. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8643. * as prefiltered data.
  8644. * @param rootUrl defines the url of the texture or the root name of the six images
  8645. * @param scene defines the scene the texture is attached to
  8646. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8647. * @param noMipmap defines if mipmaps should be created or not
  8648. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8649. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8650. * @param onError defines a callback triggered in case of error during load
  8651. * @param format defines the internal format to use for the texture once loaded
  8652. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8653. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8654. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8655. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8656. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8657. * @return the cube texture
  8658. */
  8659. 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);
  8660. /**
  8661. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8662. */
  8663. readonly isPrefiltered: boolean;
  8664. /**
  8665. * Get the current class name of the texture useful for serialization or dynamic coding.
  8666. * @returns "CubeTexture"
  8667. */
  8668. getClassName(): string;
  8669. /**
  8670. * Update the url (and optional buffer) of this texture if url was null during construction.
  8671. * @param url the url of the texture
  8672. * @param forcedExtension defines the extension to use
  8673. * @param onLoad callback called when the texture is loaded (defaults to null)
  8674. */
  8675. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8676. /**
  8677. * Delays loading of the cube texture
  8678. * @param forcedExtension defines the extension to use
  8679. */
  8680. delayLoad(forcedExtension?: string): void;
  8681. /**
  8682. * Returns the reflection texture matrix
  8683. * @returns the reflection texture matrix
  8684. */
  8685. getReflectionTextureMatrix(): Matrix;
  8686. /**
  8687. * Sets the reflection texture matrix
  8688. * @param value Reflection texture matrix
  8689. */
  8690. setReflectionTextureMatrix(value: Matrix): void;
  8691. /**
  8692. * Parses text to create a cube texture
  8693. * @param parsedTexture define the serialized text to read from
  8694. * @param scene defines the hosting scene
  8695. * @param rootUrl defines the root url of the cube texture
  8696. * @returns a cube texture
  8697. */
  8698. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8699. /**
  8700. * Makes a clone, or deep copy, of the cube texture
  8701. * @returns a new cube texture
  8702. */
  8703. clone(): CubeTexture;
  8704. }
  8705. }
  8706. declare module "babylonjs/Shaders/postprocess.vertex" {
  8707. /** @hidden */
  8708. export var postprocessVertexShader: {
  8709. name: string;
  8710. shader: string;
  8711. };
  8712. }
  8713. declare module "babylonjs/Cameras/targetCamera" {
  8714. import { Nullable } from "babylonjs/types";
  8715. import { Camera } from "babylonjs/Cameras/camera";
  8716. import { Scene } from "babylonjs/scene";
  8717. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8718. /**
  8719. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8720. * This is the base of the follow, arc rotate cameras and Free camera
  8721. * @see http://doc.babylonjs.com/features/cameras
  8722. */
  8723. export class TargetCamera extends Camera {
  8724. private static _RigCamTransformMatrix;
  8725. private static _TargetTransformMatrix;
  8726. private static _TargetFocalPoint;
  8727. /**
  8728. * Define the current direction the camera is moving to
  8729. */
  8730. cameraDirection: Vector3;
  8731. /**
  8732. * Define the current rotation the camera is rotating to
  8733. */
  8734. cameraRotation: Vector2;
  8735. /**
  8736. * When set, the up vector of the camera will be updated by the rotation of the camera
  8737. */
  8738. updateUpVectorFromRotation: boolean;
  8739. private _tmpQuaternion;
  8740. /**
  8741. * Define the current rotation of the camera
  8742. */
  8743. rotation: Vector3;
  8744. /**
  8745. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8746. */
  8747. rotationQuaternion: Quaternion;
  8748. /**
  8749. * Define the current speed of the camera
  8750. */
  8751. speed: number;
  8752. /**
  8753. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8754. * around all axis.
  8755. */
  8756. noRotationConstraint: boolean;
  8757. /**
  8758. * Define the current target of the camera as an object or a position.
  8759. */
  8760. lockedTarget: any;
  8761. /** @hidden */
  8762. _currentTarget: Vector3;
  8763. /** @hidden */
  8764. _initialFocalDistance: number;
  8765. /** @hidden */
  8766. _viewMatrix: Matrix;
  8767. /** @hidden */
  8768. _camMatrix: Matrix;
  8769. /** @hidden */
  8770. _cameraTransformMatrix: Matrix;
  8771. /** @hidden */
  8772. _cameraRotationMatrix: Matrix;
  8773. /** @hidden */
  8774. _referencePoint: Vector3;
  8775. /** @hidden */
  8776. _transformedReferencePoint: Vector3;
  8777. protected _globalCurrentTarget: Vector3;
  8778. protected _globalCurrentUpVector: Vector3;
  8779. /** @hidden */
  8780. _reset: () => void;
  8781. private _defaultUp;
  8782. /**
  8783. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8784. * This is the base of the follow, arc rotate cameras and Free camera
  8785. * @see http://doc.babylonjs.com/features/cameras
  8786. * @param name Defines the name of the camera in the scene
  8787. * @param position Defines the start position of the camera in the scene
  8788. * @param scene Defines the scene the camera belongs to
  8789. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8790. */
  8791. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8792. /**
  8793. * Gets the position in front of the camera at a given distance.
  8794. * @param distance The distance from the camera we want the position to be
  8795. * @returns the position
  8796. */
  8797. getFrontPosition(distance: number): Vector3;
  8798. /** @hidden */
  8799. _getLockedTargetPosition(): Nullable<Vector3>;
  8800. private _storedPosition;
  8801. private _storedRotation;
  8802. private _storedRotationQuaternion;
  8803. /**
  8804. * Store current camera state of the camera (fov, position, rotation, etc..)
  8805. * @returns the camera
  8806. */
  8807. storeState(): Camera;
  8808. /**
  8809. * Restored camera state. You must call storeState() first
  8810. * @returns whether it was successful or not
  8811. * @hidden
  8812. */
  8813. _restoreStateValues(): boolean;
  8814. /** @hidden */
  8815. _initCache(): void;
  8816. /** @hidden */
  8817. _updateCache(ignoreParentClass?: boolean): void;
  8818. /** @hidden */
  8819. _isSynchronizedViewMatrix(): boolean;
  8820. /** @hidden */
  8821. _computeLocalCameraSpeed(): number;
  8822. /**
  8823. * Defines the target the camera should look at.
  8824. * This will automatically adapt alpha beta and radius to fit within the new target.
  8825. * @param target Defines the new target as a Vector or a mesh
  8826. */
  8827. setTarget(target: Vector3): void;
  8828. /**
  8829. * Return the current target position of the camera. This value is expressed in local space.
  8830. * @returns the target position
  8831. */
  8832. getTarget(): Vector3;
  8833. /** @hidden */
  8834. _decideIfNeedsToMove(): boolean;
  8835. /** @hidden */
  8836. _updatePosition(): void;
  8837. /** @hidden */
  8838. _checkInputs(): void;
  8839. protected _updateCameraRotationMatrix(): void;
  8840. /**
  8841. * 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)
  8842. * @returns the current camera
  8843. */
  8844. private _rotateUpVectorWithCameraRotationMatrix;
  8845. private _cachedRotationZ;
  8846. private _cachedQuaternionRotationZ;
  8847. /** @hidden */
  8848. _getViewMatrix(): Matrix;
  8849. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8850. /**
  8851. * @hidden
  8852. */
  8853. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8854. /**
  8855. * @hidden
  8856. */
  8857. _updateRigCameras(): void;
  8858. private _getRigCamPositionAndTarget;
  8859. /**
  8860. * Gets the current object class name.
  8861. * @return the class name
  8862. */
  8863. getClassName(): string;
  8864. }
  8865. }
  8866. declare module "babylonjs/Cameras/cameraInputsManager" {
  8867. import { Nullable } from "babylonjs/types";
  8868. import { Camera } from "babylonjs/Cameras/camera";
  8869. /**
  8870. * @ignore
  8871. * This is a list of all the different input types that are available in the application.
  8872. * Fo instance: ArcRotateCameraGamepadInput...
  8873. */
  8874. export var CameraInputTypes: {};
  8875. /**
  8876. * This is the contract to implement in order to create a new input class.
  8877. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8878. */
  8879. export interface ICameraInput<TCamera extends Camera> {
  8880. /**
  8881. * Defines the camera the input is attached to.
  8882. */
  8883. camera: Nullable<TCamera>;
  8884. /**
  8885. * Gets the class name of the current intput.
  8886. * @returns the class name
  8887. */
  8888. getClassName(): string;
  8889. /**
  8890. * Get the friendly name associated with the input class.
  8891. * @returns the input friendly name
  8892. */
  8893. getSimpleName(): string;
  8894. /**
  8895. * Attach the input controls to a specific dom element to get the input from.
  8896. * @param element Defines the element the controls should be listened from
  8897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8898. */
  8899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8900. /**
  8901. * Detach the current controls from the specified dom element.
  8902. * @param element Defines the element to stop listening the inputs from
  8903. */
  8904. detachControl(element: Nullable<HTMLElement>): void;
  8905. /**
  8906. * Update the current camera state depending on the inputs that have been used this frame.
  8907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8908. */
  8909. checkInputs?: () => void;
  8910. }
  8911. /**
  8912. * Represents a map of input types to input instance or input index to input instance.
  8913. */
  8914. export interface CameraInputsMap<TCamera extends Camera> {
  8915. /**
  8916. * Accessor to the input by input type.
  8917. */
  8918. [name: string]: ICameraInput<TCamera>;
  8919. /**
  8920. * Accessor to the input by input index.
  8921. */
  8922. [idx: number]: ICameraInput<TCamera>;
  8923. }
  8924. /**
  8925. * This represents the input manager used within a camera.
  8926. * It helps dealing with all the different kind of input attached to a camera.
  8927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8928. */
  8929. export class CameraInputsManager<TCamera extends Camera> {
  8930. /**
  8931. * Defines the list of inputs attahed to the camera.
  8932. */
  8933. attached: CameraInputsMap<TCamera>;
  8934. /**
  8935. * Defines the dom element the camera is collecting inputs from.
  8936. * This is null if the controls have not been attached.
  8937. */
  8938. attachedElement: Nullable<HTMLElement>;
  8939. /**
  8940. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8941. */
  8942. noPreventDefault: boolean;
  8943. /**
  8944. * Defined the camera the input manager belongs to.
  8945. */
  8946. camera: TCamera;
  8947. /**
  8948. * Update the current camera state depending on the inputs that have been used this frame.
  8949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8950. */
  8951. checkInputs: () => void;
  8952. /**
  8953. * Instantiate a new Camera Input Manager.
  8954. * @param camera Defines the camera the input manager blongs to
  8955. */
  8956. constructor(camera: TCamera);
  8957. /**
  8958. * Add an input method to a camera
  8959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8960. * @param input camera input method
  8961. */
  8962. add(input: ICameraInput<TCamera>): void;
  8963. /**
  8964. * Remove a specific input method from a camera
  8965. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8966. * @param inputToRemove camera input method
  8967. */
  8968. remove(inputToRemove: ICameraInput<TCamera>): void;
  8969. /**
  8970. * Remove a specific input type from a camera
  8971. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8972. * @param inputType the type of the input to remove
  8973. */
  8974. removeByType(inputType: string): void;
  8975. private _addCheckInputs;
  8976. /**
  8977. * Attach the input controls to the currently attached dom element to listen the events from.
  8978. * @param input Defines the input to attach
  8979. */
  8980. attachInput(input: ICameraInput<TCamera>): void;
  8981. /**
  8982. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8983. * @param element Defines the dom element to collect the events from
  8984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8985. */
  8986. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8987. /**
  8988. * Detach the current manager inputs controls from a specific dom element.
  8989. * @param element Defines the dom element to collect the events from
  8990. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8991. */
  8992. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8993. /**
  8994. * Rebuild the dynamic inputCheck function from the current list of
  8995. * defined inputs in the manager.
  8996. */
  8997. rebuildInputCheck(): void;
  8998. /**
  8999. * Remove all attached input methods from a camera
  9000. */
  9001. clear(): void;
  9002. /**
  9003. * Serialize the current input manager attached to a camera.
  9004. * This ensures than once parsed,
  9005. * the input associated to the camera will be identical to the current ones
  9006. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9007. */
  9008. serialize(serializedCamera: any): void;
  9009. /**
  9010. * Parses an input manager serialized JSON to restore the previous list of inputs
  9011. * and states associated to a camera.
  9012. * @param parsedCamera Defines the JSON to parse
  9013. */
  9014. parse(parsedCamera: any): void;
  9015. }
  9016. }
  9017. declare module "babylonjs/Events/keyboardEvents" {
  9018. /**
  9019. * Gather the list of keyboard event types as constants.
  9020. */
  9021. export class KeyboardEventTypes {
  9022. /**
  9023. * The keydown event is fired when a key becomes active (pressed).
  9024. */
  9025. static readonly KEYDOWN: number;
  9026. /**
  9027. * The keyup event is fired when a key has been released.
  9028. */
  9029. static readonly KEYUP: number;
  9030. }
  9031. /**
  9032. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9033. */
  9034. export class KeyboardInfo {
  9035. /**
  9036. * Defines the type of event (KeyboardEventTypes)
  9037. */
  9038. type: number;
  9039. /**
  9040. * Defines the related dom event
  9041. */
  9042. event: KeyboardEvent;
  9043. /**
  9044. * Instantiates a new keyboard info.
  9045. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9046. * @param type Defines the type of event (KeyboardEventTypes)
  9047. * @param event Defines the related dom event
  9048. */
  9049. constructor(
  9050. /**
  9051. * Defines the type of event (KeyboardEventTypes)
  9052. */
  9053. type: number,
  9054. /**
  9055. * Defines the related dom event
  9056. */
  9057. event: KeyboardEvent);
  9058. }
  9059. /**
  9060. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9061. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9062. */
  9063. export class KeyboardInfoPre extends KeyboardInfo {
  9064. /**
  9065. * Defines the type of event (KeyboardEventTypes)
  9066. */
  9067. type: number;
  9068. /**
  9069. * Defines the related dom event
  9070. */
  9071. event: KeyboardEvent;
  9072. /**
  9073. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9074. */
  9075. skipOnPointerObservable: boolean;
  9076. /**
  9077. * Instantiates a new keyboard pre info.
  9078. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9079. * @param type Defines the type of event (KeyboardEventTypes)
  9080. * @param event Defines the related dom event
  9081. */
  9082. constructor(
  9083. /**
  9084. * Defines the type of event (KeyboardEventTypes)
  9085. */
  9086. type: number,
  9087. /**
  9088. * Defines the related dom event
  9089. */
  9090. event: KeyboardEvent);
  9091. }
  9092. }
  9093. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9096. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9097. /**
  9098. * Manage the keyboard inputs to control the movement of a free camera.
  9099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9100. */
  9101. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9102. /**
  9103. * Defines the camera the input is attached to.
  9104. */
  9105. camera: FreeCamera;
  9106. /**
  9107. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9108. */
  9109. keysUp: number[];
  9110. /**
  9111. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9112. */
  9113. keysDown: number[];
  9114. /**
  9115. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9116. */
  9117. keysLeft: number[];
  9118. /**
  9119. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9120. */
  9121. keysRight: number[];
  9122. private _keys;
  9123. private _onCanvasBlurObserver;
  9124. private _onKeyboardObserver;
  9125. private _engine;
  9126. private _scene;
  9127. /**
  9128. * Attach the input controls to a specific dom element to get the input from.
  9129. * @param element Defines the element the controls should be listened from
  9130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9131. */
  9132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9133. /**
  9134. * Detach the current controls from the specified dom element.
  9135. * @param element Defines the element to stop listening the inputs from
  9136. */
  9137. detachControl(element: Nullable<HTMLElement>): void;
  9138. /**
  9139. * Update the current camera state depending on the inputs that have been used this frame.
  9140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9141. */
  9142. checkInputs(): void;
  9143. /**
  9144. * Gets the class name of the current intput.
  9145. * @returns the class name
  9146. */
  9147. getClassName(): string;
  9148. /** @hidden */
  9149. _onLostFocus(): void;
  9150. /**
  9151. * Get the friendly name associated with the input class.
  9152. * @returns the input friendly name
  9153. */
  9154. getSimpleName(): string;
  9155. }
  9156. }
  9157. declare module "babylonjs/Lights/shadowLight" {
  9158. import { Camera } from "babylonjs/Cameras/camera";
  9159. import { Scene } from "babylonjs/scene";
  9160. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9162. import { Light } from "babylonjs/Lights/light";
  9163. /**
  9164. * Interface describing all the common properties and methods a shadow light needs to implement.
  9165. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9166. * as well as binding the different shadow properties to the effects.
  9167. */
  9168. export interface IShadowLight extends Light {
  9169. /**
  9170. * The light id in the scene (used in scene.findLighById for instance)
  9171. */
  9172. id: string;
  9173. /**
  9174. * The position the shdow will be casted from.
  9175. */
  9176. position: Vector3;
  9177. /**
  9178. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9179. */
  9180. direction: Vector3;
  9181. /**
  9182. * The transformed position. Position of the light in world space taking parenting in account.
  9183. */
  9184. transformedPosition: Vector3;
  9185. /**
  9186. * The transformed direction. Direction of the light in world space taking parenting in account.
  9187. */
  9188. transformedDirection: Vector3;
  9189. /**
  9190. * The friendly name of the light in the scene.
  9191. */
  9192. name: string;
  9193. /**
  9194. * Defines the shadow projection clipping minimum z value.
  9195. */
  9196. shadowMinZ: number;
  9197. /**
  9198. * Defines the shadow projection clipping maximum z value.
  9199. */
  9200. shadowMaxZ: number;
  9201. /**
  9202. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9203. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9204. */
  9205. computeTransformedInformation(): boolean;
  9206. /**
  9207. * Gets the scene the light belongs to.
  9208. * @returns The scene
  9209. */
  9210. getScene(): Scene;
  9211. /**
  9212. * Callback defining a custom Projection Matrix Builder.
  9213. * This can be used to override the default projection matrix computation.
  9214. */
  9215. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9216. /**
  9217. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9218. * @param matrix The materix to updated with the projection information
  9219. * @param viewMatrix The transform matrix of the light
  9220. * @param renderList The list of mesh to render in the map
  9221. * @returns The current light
  9222. */
  9223. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9224. /**
  9225. * Gets the current depth scale used in ESM.
  9226. * @returns The scale
  9227. */
  9228. getDepthScale(): number;
  9229. /**
  9230. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9231. * @returns true if a cube texture needs to be use
  9232. */
  9233. needCube(): boolean;
  9234. /**
  9235. * Detects if the projection matrix requires to be recomputed this frame.
  9236. * @returns true if it requires to be recomputed otherwise, false.
  9237. */
  9238. needProjectionMatrixCompute(): boolean;
  9239. /**
  9240. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9241. */
  9242. forceProjectionMatrixCompute(): void;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Gets the minZ used for shadow according to both the scene and the light.
  9251. * @param activeCamera The camera we are returning the min for
  9252. * @returns the depth min z
  9253. */
  9254. getDepthMinZ(activeCamera: Camera): number;
  9255. /**
  9256. * Gets the maxZ used for shadow according to both the scene and the light.
  9257. * @param activeCamera The camera we are returning the max for
  9258. * @returns the depth max z
  9259. */
  9260. getDepthMaxZ(activeCamera: Camera): number;
  9261. }
  9262. /**
  9263. * Base implementation IShadowLight
  9264. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9265. */
  9266. export abstract class ShadowLight extends Light implements IShadowLight {
  9267. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9268. protected _position: Vector3;
  9269. protected _setPosition(value: Vector3): void;
  9270. /**
  9271. * Sets the position the shadow will be casted from. Also use as the light position for both
  9272. * point and spot lights.
  9273. */
  9274. /**
  9275. * Sets the position the shadow will be casted from. Also use as the light position for both
  9276. * point and spot lights.
  9277. */
  9278. position: Vector3;
  9279. protected _direction: Vector3;
  9280. protected _setDirection(value: Vector3): void;
  9281. /**
  9282. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9283. * Also use as the light direction on spot and directional lights.
  9284. */
  9285. /**
  9286. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9287. * Also use as the light direction on spot and directional lights.
  9288. */
  9289. direction: Vector3;
  9290. private _shadowMinZ;
  9291. /**
  9292. * Gets the shadow projection clipping minimum z value.
  9293. */
  9294. /**
  9295. * Sets the shadow projection clipping minimum z value.
  9296. */
  9297. shadowMinZ: number;
  9298. private _shadowMaxZ;
  9299. /**
  9300. * Sets the shadow projection clipping maximum z value.
  9301. */
  9302. /**
  9303. * Gets the shadow projection clipping maximum z value.
  9304. */
  9305. shadowMaxZ: number;
  9306. /**
  9307. * Callback defining a custom Projection Matrix Builder.
  9308. * This can be used to override the default projection matrix computation.
  9309. */
  9310. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9311. /**
  9312. * The transformed position. Position of the light in world space taking parenting in account.
  9313. */
  9314. transformedPosition: Vector3;
  9315. /**
  9316. * The transformed direction. Direction of the light in world space taking parenting in account.
  9317. */
  9318. transformedDirection: Vector3;
  9319. private _needProjectionMatrixCompute;
  9320. /**
  9321. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9322. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9323. */
  9324. computeTransformedInformation(): boolean;
  9325. /**
  9326. * Return the depth scale used for the shadow map.
  9327. * @returns the depth scale.
  9328. */
  9329. getDepthScale(): number;
  9330. /**
  9331. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9332. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9333. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9334. */
  9335. getShadowDirection(faceIndex?: number): Vector3;
  9336. /**
  9337. * Returns the ShadowLight absolute position in the World.
  9338. * @returns the position vector in world space
  9339. */
  9340. getAbsolutePosition(): Vector3;
  9341. /**
  9342. * Sets the ShadowLight direction toward the passed target.
  9343. * @param target The point to target in local space
  9344. * @returns the updated ShadowLight direction
  9345. */
  9346. setDirectionToTarget(target: Vector3): Vector3;
  9347. /**
  9348. * Returns the light rotation in euler definition.
  9349. * @returns the x y z rotation in local space.
  9350. */
  9351. getRotation(): Vector3;
  9352. /**
  9353. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9354. * @returns true if a cube texture needs to be use
  9355. */
  9356. needCube(): boolean;
  9357. /**
  9358. * Detects if the projection matrix requires to be recomputed this frame.
  9359. * @returns true if it requires to be recomputed otherwise, false.
  9360. */
  9361. needProjectionMatrixCompute(): boolean;
  9362. /**
  9363. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9364. */
  9365. forceProjectionMatrixCompute(): void;
  9366. /** @hidden */
  9367. _initCache(): void;
  9368. /** @hidden */
  9369. _isSynchronized(): boolean;
  9370. /**
  9371. * Computes the world matrix of the node
  9372. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9373. * @returns the world matrix
  9374. */
  9375. computeWorldMatrix(force?: boolean): Matrix;
  9376. /**
  9377. * Gets the minZ used for shadow according to both the scene and the light.
  9378. * @param activeCamera The camera we are returning the min for
  9379. * @returns the depth min z
  9380. */
  9381. getDepthMinZ(activeCamera: Camera): number;
  9382. /**
  9383. * Gets the maxZ used for shadow according to both the scene and the light.
  9384. * @param activeCamera The camera we are returning the max for
  9385. * @returns the depth max z
  9386. */
  9387. getDepthMaxZ(activeCamera: Camera): number;
  9388. /**
  9389. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9390. * @param matrix The materix to updated with the projection information
  9391. * @param viewMatrix The transform matrix of the light
  9392. * @param renderList The list of mesh to render in the map
  9393. * @returns The current light
  9394. */
  9395. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9396. }
  9397. }
  9398. declare module "babylonjs/Materials/materialHelper" {
  9399. import { Nullable } from "babylonjs/types";
  9400. import { Scene } from "babylonjs/scene";
  9401. import { Engine } from "babylonjs/Engines/engine";
  9402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9403. import { Light } from "babylonjs/Lights/light";
  9404. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9405. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9407. /**
  9408. * "Static Class" containing the most commonly used helper while dealing with material for
  9409. * rendering purpose.
  9410. *
  9411. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9412. *
  9413. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9414. */
  9415. export class MaterialHelper {
  9416. /**
  9417. * Bind the current view position to an effect.
  9418. * @param effect The effect to be bound
  9419. * @param scene The scene the eyes position is used from
  9420. */
  9421. static BindEyePosition(effect: Effect, scene: Scene): void;
  9422. /**
  9423. * Helps preparing the defines values about the UVs in used in the effect.
  9424. * UVs are shared as much as we can accross channels in the shaders.
  9425. * @param texture The texture we are preparing the UVs for
  9426. * @param defines The defines to update
  9427. * @param key The channel key "diffuse", "specular"... used in the shader
  9428. */
  9429. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9430. /**
  9431. * Binds a texture matrix value to its corrsponding uniform
  9432. * @param texture The texture to bind the matrix for
  9433. * @param uniformBuffer The uniform buffer receivin the data
  9434. * @param key The channel key "diffuse", "specular"... used in the shader
  9435. */
  9436. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9437. /**
  9438. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9439. * @param mesh defines the current mesh
  9440. * @param scene defines the current scene
  9441. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9442. * @param pointsCloud defines if point cloud rendering has to be turned on
  9443. * @param fogEnabled defines if fog has to be turned on
  9444. * @param alphaTest defines if alpha testing has to be turned on
  9445. * @param defines defines the current list of defines
  9446. */
  9447. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9448. /**
  9449. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9450. * @param scene defines the current scene
  9451. * @param engine defines the current engine
  9452. * @param defines specifies the list of active defines
  9453. * @param useInstances defines if instances have to be turned on
  9454. * @param useClipPlane defines if clip plane have to be turned on
  9455. */
  9456. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9457. /**
  9458. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9459. * @param mesh The mesh containing the geometry data we will draw
  9460. * @param defines The defines to update
  9461. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9462. * @param useBones Precise whether bones should be used or not (override mesh info)
  9463. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9464. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9465. * @returns false if defines are considered not dirty and have not been checked
  9466. */
  9467. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9468. /**
  9469. * Prepares the defines related to multiview
  9470. * @param scene The scene we are intending to draw
  9471. * @param defines The defines to update
  9472. */
  9473. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9474. /**
  9475. * Prepares the defines related to the light information passed in parameter
  9476. * @param scene The scene we are intending to draw
  9477. * @param mesh The mesh the effect is compiling for
  9478. * @param defines The defines to update
  9479. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9480. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9481. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9482. * @returns true if normals will be required for the rest of the effect
  9483. */
  9484. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9485. /**
  9486. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9487. * that won t be acctive due to defines being turned off.
  9488. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9489. * @param samplersList The samplers list
  9490. * @param defines The defines helping in the list generation
  9491. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9492. */
  9493. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9494. /**
  9495. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9496. * @param defines The defines to update while falling back
  9497. * @param fallbacks The authorized effect fallbacks
  9498. * @param maxSimultaneousLights The maximum number of lights allowed
  9499. * @param rank the current rank of the Effect
  9500. * @returns The newly affected rank
  9501. */
  9502. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9503. /**
  9504. * Prepares the list of attributes required for morph targets according to the effect defines.
  9505. * @param attribs The current list of supported attribs
  9506. * @param mesh The mesh to prepare the morph targets attributes for
  9507. * @param defines The current Defines of the effect
  9508. */
  9509. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9510. /**
  9511. * Prepares the list of attributes required for bones according to the effect defines.
  9512. * @param attribs The current list of supported attribs
  9513. * @param mesh The mesh to prepare the bones attributes for
  9514. * @param defines The current Defines of the effect
  9515. * @param fallbacks The current efffect fallback strategy
  9516. */
  9517. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9518. /**
  9519. * Prepares the list of attributes required for instances according to the effect defines.
  9520. * @param attribs The current list of supported attribs
  9521. * @param defines The current Defines of the effect
  9522. */
  9523. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9524. /**
  9525. * Binds the light shadow information to the effect for the given mesh.
  9526. * @param light The light containing the generator
  9527. * @param scene The scene the lights belongs to
  9528. * @param mesh The mesh we are binding the information to render
  9529. * @param lightIndex The light index in the effect used to render the mesh
  9530. * @param effect The effect we are binding the data to
  9531. */
  9532. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9533. /**
  9534. * Binds the light information to the effect.
  9535. * @param light The light containing the generator
  9536. * @param effect The effect we are binding the data to
  9537. * @param lightIndex The light index in the effect used to render
  9538. */
  9539. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9540. /**
  9541. * Binds the lights information from the scene to the effect for the given mesh.
  9542. * @param scene The scene the lights belongs to
  9543. * @param mesh The mesh we are binding the information to render
  9544. * @param effect The effect we are binding the data to
  9545. * @param defines The generated defines for the effect
  9546. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9547. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9548. */
  9549. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9550. private static _tempFogColor;
  9551. /**
  9552. * Binds the fog information from the scene to the effect for the given mesh.
  9553. * @param scene The scene the lights belongs to
  9554. * @param mesh The mesh we are binding the information to render
  9555. * @param effect The effect we are binding the data to
  9556. * @param linearSpace Defines if the fog effect is applied in linear space
  9557. */
  9558. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9559. /**
  9560. * Binds the bones information from the mesh to the effect.
  9561. * @param mesh The mesh we are binding the information to render
  9562. * @param effect The effect we are binding the data to
  9563. */
  9564. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9565. /**
  9566. * Binds the morph targets information from the mesh to the effect.
  9567. * @param abstractMesh The mesh we are binding the information to render
  9568. * @param effect The effect we are binding the data to
  9569. */
  9570. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9571. /**
  9572. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9573. * @param defines The generated defines used in the effect
  9574. * @param effect The effect we are binding the data to
  9575. * @param scene The scene we are willing to render with logarithmic scale for
  9576. */
  9577. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9578. /**
  9579. * Binds the clip plane information from the scene to the effect.
  9580. * @param scene The scene the clip plane information are extracted from
  9581. * @param effect The effect we are binding the data to
  9582. */
  9583. static BindClipPlane(effect: Effect, scene: Scene): void;
  9584. }
  9585. }
  9586. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9587. /** @hidden */
  9588. export var kernelBlurVaryingDeclaration: {
  9589. name: string;
  9590. shader: string;
  9591. };
  9592. }
  9593. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9594. /** @hidden */
  9595. export var kernelBlurFragment: {
  9596. name: string;
  9597. shader: string;
  9598. };
  9599. }
  9600. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9601. /** @hidden */
  9602. export var kernelBlurFragment2: {
  9603. name: string;
  9604. shader: string;
  9605. };
  9606. }
  9607. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9608. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9609. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9610. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9611. /** @hidden */
  9612. export var kernelBlurPixelShader: {
  9613. name: string;
  9614. shader: string;
  9615. };
  9616. }
  9617. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9618. /** @hidden */
  9619. export var kernelBlurVertex: {
  9620. name: string;
  9621. shader: string;
  9622. };
  9623. }
  9624. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9625. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9626. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9627. /** @hidden */
  9628. export var kernelBlurVertexShader: {
  9629. name: string;
  9630. shader: string;
  9631. };
  9632. }
  9633. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9634. import { Vector2 } from "babylonjs/Maths/math";
  9635. import { Nullable } from "babylonjs/types";
  9636. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9637. import { Camera } from "babylonjs/Cameras/camera";
  9638. import { Effect } from "babylonjs/Materials/effect";
  9639. import { Engine } from "babylonjs/Engines/engine";
  9640. import "babylonjs/Shaders/kernelBlur.fragment";
  9641. import "babylonjs/Shaders/kernelBlur.vertex";
  9642. /**
  9643. * The Blur Post Process which blurs an image based on a kernel and direction.
  9644. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9645. */
  9646. export class BlurPostProcess extends PostProcess {
  9647. /** The direction in which to blur the image. */
  9648. direction: Vector2;
  9649. private blockCompilation;
  9650. protected _kernel: number;
  9651. protected _idealKernel: number;
  9652. protected _packedFloat: boolean;
  9653. private _staticDefines;
  9654. /**
  9655. * Sets the length in pixels of the blur sample region
  9656. */
  9657. /**
  9658. * Gets the length in pixels of the blur sample region
  9659. */
  9660. kernel: number;
  9661. /**
  9662. * Sets wether or not the blur needs to unpack/repack floats
  9663. */
  9664. /**
  9665. * Gets wether or not the blur is unpacking/repacking floats
  9666. */
  9667. packedFloat: boolean;
  9668. /**
  9669. * Creates a new instance BlurPostProcess
  9670. * @param name The name of the effect.
  9671. * @param direction The direction in which to blur the image.
  9672. * @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.
  9673. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9674. * @param camera The camera to apply the render pass to.
  9675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9676. * @param engine The engine which the post process will be applied. (default: current engine)
  9677. * @param reusable If the post process can be reused on the same frame. (default: false)
  9678. * @param textureType Type of textures used when performing the post process. (default: 0)
  9679. * @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)
  9680. */
  9681. constructor(name: string,
  9682. /** The direction in which to blur the image. */
  9683. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9684. /**
  9685. * Updates the effect with the current post process compile time values and recompiles the shader.
  9686. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9687. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9688. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9689. * @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
  9690. * @param onCompiled Called when the shader has been compiled.
  9691. * @param onError Called if there is an error when compiling a shader.
  9692. */
  9693. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9694. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9695. /**
  9696. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9697. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9698. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9699. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9700. * The gaps between physical kernels are compensated for in the weighting of the samples
  9701. * @param idealKernel Ideal blur kernel.
  9702. * @return Nearest best kernel.
  9703. */
  9704. protected _nearestBestKernel(idealKernel: number): number;
  9705. /**
  9706. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9707. * @param x The point on the Gaussian distribution to sample.
  9708. * @return the value of the Gaussian function at x.
  9709. */
  9710. protected _gaussianWeight(x: number): number;
  9711. /**
  9712. * Generates a string that can be used as a floating point number in GLSL.
  9713. * @param x Value to print.
  9714. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9715. * @return GLSL float string.
  9716. */
  9717. protected _glslFloat(x: number, decimalFigures?: number): string;
  9718. }
  9719. }
  9720. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9721. /** @hidden */
  9722. export var shadowMapPixelShader: {
  9723. name: string;
  9724. shader: string;
  9725. };
  9726. }
  9727. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9728. /** @hidden */
  9729. export var bonesDeclaration: {
  9730. name: string;
  9731. shader: string;
  9732. };
  9733. }
  9734. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9735. /** @hidden */
  9736. export var morphTargetsVertexGlobalDeclaration: {
  9737. name: string;
  9738. shader: string;
  9739. };
  9740. }
  9741. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9742. /** @hidden */
  9743. export var morphTargetsVertexDeclaration: {
  9744. name: string;
  9745. shader: string;
  9746. };
  9747. }
  9748. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9749. /** @hidden */
  9750. export var instancesDeclaration: {
  9751. name: string;
  9752. shader: string;
  9753. };
  9754. }
  9755. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9756. /** @hidden */
  9757. export var helperFunctions: {
  9758. name: string;
  9759. shader: string;
  9760. };
  9761. }
  9762. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9763. /** @hidden */
  9764. export var morphTargetsVertex: {
  9765. name: string;
  9766. shader: string;
  9767. };
  9768. }
  9769. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9770. /** @hidden */
  9771. export var instancesVertex: {
  9772. name: string;
  9773. shader: string;
  9774. };
  9775. }
  9776. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9777. /** @hidden */
  9778. export var bonesVertex: {
  9779. name: string;
  9780. shader: string;
  9781. };
  9782. }
  9783. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9784. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9785. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9786. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9787. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9788. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9789. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9790. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9791. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9792. /** @hidden */
  9793. export var shadowMapVertexShader: {
  9794. name: string;
  9795. shader: string;
  9796. };
  9797. }
  9798. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9799. /** @hidden */
  9800. export var depthBoxBlurPixelShader: {
  9801. name: string;
  9802. shader: string;
  9803. };
  9804. }
  9805. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9806. import { Nullable } from "babylonjs/types";
  9807. import { Scene } from "babylonjs/scene";
  9808. import { Matrix } from "babylonjs/Maths/math";
  9809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9811. import { Mesh } from "babylonjs/Meshes/mesh";
  9812. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9813. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9814. import { Effect } from "babylonjs/Materials/effect";
  9815. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9816. import "babylonjs/Shaders/shadowMap.fragment";
  9817. import "babylonjs/Shaders/shadowMap.vertex";
  9818. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9819. import { Observable } from "babylonjs/Misc/observable";
  9820. /**
  9821. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9822. */
  9823. export interface ICustomShaderOptions {
  9824. /**
  9825. * Gets or sets the custom shader name to use
  9826. */
  9827. shaderName: string;
  9828. /**
  9829. * The list of attribute names used in the shader
  9830. */
  9831. attributes?: string[];
  9832. /**
  9833. * The list of unifrom names used in the shader
  9834. */
  9835. uniforms?: string[];
  9836. /**
  9837. * The list of sampler names used in the shader
  9838. */
  9839. samplers?: string[];
  9840. /**
  9841. * The list of defines used in the shader
  9842. */
  9843. defines?: string[];
  9844. }
  9845. /**
  9846. * Interface to implement to create a shadow generator compatible with BJS.
  9847. */
  9848. export interface IShadowGenerator {
  9849. /**
  9850. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9851. * @returns The render target texture if present otherwise, null
  9852. */
  9853. getShadowMap(): Nullable<RenderTargetTexture>;
  9854. /**
  9855. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9856. * @returns The render target texture if the shadow map is present otherwise, null
  9857. */
  9858. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9859. /**
  9860. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9861. * @param subMesh The submesh we want to render in the shadow map
  9862. * @param useInstances Defines wether will draw in the map using instances
  9863. * @returns true if ready otherwise, false
  9864. */
  9865. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9866. /**
  9867. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9868. * @param defines Defines of the material we want to update
  9869. * @param lightIndex Index of the light in the enabled light list of the material
  9870. */
  9871. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9872. /**
  9873. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9874. * defined in the generator but impacting the effect).
  9875. * It implies the unifroms available on the materials are the standard BJS ones.
  9876. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9877. * @param effect The effect we are binfing the information for
  9878. */
  9879. bindShadowLight(lightIndex: string, effect: Effect): void;
  9880. /**
  9881. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9882. * (eq to shadow prjection matrix * light transform matrix)
  9883. * @returns The transform matrix used to create the shadow map
  9884. */
  9885. getTransformMatrix(): Matrix;
  9886. /**
  9887. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9888. * Cube and 2D textures for instance.
  9889. */
  9890. recreateShadowMap(): void;
  9891. /**
  9892. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9893. * @param onCompiled Callback triggered at the and of the effects compilation
  9894. * @param options Sets of optional options forcing the compilation with different modes
  9895. */
  9896. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9897. useInstances: boolean;
  9898. }>): void;
  9899. /**
  9900. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9901. * @param options Sets of optional options forcing the compilation with different modes
  9902. * @returns A promise that resolves when the compilation completes
  9903. */
  9904. forceCompilationAsync(options?: Partial<{
  9905. useInstances: boolean;
  9906. }>): Promise<void>;
  9907. /**
  9908. * Serializes the shadow generator setup to a json object.
  9909. * @returns The serialized JSON object
  9910. */
  9911. serialize(): any;
  9912. /**
  9913. * Disposes the Shadow map and related Textures and effects.
  9914. */
  9915. dispose(): void;
  9916. }
  9917. /**
  9918. * Default implementation IShadowGenerator.
  9919. * This is the main object responsible of generating shadows in the framework.
  9920. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9921. */
  9922. export class ShadowGenerator implements IShadowGenerator {
  9923. /**
  9924. * Shadow generator mode None: no filtering applied.
  9925. */
  9926. static readonly FILTER_NONE: number;
  9927. /**
  9928. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9929. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9930. */
  9931. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9932. /**
  9933. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9934. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9935. */
  9936. static readonly FILTER_POISSONSAMPLING: number;
  9937. /**
  9938. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9939. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9940. */
  9941. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9942. /**
  9943. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9944. * edge artifacts on steep falloff.
  9945. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9946. */
  9947. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9948. /**
  9949. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9950. * edge artifacts on steep falloff.
  9951. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9952. */
  9953. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9954. /**
  9955. * Shadow generator mode PCF: Percentage Closer Filtering
  9956. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9957. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9958. */
  9959. static readonly FILTER_PCF: number;
  9960. /**
  9961. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9962. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9963. * Contact Hardening
  9964. */
  9965. static readonly FILTER_PCSS: number;
  9966. /**
  9967. * Reserved for PCF and PCSS
  9968. * Highest Quality.
  9969. *
  9970. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9971. *
  9972. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9973. */
  9974. static readonly QUALITY_HIGH: number;
  9975. /**
  9976. * Reserved for PCF and PCSS
  9977. * Good tradeoff for quality/perf cross devices
  9978. *
  9979. * Execute PCF on a 3*3 kernel.
  9980. *
  9981. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9982. */
  9983. static readonly QUALITY_MEDIUM: number;
  9984. /**
  9985. * Reserved for PCF and PCSS
  9986. * The lowest quality but the fastest.
  9987. *
  9988. * Execute PCF on a 1*1 kernel.
  9989. *
  9990. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9991. */
  9992. static readonly QUALITY_LOW: number;
  9993. /** Gets or sets the custom shader name to use */
  9994. customShaderOptions: ICustomShaderOptions;
  9995. /**
  9996. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9997. */
  9998. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9999. /**
  10000. * Observable triggered before a mesh is rendered in the shadow map.
  10001. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10002. */
  10003. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10004. private _bias;
  10005. /**
  10006. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10007. */
  10008. /**
  10009. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10010. */
  10011. bias: number;
  10012. private _normalBias;
  10013. /**
  10014. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10015. */
  10016. /**
  10017. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10018. */
  10019. normalBias: number;
  10020. private _blurBoxOffset;
  10021. /**
  10022. * Gets the blur box offset: offset applied during the blur pass.
  10023. * Only useful if useKernelBlur = false
  10024. */
  10025. /**
  10026. * Sets the blur box offset: offset applied during the blur pass.
  10027. * Only useful if useKernelBlur = false
  10028. */
  10029. blurBoxOffset: number;
  10030. private _blurScale;
  10031. /**
  10032. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10033. * 2 means half of the size.
  10034. */
  10035. /**
  10036. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10037. * 2 means half of the size.
  10038. */
  10039. blurScale: number;
  10040. private _blurKernel;
  10041. /**
  10042. * Gets the blur kernel: kernel size of the blur pass.
  10043. * Only useful if useKernelBlur = true
  10044. */
  10045. /**
  10046. * Sets the blur kernel: kernel size of the blur pass.
  10047. * Only useful if useKernelBlur = true
  10048. */
  10049. blurKernel: number;
  10050. private _useKernelBlur;
  10051. /**
  10052. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10053. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10054. */
  10055. /**
  10056. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10057. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10058. */
  10059. useKernelBlur: boolean;
  10060. private _depthScale;
  10061. /**
  10062. * Gets the depth scale used in ESM mode.
  10063. */
  10064. /**
  10065. * Sets the depth scale used in ESM mode.
  10066. * This can override the scale stored on the light.
  10067. */
  10068. depthScale: number;
  10069. private _filter;
  10070. /**
  10071. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10072. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10073. */
  10074. /**
  10075. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10076. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10077. */
  10078. filter: number;
  10079. /**
  10080. * Gets if the current filter is set to Poisson Sampling.
  10081. */
  10082. /**
  10083. * Sets the current filter to Poisson Sampling.
  10084. */
  10085. usePoissonSampling: boolean;
  10086. /**
  10087. * Gets if the current filter is set to ESM.
  10088. */
  10089. /**
  10090. * Sets the current filter is to ESM.
  10091. */
  10092. useExponentialShadowMap: boolean;
  10093. /**
  10094. * Gets if the current filter is set to filtered ESM.
  10095. */
  10096. /**
  10097. * Gets if the current filter is set to filtered ESM.
  10098. */
  10099. useBlurExponentialShadowMap: boolean;
  10100. /**
  10101. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10102. * exponential to prevent steep falloff artifacts).
  10103. */
  10104. /**
  10105. * Sets the current filter to "close ESM" (using the inverse of the
  10106. * exponential to prevent steep falloff artifacts).
  10107. */
  10108. useCloseExponentialShadowMap: boolean;
  10109. /**
  10110. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10111. * exponential to prevent steep falloff artifacts).
  10112. */
  10113. /**
  10114. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10115. * exponential to prevent steep falloff artifacts).
  10116. */
  10117. useBlurCloseExponentialShadowMap: boolean;
  10118. /**
  10119. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10120. */
  10121. /**
  10122. * Sets the current filter to "PCF" (percentage closer filtering).
  10123. */
  10124. usePercentageCloserFiltering: boolean;
  10125. private _filteringQuality;
  10126. /**
  10127. * Gets the PCF or PCSS Quality.
  10128. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10129. */
  10130. /**
  10131. * Sets the PCF or PCSS Quality.
  10132. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10133. */
  10134. filteringQuality: number;
  10135. /**
  10136. * Gets if the current filter is set to "PCSS" (contact hardening).
  10137. */
  10138. /**
  10139. * Sets the current filter to "PCSS" (contact hardening).
  10140. */
  10141. useContactHardeningShadow: boolean;
  10142. private _contactHardeningLightSizeUVRatio;
  10143. /**
  10144. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10145. * Using a ratio helps keeping shape stability independently of the map size.
  10146. *
  10147. * It does not account for the light projection as it was having too much
  10148. * instability during the light setup or during light position changes.
  10149. *
  10150. * Only valid if useContactHardeningShadow is true.
  10151. */
  10152. /**
  10153. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10154. * Using a ratio helps keeping shape stability independently of the map size.
  10155. *
  10156. * It does not account for the light projection as it was having too much
  10157. * instability during the light setup or during light position changes.
  10158. *
  10159. * Only valid if useContactHardeningShadow is true.
  10160. */
  10161. contactHardeningLightSizeUVRatio: number;
  10162. private _darkness;
  10163. /**
  10164. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10165. * 0 means strongest and 1 would means no shadow.
  10166. * @returns the darkness.
  10167. */
  10168. getDarkness(): number;
  10169. /**
  10170. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10171. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10172. * @returns the shadow generator allowing fluent coding.
  10173. */
  10174. setDarkness(darkness: number): ShadowGenerator;
  10175. private _transparencyShadow;
  10176. /**
  10177. * Sets the ability to have transparent shadow (boolean).
  10178. * @param transparent True if transparent else False
  10179. * @returns the shadow generator allowing fluent coding
  10180. */
  10181. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10182. private _shadowMap;
  10183. private _shadowMap2;
  10184. /**
  10185. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10186. * @returns The render target texture if present otherwise, null
  10187. */
  10188. getShadowMap(): Nullable<RenderTargetTexture>;
  10189. /**
  10190. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10191. * @returns The render target texture if the shadow map is present otherwise, null
  10192. */
  10193. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10194. /**
  10195. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10196. * @param mesh Mesh to add
  10197. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10198. * @returns the Shadow Generator itself
  10199. */
  10200. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10201. /**
  10202. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10203. * @param mesh Mesh to remove
  10204. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10205. * @returns the Shadow Generator itself
  10206. */
  10207. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10208. /**
  10209. * Controls the extent to which the shadows fade out at the edge of the frustum
  10210. * Used only by directionals and spots
  10211. */
  10212. frustumEdgeFalloff: number;
  10213. private _light;
  10214. /**
  10215. * Returns the associated light object.
  10216. * @returns the light generating the shadow
  10217. */
  10218. getLight(): IShadowLight;
  10219. /**
  10220. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10221. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10222. * It might on the other hand introduce peter panning.
  10223. */
  10224. forceBackFacesOnly: boolean;
  10225. private _scene;
  10226. private _lightDirection;
  10227. private _effect;
  10228. private _viewMatrix;
  10229. private _projectionMatrix;
  10230. private _transformMatrix;
  10231. private _cachedPosition;
  10232. private _cachedDirection;
  10233. private _cachedDefines;
  10234. private _currentRenderID;
  10235. private _boxBlurPostprocess;
  10236. private _kernelBlurXPostprocess;
  10237. private _kernelBlurYPostprocess;
  10238. private _blurPostProcesses;
  10239. private _mapSize;
  10240. private _currentFaceIndex;
  10241. private _currentFaceIndexCache;
  10242. private _textureType;
  10243. private _defaultTextureMatrix;
  10244. /** @hidden */
  10245. static _SceneComponentInitialization: (scene: Scene) => void;
  10246. /**
  10247. * Creates a ShadowGenerator object.
  10248. * A ShadowGenerator is the required tool to use the shadows.
  10249. * Each light casting shadows needs to use its own ShadowGenerator.
  10250. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10251. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10252. * @param light The light object generating the shadows.
  10253. * @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.
  10254. */
  10255. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10256. private _initializeGenerator;
  10257. private _initializeShadowMap;
  10258. private _initializeBlurRTTAndPostProcesses;
  10259. private _renderForShadowMap;
  10260. private _renderSubMeshForShadowMap;
  10261. private _applyFilterValues;
  10262. /**
  10263. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10264. * @param onCompiled Callback triggered at the and of the effects compilation
  10265. * @param options Sets of optional options forcing the compilation with different modes
  10266. */
  10267. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10268. useInstances: boolean;
  10269. }>): void;
  10270. /**
  10271. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10272. * @param options Sets of optional options forcing the compilation with different modes
  10273. * @returns A promise that resolves when the compilation completes
  10274. */
  10275. forceCompilationAsync(options?: Partial<{
  10276. useInstances: boolean;
  10277. }>): Promise<void>;
  10278. /**
  10279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10280. * @param subMesh The submesh we want to render in the shadow map
  10281. * @param useInstances Defines wether will draw in the map using instances
  10282. * @returns true if ready otherwise, false
  10283. */
  10284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10285. /**
  10286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10287. * @param defines Defines of the material we want to update
  10288. * @param lightIndex Index of the light in the enabled light list of the material
  10289. */
  10290. prepareDefines(defines: any, lightIndex: number): void;
  10291. /**
  10292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10293. * defined in the generator but impacting the effect).
  10294. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10295. * @param effect The effect we are binfing the information for
  10296. */
  10297. bindShadowLight(lightIndex: string, effect: Effect): void;
  10298. /**
  10299. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10300. * (eq to shadow prjection matrix * light transform matrix)
  10301. * @returns The transform matrix used to create the shadow map
  10302. */
  10303. getTransformMatrix(): Matrix;
  10304. /**
  10305. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10306. * Cube and 2D textures for instance.
  10307. */
  10308. recreateShadowMap(): void;
  10309. private _disposeBlurPostProcesses;
  10310. private _disposeRTTandPostProcesses;
  10311. /**
  10312. * Disposes the ShadowGenerator.
  10313. * Returns nothing.
  10314. */
  10315. dispose(): void;
  10316. /**
  10317. * Serializes the shadow generator setup to a json object.
  10318. * @returns The serialized JSON object
  10319. */
  10320. serialize(): any;
  10321. /**
  10322. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10323. * @param parsedShadowGenerator The JSON object to parse
  10324. * @param scene The scene to create the shadow map for
  10325. * @returns The parsed shadow generator
  10326. */
  10327. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10328. }
  10329. }
  10330. declare module "babylonjs/Lights/light" {
  10331. import { Nullable } from "babylonjs/types";
  10332. import { Scene } from "babylonjs/scene";
  10333. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10334. import { Node } from "babylonjs/node";
  10335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10336. import { Effect } from "babylonjs/Materials/effect";
  10337. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10338. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10339. /**
  10340. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10341. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10342. * 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.
  10343. */
  10344. export abstract class Light extends Node {
  10345. /**
  10346. * Falloff Default: light is falling off following the material specification:
  10347. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10348. */
  10349. static readonly FALLOFF_DEFAULT: number;
  10350. /**
  10351. * Falloff Physical: light is falling off following the inverse squared distance law.
  10352. */
  10353. static readonly FALLOFF_PHYSICAL: number;
  10354. /**
  10355. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10356. * to enhance interoperability with other engines.
  10357. */
  10358. static readonly FALLOFF_GLTF: number;
  10359. /**
  10360. * Falloff Standard: light is falling off like in the standard material
  10361. * to enhance interoperability with other materials.
  10362. */
  10363. static readonly FALLOFF_STANDARD: number;
  10364. /**
  10365. * If every light affecting the material is in this lightmapMode,
  10366. * material.lightmapTexture adds or multiplies
  10367. * (depends on material.useLightmapAsShadowmap)
  10368. * after every other light calculations.
  10369. */
  10370. static readonly LIGHTMAP_DEFAULT: number;
  10371. /**
  10372. * material.lightmapTexture as only diffuse lighting from this light
  10373. * adds only specular lighting from this light
  10374. * adds dynamic shadows
  10375. */
  10376. static readonly LIGHTMAP_SPECULAR: number;
  10377. /**
  10378. * material.lightmapTexture as only lighting
  10379. * no light calculation from this light
  10380. * only adds dynamic shadows from this light
  10381. */
  10382. static readonly LIGHTMAP_SHADOWSONLY: number;
  10383. /**
  10384. * Each light type uses the default quantity according to its type:
  10385. * point/spot lights use luminous intensity
  10386. * directional lights use illuminance
  10387. */
  10388. static readonly INTENSITYMODE_AUTOMATIC: number;
  10389. /**
  10390. * lumen (lm)
  10391. */
  10392. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10393. /**
  10394. * candela (lm/sr)
  10395. */
  10396. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10397. /**
  10398. * lux (lm/m^2)
  10399. */
  10400. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10401. /**
  10402. * nit (cd/m^2)
  10403. */
  10404. static readonly INTENSITYMODE_LUMINANCE: number;
  10405. /**
  10406. * Light type const id of the point light.
  10407. */
  10408. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10409. /**
  10410. * Light type const id of the directional light.
  10411. */
  10412. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10413. /**
  10414. * Light type const id of the spot light.
  10415. */
  10416. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10417. /**
  10418. * Light type const id of the hemispheric light.
  10419. */
  10420. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10421. /**
  10422. * Diffuse gives the basic color to an object.
  10423. */
  10424. diffuse: Color3;
  10425. /**
  10426. * Specular produces a highlight color on an object.
  10427. * Note: This is note affecting PBR materials.
  10428. */
  10429. specular: Color3;
  10430. /**
  10431. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10432. * falling off base on range or angle.
  10433. * This can be set to any values in Light.FALLOFF_x.
  10434. *
  10435. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10436. * other types of materials.
  10437. */
  10438. falloffType: number;
  10439. /**
  10440. * Strength of the light.
  10441. * Note: By default it is define in the framework own unit.
  10442. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10443. */
  10444. intensity: number;
  10445. private _range;
  10446. protected _inverseSquaredRange: number;
  10447. /**
  10448. * Defines how far from the source the light is impacting in scene units.
  10449. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10450. */
  10451. /**
  10452. * Defines how far from the source the light is impacting in scene units.
  10453. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10454. */
  10455. range: number;
  10456. /**
  10457. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10458. * of light.
  10459. */
  10460. private _photometricScale;
  10461. private _intensityMode;
  10462. /**
  10463. * Gets the photometric scale used to interpret the intensity.
  10464. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10465. */
  10466. /**
  10467. * Sets the photometric scale used to interpret the intensity.
  10468. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10469. */
  10470. intensityMode: number;
  10471. private _radius;
  10472. /**
  10473. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10474. */
  10475. /**
  10476. * sets the light radius used by PBR Materials to simulate soft area lights.
  10477. */
  10478. radius: number;
  10479. private _renderPriority;
  10480. /**
  10481. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10482. * exceeding the number allowed of the materials.
  10483. */
  10484. renderPriority: number;
  10485. private _shadowEnabled;
  10486. /**
  10487. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10488. * the current shadow generator.
  10489. */
  10490. /**
  10491. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10492. * the current shadow generator.
  10493. */
  10494. shadowEnabled: boolean;
  10495. private _includedOnlyMeshes;
  10496. /**
  10497. * Gets the only meshes impacted by this light.
  10498. */
  10499. /**
  10500. * Sets the only meshes impacted by this light.
  10501. */
  10502. includedOnlyMeshes: AbstractMesh[];
  10503. private _excludedMeshes;
  10504. /**
  10505. * Gets the meshes not impacted by this light.
  10506. */
  10507. /**
  10508. * Sets the meshes not impacted by this light.
  10509. */
  10510. excludedMeshes: AbstractMesh[];
  10511. private _excludeWithLayerMask;
  10512. /**
  10513. * Gets the layer id use to find what meshes are not impacted by the light.
  10514. * Inactive if 0
  10515. */
  10516. /**
  10517. * Sets the layer id use to find what meshes are not impacted by the light.
  10518. * Inactive if 0
  10519. */
  10520. excludeWithLayerMask: number;
  10521. private _includeOnlyWithLayerMask;
  10522. /**
  10523. * Gets the layer id use to find what meshes are impacted by the light.
  10524. * Inactive if 0
  10525. */
  10526. /**
  10527. * Sets the layer id use to find what meshes are impacted by the light.
  10528. * Inactive if 0
  10529. */
  10530. includeOnlyWithLayerMask: number;
  10531. private _lightmapMode;
  10532. /**
  10533. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10534. */
  10535. /**
  10536. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10537. */
  10538. lightmapMode: number;
  10539. /**
  10540. * Shadow generator associted to the light.
  10541. * @hidden Internal use only.
  10542. */
  10543. _shadowGenerator: Nullable<IShadowGenerator>;
  10544. /**
  10545. * @hidden Internal use only.
  10546. */
  10547. _excludedMeshesIds: string[];
  10548. /**
  10549. * @hidden Internal use only.
  10550. */
  10551. _includedOnlyMeshesIds: string[];
  10552. /**
  10553. * The current light unifom buffer.
  10554. * @hidden Internal use only.
  10555. */
  10556. _uniformBuffer: UniformBuffer;
  10557. /**
  10558. * Creates a Light object in the scene.
  10559. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10560. * @param name The firendly name of the light
  10561. * @param scene The scene the light belongs too
  10562. */
  10563. constructor(name: string, scene: Scene);
  10564. protected abstract _buildUniformLayout(): void;
  10565. /**
  10566. * Sets the passed Effect "effect" with the Light information.
  10567. * @param effect The effect to update
  10568. * @param lightIndex The index of the light in the effect to update
  10569. * @returns The light
  10570. */
  10571. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10572. /**
  10573. * Returns the string "Light".
  10574. * @returns the class name
  10575. */
  10576. getClassName(): string;
  10577. /** @hidden */
  10578. readonly _isLight: boolean;
  10579. /**
  10580. * Converts the light information to a readable string for debug purpose.
  10581. * @param fullDetails Supports for multiple levels of logging within scene loading
  10582. * @returns the human readable light info
  10583. */
  10584. toString(fullDetails?: boolean): string;
  10585. /** @hidden */
  10586. protected _syncParentEnabledState(): void;
  10587. /**
  10588. * Set the enabled state of this node.
  10589. * @param value - the new enabled state
  10590. */
  10591. setEnabled(value: boolean): void;
  10592. /**
  10593. * Returns the Light associated shadow generator if any.
  10594. * @return the associated shadow generator.
  10595. */
  10596. getShadowGenerator(): Nullable<IShadowGenerator>;
  10597. /**
  10598. * Returns a Vector3, the absolute light position in the World.
  10599. * @returns the world space position of the light
  10600. */
  10601. getAbsolutePosition(): Vector3;
  10602. /**
  10603. * Specifies if the light will affect the passed mesh.
  10604. * @param mesh The mesh to test against the light
  10605. * @return true the mesh is affected otherwise, false.
  10606. */
  10607. canAffectMesh(mesh: AbstractMesh): boolean;
  10608. /**
  10609. * Sort function to order lights for rendering.
  10610. * @param a First Light object to compare to second.
  10611. * @param b Second Light object to compare first.
  10612. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10613. */
  10614. static CompareLightsPriority(a: Light, b: Light): number;
  10615. /**
  10616. * Releases resources associated with this node.
  10617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10619. */
  10620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10621. /**
  10622. * Returns the light type ID (integer).
  10623. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10624. */
  10625. getTypeID(): number;
  10626. /**
  10627. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10628. * @returns the scaled intensity in intensity mode unit
  10629. */
  10630. getScaledIntensity(): number;
  10631. /**
  10632. * Returns a new Light object, named "name", from the current one.
  10633. * @param name The name of the cloned light
  10634. * @returns the new created light
  10635. */
  10636. clone(name: string): Nullable<Light>;
  10637. /**
  10638. * Serializes the current light into a Serialization object.
  10639. * @returns the serialized object.
  10640. */
  10641. serialize(): any;
  10642. /**
  10643. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10644. * This new light is named "name" and added to the passed scene.
  10645. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10646. * @param name The friendly name of the light
  10647. * @param scene The scene the new light will belong to
  10648. * @returns the constructor function
  10649. */
  10650. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10651. /**
  10652. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10653. * @param parsedLight The JSON representation of the light
  10654. * @param scene The scene to create the parsed light in
  10655. * @returns the created light after parsing
  10656. */
  10657. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10658. private _hookArrayForExcluded;
  10659. private _hookArrayForIncludedOnly;
  10660. private _resyncMeshes;
  10661. /**
  10662. * Forces the meshes to update their light related information in their rendering used effects
  10663. * @hidden Internal Use Only
  10664. */
  10665. _markMeshesAsLightDirty(): void;
  10666. /**
  10667. * Recomputes the cached photometric scale if needed.
  10668. */
  10669. private _computePhotometricScale;
  10670. /**
  10671. * Returns the Photometric Scale according to the light type and intensity mode.
  10672. */
  10673. private _getPhotometricScale;
  10674. /**
  10675. * Reorder the light in the scene according to their defined priority.
  10676. * @hidden Internal Use Only
  10677. */
  10678. _reorderLightsInScene(): void;
  10679. /**
  10680. * Prepares the list of defines specific to the light type.
  10681. * @param defines the list of defines
  10682. * @param lightIndex defines the index of the light for the effect
  10683. */
  10684. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10685. }
  10686. }
  10687. declare module "babylonjs/Actions/action" {
  10688. import { Observable } from "babylonjs/Misc/observable";
  10689. import { Condition } from "babylonjs/Actions/condition";
  10690. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10691. import { ActionManager } from "babylonjs/Actions/actionManager";
  10692. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10693. /**
  10694. * Interface used to define Action
  10695. */
  10696. export interface IAction {
  10697. /**
  10698. * Trigger for the action
  10699. */
  10700. trigger: number;
  10701. /** Options of the trigger */
  10702. triggerOptions: any;
  10703. /**
  10704. * Gets the trigger parameters
  10705. * @returns the trigger parameters
  10706. */
  10707. getTriggerParameter(): any;
  10708. /**
  10709. * Internal only - executes current action event
  10710. * @hidden
  10711. */
  10712. _executeCurrent(evt?: ActionEvent): void;
  10713. /**
  10714. * Serialize placeholder for child classes
  10715. * @param parent of child
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. /**
  10720. * Internal only
  10721. * @hidden
  10722. */
  10723. _prepare(): void;
  10724. /**
  10725. * Internal only - manager for action
  10726. * @hidden
  10727. */
  10728. _actionManager: AbstractActionManager;
  10729. }
  10730. /**
  10731. * The action to be carried out following a trigger
  10732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10733. */
  10734. export class Action implements IAction {
  10735. /** the trigger, with or without parameters, for the action */
  10736. triggerOptions: any;
  10737. /**
  10738. * Trigger for the action
  10739. */
  10740. trigger: number;
  10741. /**
  10742. * Internal only - manager for action
  10743. * @hidden
  10744. */
  10745. _actionManager: ActionManager;
  10746. private _nextActiveAction;
  10747. private _child;
  10748. private _condition?;
  10749. private _triggerParameter;
  10750. /**
  10751. * An event triggered prior to action being executed.
  10752. */
  10753. onBeforeExecuteObservable: Observable<Action>;
  10754. /**
  10755. * Creates a new Action
  10756. * @param triggerOptions the trigger, with or without parameters, for the action
  10757. * @param condition an optional determinant of action
  10758. */
  10759. constructor(
  10760. /** the trigger, with or without parameters, for the action */
  10761. triggerOptions: any, condition?: Condition);
  10762. /**
  10763. * Internal only
  10764. * @hidden
  10765. */
  10766. _prepare(): void;
  10767. /**
  10768. * Gets the trigger parameters
  10769. * @returns the trigger parameters
  10770. */
  10771. getTriggerParameter(): any;
  10772. /**
  10773. * Internal only - executes current action event
  10774. * @hidden
  10775. */
  10776. _executeCurrent(evt?: ActionEvent): void;
  10777. /**
  10778. * Execute placeholder for child classes
  10779. * @param evt optional action event
  10780. */
  10781. execute(evt?: ActionEvent): void;
  10782. /**
  10783. * Skips to next active action
  10784. */
  10785. skipToNextActiveAction(): void;
  10786. /**
  10787. * Adds action to chain of actions, may be a DoNothingAction
  10788. * @param action defines the next action to execute
  10789. * @returns The action passed in
  10790. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10791. */
  10792. then(action: Action): Action;
  10793. /**
  10794. * Internal only
  10795. * @hidden
  10796. */
  10797. _getProperty(propertyPath: string): string;
  10798. /**
  10799. * Internal only
  10800. * @hidden
  10801. */
  10802. _getEffectiveTarget(target: any, propertyPath: string): any;
  10803. /**
  10804. * Serialize placeholder for child classes
  10805. * @param parent of child
  10806. * @returns the serialized object
  10807. */
  10808. serialize(parent: any): any;
  10809. /**
  10810. * Internal only called by serialize
  10811. * @hidden
  10812. */
  10813. protected _serialize(serializedAction: any, parent?: any): any;
  10814. /**
  10815. * Internal only
  10816. * @hidden
  10817. */
  10818. static _SerializeValueAsString: (value: any) => string;
  10819. /**
  10820. * Internal only
  10821. * @hidden
  10822. */
  10823. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10824. name: string;
  10825. targetType: string;
  10826. value: string;
  10827. };
  10828. }
  10829. }
  10830. declare module "babylonjs/Actions/condition" {
  10831. import { ActionManager } from "babylonjs/Actions/actionManager";
  10832. /**
  10833. * A Condition applied to an Action
  10834. */
  10835. export class Condition {
  10836. /**
  10837. * Internal only - manager for action
  10838. * @hidden
  10839. */
  10840. _actionManager: ActionManager;
  10841. /**
  10842. * Internal only
  10843. * @hidden
  10844. */
  10845. _evaluationId: number;
  10846. /**
  10847. * Internal only
  10848. * @hidden
  10849. */
  10850. _currentResult: boolean;
  10851. /**
  10852. * Creates a new Condition
  10853. * @param actionManager the manager of the action the condition is applied to
  10854. */
  10855. constructor(actionManager: ActionManager);
  10856. /**
  10857. * Check if the current condition is valid
  10858. * @returns a boolean
  10859. */
  10860. isValid(): boolean;
  10861. /**
  10862. * Internal only
  10863. * @hidden
  10864. */
  10865. _getProperty(propertyPath: string): string;
  10866. /**
  10867. * Internal only
  10868. * @hidden
  10869. */
  10870. _getEffectiveTarget(target: any, propertyPath: string): any;
  10871. /**
  10872. * Serialize placeholder for child classes
  10873. * @returns the serialized object
  10874. */
  10875. serialize(): any;
  10876. /**
  10877. * Internal only
  10878. * @hidden
  10879. */
  10880. protected _serialize(serializedCondition: any): any;
  10881. }
  10882. /**
  10883. * Defines specific conditional operators as extensions of Condition
  10884. */
  10885. export class ValueCondition extends Condition {
  10886. /** path to specify the property of the target the conditional operator uses */
  10887. propertyPath: string;
  10888. /** the value compared by the conditional operator against the current value of the property */
  10889. value: any;
  10890. /** the conditional operator, default ValueCondition.IsEqual */
  10891. operator: number;
  10892. /**
  10893. * Internal only
  10894. * @hidden
  10895. */
  10896. private static _IsEqual;
  10897. /**
  10898. * Internal only
  10899. * @hidden
  10900. */
  10901. private static _IsDifferent;
  10902. /**
  10903. * Internal only
  10904. * @hidden
  10905. */
  10906. private static _IsGreater;
  10907. /**
  10908. * Internal only
  10909. * @hidden
  10910. */
  10911. private static _IsLesser;
  10912. /**
  10913. * returns the number for IsEqual
  10914. */
  10915. static readonly IsEqual: number;
  10916. /**
  10917. * Returns the number for IsDifferent
  10918. */
  10919. static readonly IsDifferent: number;
  10920. /**
  10921. * Returns the number for IsGreater
  10922. */
  10923. static readonly IsGreater: number;
  10924. /**
  10925. * Returns the number for IsLesser
  10926. */
  10927. static readonly IsLesser: number;
  10928. /**
  10929. * Internal only The action manager for the condition
  10930. * @hidden
  10931. */
  10932. _actionManager: ActionManager;
  10933. /**
  10934. * Internal only
  10935. * @hidden
  10936. */
  10937. private _target;
  10938. /**
  10939. * Internal only
  10940. * @hidden
  10941. */
  10942. private _effectiveTarget;
  10943. /**
  10944. * Internal only
  10945. * @hidden
  10946. */
  10947. private _property;
  10948. /**
  10949. * Creates a new ValueCondition
  10950. * @param actionManager manager for the action the condition applies to
  10951. * @param target for the action
  10952. * @param propertyPath path to specify the property of the target the conditional operator uses
  10953. * @param value the value compared by the conditional operator against the current value of the property
  10954. * @param operator the conditional operator, default ValueCondition.IsEqual
  10955. */
  10956. constructor(actionManager: ActionManager, target: any,
  10957. /** path to specify the property of the target the conditional operator uses */
  10958. propertyPath: string,
  10959. /** the value compared by the conditional operator against the current value of the property */
  10960. value: any,
  10961. /** the conditional operator, default ValueCondition.IsEqual */
  10962. operator?: number);
  10963. /**
  10964. * Compares the given value with the property value for the specified conditional operator
  10965. * @returns the result of the comparison
  10966. */
  10967. isValid(): boolean;
  10968. /**
  10969. * Serialize the ValueCondition into a JSON compatible object
  10970. * @returns serialization object
  10971. */
  10972. serialize(): any;
  10973. /**
  10974. * Gets the name of the conditional operator for the ValueCondition
  10975. * @param operator the conditional operator
  10976. * @returns the name
  10977. */
  10978. static GetOperatorName(operator: number): string;
  10979. }
  10980. /**
  10981. * Defines a predicate condition as an extension of Condition
  10982. */
  10983. export class PredicateCondition extends Condition {
  10984. /** defines the predicate function used to validate the condition */
  10985. predicate: () => boolean;
  10986. /**
  10987. * Internal only - manager for action
  10988. * @hidden
  10989. */
  10990. _actionManager: ActionManager;
  10991. /**
  10992. * Creates a new PredicateCondition
  10993. * @param actionManager manager for the action the condition applies to
  10994. * @param predicate defines the predicate function used to validate the condition
  10995. */
  10996. constructor(actionManager: ActionManager,
  10997. /** defines the predicate function used to validate the condition */
  10998. predicate: () => boolean);
  10999. /**
  11000. * @returns the validity of the predicate condition
  11001. */
  11002. isValid(): boolean;
  11003. }
  11004. /**
  11005. * Defines a state condition as an extension of Condition
  11006. */
  11007. export class StateCondition extends Condition {
  11008. /** Value to compare with target state */
  11009. value: string;
  11010. /**
  11011. * Internal only - manager for action
  11012. * @hidden
  11013. */
  11014. _actionManager: ActionManager;
  11015. /**
  11016. * Internal only
  11017. * @hidden
  11018. */
  11019. private _target;
  11020. /**
  11021. * Creates a new StateCondition
  11022. * @param actionManager manager for the action the condition applies to
  11023. * @param target of the condition
  11024. * @param value to compare with target state
  11025. */
  11026. constructor(actionManager: ActionManager, target: any,
  11027. /** Value to compare with target state */
  11028. value: string);
  11029. /**
  11030. * Gets a boolean indicating if the current condition is met
  11031. * @returns the validity of the state
  11032. */
  11033. isValid(): boolean;
  11034. /**
  11035. * Serialize the StateCondition into a JSON compatible object
  11036. * @returns serialization object
  11037. */
  11038. serialize(): any;
  11039. }
  11040. }
  11041. declare module "babylonjs/Actions/directActions" {
  11042. import { Action } from "babylonjs/Actions/action";
  11043. import { Condition } from "babylonjs/Actions/condition";
  11044. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11045. /**
  11046. * This defines an action responsible to toggle a boolean once triggered.
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11048. */
  11049. export class SwitchBooleanAction extends Action {
  11050. /**
  11051. * The path to the boolean property in the target object
  11052. */
  11053. propertyPath: string;
  11054. private _target;
  11055. private _effectiveTarget;
  11056. private _property;
  11057. /**
  11058. * Instantiate the action
  11059. * @param triggerOptions defines the trigger options
  11060. * @param target defines the object containing the boolean
  11061. * @param propertyPath defines the path to the boolean property in the target object
  11062. * @param condition defines the trigger related conditions
  11063. */
  11064. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11065. /** @hidden */
  11066. _prepare(): void;
  11067. /**
  11068. * Execute the action toggle the boolean value.
  11069. */
  11070. execute(): void;
  11071. /**
  11072. * Serializes the actions and its related information.
  11073. * @param parent defines the object to serialize in
  11074. * @returns the serialized object
  11075. */
  11076. serialize(parent: any): any;
  11077. }
  11078. /**
  11079. * This defines an action responsible to set a the state field of the target
  11080. * to a desired value once triggered.
  11081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11082. */
  11083. export class SetStateAction extends Action {
  11084. /**
  11085. * The value to store in the state field.
  11086. */
  11087. value: string;
  11088. private _target;
  11089. /**
  11090. * Instantiate the action
  11091. * @param triggerOptions defines the trigger options
  11092. * @param target defines the object containing the state property
  11093. * @param value defines the value to store in the state field
  11094. * @param condition defines the trigger related conditions
  11095. */
  11096. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11097. /**
  11098. * Execute the action and store the value on the target state property.
  11099. */
  11100. execute(): void;
  11101. /**
  11102. * Serializes the actions and its related information.
  11103. * @param parent defines the object to serialize in
  11104. * @returns the serialized object
  11105. */
  11106. serialize(parent: any): any;
  11107. }
  11108. /**
  11109. * This defines an action responsible to set a property of the target
  11110. * to a desired value once triggered.
  11111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11112. */
  11113. export class SetValueAction extends Action {
  11114. /**
  11115. * The path of the property to set in the target.
  11116. */
  11117. propertyPath: string;
  11118. /**
  11119. * The value to set in the property
  11120. */
  11121. value: any;
  11122. private _target;
  11123. private _effectiveTarget;
  11124. private _property;
  11125. /**
  11126. * Instantiate the action
  11127. * @param triggerOptions defines the trigger options
  11128. * @param target defines the object containing the property
  11129. * @param propertyPath defines the path of the property to set in the target
  11130. * @param value defines the value to set in the property
  11131. * @param condition defines the trigger related conditions
  11132. */
  11133. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11134. /** @hidden */
  11135. _prepare(): void;
  11136. /**
  11137. * Execute the action and set the targetted property to the desired value.
  11138. */
  11139. execute(): void;
  11140. /**
  11141. * Serializes the actions and its related information.
  11142. * @param parent defines the object to serialize in
  11143. * @returns the serialized object
  11144. */
  11145. serialize(parent: any): any;
  11146. }
  11147. /**
  11148. * This defines an action responsible to increment the target value
  11149. * to a desired value once triggered.
  11150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11151. */
  11152. export class IncrementValueAction extends Action {
  11153. /**
  11154. * The path of the property to increment in the target.
  11155. */
  11156. propertyPath: string;
  11157. /**
  11158. * The value we should increment the property by.
  11159. */
  11160. value: any;
  11161. private _target;
  11162. private _effectiveTarget;
  11163. private _property;
  11164. /**
  11165. * Instantiate the action
  11166. * @param triggerOptions defines the trigger options
  11167. * @param target defines the object containing the property
  11168. * @param propertyPath defines the path of the property to increment in the target
  11169. * @param value defines the value value we should increment the property by
  11170. * @param condition defines the trigger related conditions
  11171. */
  11172. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11173. /** @hidden */
  11174. _prepare(): void;
  11175. /**
  11176. * Execute the action and increment the target of the value amount.
  11177. */
  11178. execute(): void;
  11179. /**
  11180. * Serializes the actions and its related information.
  11181. * @param parent defines the object to serialize in
  11182. * @returns the serialized object
  11183. */
  11184. serialize(parent: any): any;
  11185. }
  11186. /**
  11187. * This defines an action responsible to start an animation once triggered.
  11188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11189. */
  11190. export class PlayAnimationAction extends Action {
  11191. /**
  11192. * Where the animation should start (animation frame)
  11193. */
  11194. from: number;
  11195. /**
  11196. * Where the animation should stop (animation frame)
  11197. */
  11198. to: number;
  11199. /**
  11200. * Define if the animation should loop or stop after the first play.
  11201. */
  11202. loop?: boolean;
  11203. private _target;
  11204. /**
  11205. * Instantiate the action
  11206. * @param triggerOptions defines the trigger options
  11207. * @param target defines the target animation or animation name
  11208. * @param from defines from where the animation should start (animation frame)
  11209. * @param end defines where the animation should stop (animation frame)
  11210. * @param loop defines if the animation should loop or stop after the first play
  11211. * @param condition defines the trigger related conditions
  11212. */
  11213. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11214. /** @hidden */
  11215. _prepare(): void;
  11216. /**
  11217. * Execute the action and play the animation.
  11218. */
  11219. execute(): void;
  11220. /**
  11221. * Serializes the actions and its related information.
  11222. * @param parent defines the object to serialize in
  11223. * @returns the serialized object
  11224. */
  11225. serialize(parent: any): any;
  11226. }
  11227. /**
  11228. * This defines an action responsible to stop an animation once triggered.
  11229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11230. */
  11231. export class StopAnimationAction extends Action {
  11232. private _target;
  11233. /**
  11234. * Instantiate the action
  11235. * @param triggerOptions defines the trigger options
  11236. * @param target defines the target animation or animation name
  11237. * @param condition defines the trigger related conditions
  11238. */
  11239. constructor(triggerOptions: any, target: any, condition?: Condition);
  11240. /** @hidden */
  11241. _prepare(): void;
  11242. /**
  11243. * Execute the action and stop the animation.
  11244. */
  11245. execute(): void;
  11246. /**
  11247. * Serializes the actions and its related information.
  11248. * @param parent defines the object to serialize in
  11249. * @returns the serialized object
  11250. */
  11251. serialize(parent: any): any;
  11252. }
  11253. /**
  11254. * This defines an action responsible that does nothing once triggered.
  11255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11256. */
  11257. export class DoNothingAction extends Action {
  11258. /**
  11259. * Instantiate the action
  11260. * @param triggerOptions defines the trigger options
  11261. * @param condition defines the trigger related conditions
  11262. */
  11263. constructor(triggerOptions?: any, condition?: Condition);
  11264. /**
  11265. * Execute the action and do nothing.
  11266. */
  11267. execute(): void;
  11268. /**
  11269. * Serializes the actions and its related information.
  11270. * @param parent defines the object to serialize in
  11271. * @returns the serialized object
  11272. */
  11273. serialize(parent: any): any;
  11274. }
  11275. /**
  11276. * This defines an action responsible to trigger several actions once triggered.
  11277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11278. */
  11279. export class CombineAction extends Action {
  11280. /**
  11281. * The list of aggregated animations to run.
  11282. */
  11283. children: Action[];
  11284. /**
  11285. * Instantiate the action
  11286. * @param triggerOptions defines the trigger options
  11287. * @param children defines the list of aggregated animations to run
  11288. * @param condition defines the trigger related conditions
  11289. */
  11290. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11291. /** @hidden */
  11292. _prepare(): void;
  11293. /**
  11294. * Execute the action and executes all the aggregated actions.
  11295. */
  11296. execute(evt: ActionEvent): void;
  11297. /**
  11298. * Serializes the actions and its related information.
  11299. * @param parent defines the object to serialize in
  11300. * @returns the serialized object
  11301. */
  11302. serialize(parent: any): any;
  11303. }
  11304. /**
  11305. * This defines an action responsible to run code (external event) once triggered.
  11306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11307. */
  11308. export class ExecuteCodeAction extends Action {
  11309. /**
  11310. * The callback function to run.
  11311. */
  11312. func: (evt: ActionEvent) => void;
  11313. /**
  11314. * Instantiate the action
  11315. * @param triggerOptions defines the trigger options
  11316. * @param func defines the callback function to run
  11317. * @param condition defines the trigger related conditions
  11318. */
  11319. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11320. /**
  11321. * Execute the action and run the attached code.
  11322. */
  11323. execute(evt: ActionEvent): void;
  11324. }
  11325. /**
  11326. * This defines an action responsible to set the parent property of the target once triggered.
  11327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11328. */
  11329. export class SetParentAction extends Action {
  11330. private _parent;
  11331. private _target;
  11332. /**
  11333. * Instantiate the action
  11334. * @param triggerOptions defines the trigger options
  11335. * @param target defines the target containing the parent property
  11336. * @param parent defines from where the animation should start (animation frame)
  11337. * @param condition defines the trigger related conditions
  11338. */
  11339. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11340. /** @hidden */
  11341. _prepare(): void;
  11342. /**
  11343. * Execute the action and set the parent property.
  11344. */
  11345. execute(): void;
  11346. /**
  11347. * Serializes the actions and its related information.
  11348. * @param parent defines the object to serialize in
  11349. * @returns the serialized object
  11350. */
  11351. serialize(parent: any): any;
  11352. }
  11353. }
  11354. declare module "babylonjs/Actions/actionManager" {
  11355. import { Nullable } from "babylonjs/types";
  11356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11357. import { Scene } from "babylonjs/scene";
  11358. import { IAction } from "babylonjs/Actions/action";
  11359. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11360. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11361. /**
  11362. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11363. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11365. */
  11366. export class ActionManager extends AbstractActionManager {
  11367. /**
  11368. * Nothing
  11369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11370. */
  11371. static readonly NothingTrigger: number;
  11372. /**
  11373. * On pick
  11374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11375. */
  11376. static readonly OnPickTrigger: number;
  11377. /**
  11378. * On left pick
  11379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11380. */
  11381. static readonly OnLeftPickTrigger: number;
  11382. /**
  11383. * On right pick
  11384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11385. */
  11386. static readonly OnRightPickTrigger: number;
  11387. /**
  11388. * On center pick
  11389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11390. */
  11391. static readonly OnCenterPickTrigger: number;
  11392. /**
  11393. * On pick down
  11394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11395. */
  11396. static readonly OnPickDownTrigger: number;
  11397. /**
  11398. * On double pick
  11399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11400. */
  11401. static readonly OnDoublePickTrigger: number;
  11402. /**
  11403. * On pick up
  11404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11405. */
  11406. static readonly OnPickUpTrigger: number;
  11407. /**
  11408. * On pick out.
  11409. * This trigger will only be raised if you also declared a OnPickDown
  11410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11411. */
  11412. static readonly OnPickOutTrigger: number;
  11413. /**
  11414. * On long press
  11415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11416. */
  11417. static readonly OnLongPressTrigger: number;
  11418. /**
  11419. * On pointer over
  11420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11421. */
  11422. static readonly OnPointerOverTrigger: number;
  11423. /**
  11424. * On pointer out
  11425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11426. */
  11427. static readonly OnPointerOutTrigger: number;
  11428. /**
  11429. * On every frame
  11430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11431. */
  11432. static readonly OnEveryFrameTrigger: number;
  11433. /**
  11434. * On intersection enter
  11435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11436. */
  11437. static readonly OnIntersectionEnterTrigger: number;
  11438. /**
  11439. * On intersection exit
  11440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11441. */
  11442. static readonly OnIntersectionExitTrigger: number;
  11443. /**
  11444. * On key down
  11445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11446. */
  11447. static readonly OnKeyDownTrigger: number;
  11448. /**
  11449. * On key up
  11450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11451. */
  11452. static readonly OnKeyUpTrigger: number;
  11453. private _scene;
  11454. /**
  11455. * Creates a new action manager
  11456. * @param scene defines the hosting scene
  11457. */
  11458. constructor(scene: Scene);
  11459. /**
  11460. * Releases all associated resources
  11461. */
  11462. dispose(): void;
  11463. /**
  11464. * Gets hosting scene
  11465. * @returns the hosting scene
  11466. */
  11467. getScene(): Scene;
  11468. /**
  11469. * Does this action manager handles actions of any of the given triggers
  11470. * @param triggers defines the triggers to be tested
  11471. * @return a boolean indicating whether one (or more) of the triggers is handled
  11472. */
  11473. hasSpecificTriggers(triggers: number[]): boolean;
  11474. /**
  11475. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11476. * speed.
  11477. * @param triggerA defines the trigger to be tested
  11478. * @param triggerB defines the trigger to be tested
  11479. * @return a boolean indicating whether one (or more) of the triggers is handled
  11480. */
  11481. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11482. /**
  11483. * Does this action manager handles actions of a given trigger
  11484. * @param trigger defines the trigger to be tested
  11485. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11486. * @return whether the trigger is handled
  11487. */
  11488. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11489. /**
  11490. * Does this action manager has pointer triggers
  11491. */
  11492. readonly hasPointerTriggers: boolean;
  11493. /**
  11494. * Does this action manager has pick triggers
  11495. */
  11496. readonly hasPickTriggers: boolean;
  11497. /**
  11498. * Registers an action to this action manager
  11499. * @param action defines the action to be registered
  11500. * @return the action amended (prepared) after registration
  11501. */
  11502. registerAction(action: IAction): Nullable<IAction>;
  11503. /**
  11504. * Unregisters an action to this action manager
  11505. * @param action defines the action to be unregistered
  11506. * @return a boolean indicating whether the action has been unregistered
  11507. */
  11508. unregisterAction(action: IAction): Boolean;
  11509. /**
  11510. * Process a specific trigger
  11511. * @param trigger defines the trigger to process
  11512. * @param evt defines the event details to be processed
  11513. */
  11514. processTrigger(trigger: number, evt?: IActionEvent): void;
  11515. /** @hidden */
  11516. _getEffectiveTarget(target: any, propertyPath: string): any;
  11517. /** @hidden */
  11518. _getProperty(propertyPath: string): string;
  11519. /**
  11520. * Serialize this manager to a JSON object
  11521. * @param name defines the property name to store this manager
  11522. * @returns a JSON representation of this manager
  11523. */
  11524. serialize(name: string): any;
  11525. /**
  11526. * Creates a new ActionManager from a JSON data
  11527. * @param parsedActions defines the JSON data to read from
  11528. * @param object defines the hosting mesh
  11529. * @param scene defines the hosting scene
  11530. */
  11531. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11532. /**
  11533. * Get a trigger name by index
  11534. * @param trigger defines the trigger index
  11535. * @returns a trigger name
  11536. */
  11537. static GetTriggerName(trigger: number): string;
  11538. }
  11539. }
  11540. declare module "babylonjs/Culling/ray" {
  11541. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11542. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11544. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11545. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11546. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11547. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11548. /**
  11549. * Class representing a ray with position and direction
  11550. */
  11551. export class Ray {
  11552. /** origin point */
  11553. origin: Vector3;
  11554. /** direction */
  11555. direction: Vector3;
  11556. /** length of the ray */
  11557. length: number;
  11558. private static readonly TmpVector3;
  11559. private _tmpRay;
  11560. /**
  11561. * Creates a new ray
  11562. * @param origin origin point
  11563. * @param direction direction
  11564. * @param length length of the ray
  11565. */
  11566. constructor(
  11567. /** origin point */
  11568. origin: Vector3,
  11569. /** direction */
  11570. direction: Vector3,
  11571. /** length of the ray */
  11572. length?: number);
  11573. /**
  11574. * Checks if the ray intersects a box
  11575. * @param minimum bound of the box
  11576. * @param maximum bound of the box
  11577. * @param intersectionTreshold extra extend to be added to the box in all direction
  11578. * @returns if the box was hit
  11579. */
  11580. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11581. /**
  11582. * Checks if the ray intersects a box
  11583. * @param box the bounding box to check
  11584. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11585. * @returns if the box was hit
  11586. */
  11587. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11588. /**
  11589. * If the ray hits a sphere
  11590. * @param sphere the bounding sphere to check
  11591. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11592. * @returns true if it hits the sphere
  11593. */
  11594. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11595. /**
  11596. * If the ray hits a triange
  11597. * @param vertex0 triangle vertex
  11598. * @param vertex1 triangle vertex
  11599. * @param vertex2 triangle vertex
  11600. * @returns intersection information if hit
  11601. */
  11602. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11603. /**
  11604. * Checks if ray intersects a plane
  11605. * @param plane the plane to check
  11606. * @returns the distance away it was hit
  11607. */
  11608. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11609. /**
  11610. * Checks if ray intersects a mesh
  11611. * @param mesh the mesh to check
  11612. * @param fastCheck if only the bounding box should checked
  11613. * @returns picking info of the intersecton
  11614. */
  11615. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11616. /**
  11617. * Checks if ray intersects a mesh
  11618. * @param meshes the meshes to check
  11619. * @param fastCheck if only the bounding box should checked
  11620. * @param results array to store result in
  11621. * @returns Array of picking infos
  11622. */
  11623. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11624. private _comparePickingInfo;
  11625. private static smallnum;
  11626. private static rayl;
  11627. /**
  11628. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11629. * @param sega the first point of the segment to test the intersection against
  11630. * @param segb the second point of the segment to test the intersection against
  11631. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11632. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11633. */
  11634. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11635. /**
  11636. * Update the ray from viewport position
  11637. * @param x position
  11638. * @param y y position
  11639. * @param viewportWidth viewport width
  11640. * @param viewportHeight viewport height
  11641. * @param world world matrix
  11642. * @param view view matrix
  11643. * @param projection projection matrix
  11644. * @returns this ray updated
  11645. */
  11646. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11647. /**
  11648. * Creates a ray with origin and direction of 0,0,0
  11649. * @returns the new ray
  11650. */
  11651. static Zero(): Ray;
  11652. /**
  11653. * Creates a new ray from screen space and viewport
  11654. * @param x position
  11655. * @param y y position
  11656. * @param viewportWidth viewport width
  11657. * @param viewportHeight viewport height
  11658. * @param world world matrix
  11659. * @param view view matrix
  11660. * @param projection projection matrix
  11661. * @returns new ray
  11662. */
  11663. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11664. /**
  11665. * 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
  11666. * transformed to the given world matrix.
  11667. * @param origin The origin point
  11668. * @param end The end point
  11669. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11670. * @returns the new ray
  11671. */
  11672. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11673. /**
  11674. * Transforms a ray by a matrix
  11675. * @param ray ray to transform
  11676. * @param matrix matrix to apply
  11677. * @returns the resulting new ray
  11678. */
  11679. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11680. /**
  11681. * Transforms a ray by a matrix
  11682. * @param ray ray to transform
  11683. * @param matrix matrix to apply
  11684. * @param result ray to store result in
  11685. */
  11686. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11687. /**
  11688. * Unproject a ray from screen space to object space
  11689. * @param sourceX defines the screen space x coordinate to use
  11690. * @param sourceY defines the screen space y coordinate to use
  11691. * @param viewportWidth defines the current width of the viewport
  11692. * @param viewportHeight defines the current height of the viewport
  11693. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11694. * @param view defines the view matrix to use
  11695. * @param projection defines the projection matrix to use
  11696. */
  11697. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11698. }
  11699. /**
  11700. * Type used to define predicate used to select faces when a mesh intersection is detected
  11701. */
  11702. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11703. module "babylonjs/scene" {
  11704. interface Scene {
  11705. /** @hidden */
  11706. _tempPickingRay: Nullable<Ray>;
  11707. /** @hidden */
  11708. _cachedRayForTransform: Ray;
  11709. /** @hidden */
  11710. _pickWithRayInverseMatrix: Matrix;
  11711. /** @hidden */
  11712. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11713. /** @hidden */
  11714. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11715. }
  11716. }
  11717. }
  11718. declare module "babylonjs/sceneComponent" {
  11719. import { Scene } from "babylonjs/scene";
  11720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11721. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11722. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11723. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11724. import { Nullable } from "babylonjs/types";
  11725. import { Camera } from "babylonjs/Cameras/camera";
  11726. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11727. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11728. import { AbstractScene } from "babylonjs/abstractScene";
  11729. /**
  11730. * Groups all the scene component constants in one place to ease maintenance.
  11731. * @hidden
  11732. */
  11733. export class SceneComponentConstants {
  11734. static readonly NAME_EFFECTLAYER: string;
  11735. static readonly NAME_LAYER: string;
  11736. static readonly NAME_LENSFLARESYSTEM: string;
  11737. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11738. static readonly NAME_PARTICLESYSTEM: string;
  11739. static readonly NAME_GAMEPAD: string;
  11740. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11741. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11742. static readonly NAME_DEPTHRENDERER: string;
  11743. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11744. static readonly NAME_SPRITE: string;
  11745. static readonly NAME_OUTLINERENDERER: string;
  11746. static readonly NAME_PROCEDURALTEXTURE: string;
  11747. static readonly NAME_SHADOWGENERATOR: string;
  11748. static readonly NAME_OCTREE: string;
  11749. static readonly NAME_PHYSICSENGINE: string;
  11750. static readonly NAME_AUDIO: string;
  11751. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11752. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11753. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11754. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11755. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11756. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11757. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11758. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11759. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11760. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11761. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11762. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11763. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11764. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11765. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11766. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11767. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11768. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11769. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11770. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11771. static readonly STEP_AFTERRENDER_AUDIO: number;
  11772. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11773. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11774. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11775. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11776. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11777. static readonly STEP_POINTERMOVE_SPRITE: number;
  11778. static readonly STEP_POINTERDOWN_SPRITE: number;
  11779. static readonly STEP_POINTERUP_SPRITE: number;
  11780. }
  11781. /**
  11782. * This represents a scene component.
  11783. *
  11784. * This is used to decouple the dependency the scene is having on the different workloads like
  11785. * layers, post processes...
  11786. */
  11787. export interface ISceneComponent {
  11788. /**
  11789. * The name of the component. Each component must have a unique name.
  11790. */
  11791. name: string;
  11792. /**
  11793. * The scene the component belongs to.
  11794. */
  11795. scene: Scene;
  11796. /**
  11797. * Register the component to one instance of a scene.
  11798. */
  11799. register(): void;
  11800. /**
  11801. * Rebuilds the elements related to this component in case of
  11802. * context lost for instance.
  11803. */
  11804. rebuild(): void;
  11805. /**
  11806. * Disposes the component and the associated ressources.
  11807. */
  11808. dispose(): void;
  11809. }
  11810. /**
  11811. * This represents a SERIALIZABLE scene component.
  11812. *
  11813. * This extends Scene Component to add Serialization methods on top.
  11814. */
  11815. export interface ISceneSerializableComponent extends ISceneComponent {
  11816. /**
  11817. * Adds all the element from the container to the scene
  11818. * @param container the container holding the elements
  11819. */
  11820. addFromContainer(container: AbstractScene): void;
  11821. /**
  11822. * Removes all the elements in the container from the scene
  11823. * @param container contains the elements to remove
  11824. * @param dispose if the removed element should be disposed (default: false)
  11825. */
  11826. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11827. /**
  11828. * Serializes the component data to the specified json object
  11829. * @param serializationObject The object to serialize to
  11830. */
  11831. serialize(serializationObject: any): void;
  11832. }
  11833. /**
  11834. * Strong typing of a Mesh related stage step action
  11835. */
  11836. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11837. /**
  11838. * Strong typing of a Evaluate Sub Mesh related stage step action
  11839. */
  11840. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11841. /**
  11842. * Strong typing of a Active Mesh related stage step action
  11843. */
  11844. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11845. /**
  11846. * Strong typing of a Camera related stage step action
  11847. */
  11848. export type CameraStageAction = (camera: Camera) => void;
  11849. /**
  11850. * Strong typing of a Camera Frame buffer related stage step action
  11851. */
  11852. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11853. /**
  11854. * Strong typing of a Render Target related stage step action
  11855. */
  11856. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11857. /**
  11858. * Strong typing of a RenderingGroup related stage step action
  11859. */
  11860. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11861. /**
  11862. * Strong typing of a Mesh Render related stage step action
  11863. */
  11864. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11865. /**
  11866. * Strong typing of a simple stage step action
  11867. */
  11868. export type SimpleStageAction = () => void;
  11869. /**
  11870. * Strong typing of a render target action.
  11871. */
  11872. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11873. /**
  11874. * Strong typing of a pointer move action.
  11875. */
  11876. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11877. /**
  11878. * Strong typing of a pointer up/down action.
  11879. */
  11880. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11881. /**
  11882. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11883. * @hidden
  11884. */
  11885. export class Stage<T extends Function> extends Array<{
  11886. index: number;
  11887. component: ISceneComponent;
  11888. action: T;
  11889. }> {
  11890. /**
  11891. * Hide ctor from the rest of the world.
  11892. * @param items The items to add.
  11893. */
  11894. private constructor();
  11895. /**
  11896. * Creates a new Stage.
  11897. * @returns A new instance of a Stage
  11898. */
  11899. static Create<T extends Function>(): Stage<T>;
  11900. /**
  11901. * Registers a step in an ordered way in the targeted stage.
  11902. * @param index Defines the position to register the step in
  11903. * @param component Defines the component attached to the step
  11904. * @param action Defines the action to launch during the step
  11905. */
  11906. registerStep(index: number, component: ISceneComponent, action: T): void;
  11907. /**
  11908. * Clears all the steps from the stage.
  11909. */
  11910. clear(): void;
  11911. }
  11912. }
  11913. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11914. import { Nullable } from "babylonjs/types";
  11915. import { Observable } from "babylonjs/Misc/observable";
  11916. import { Scene } from "babylonjs/scene";
  11917. import { Sprite } from "babylonjs/Sprites/sprite";
  11918. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11919. import { Ray } from "babylonjs/Culling/ray";
  11920. import { Camera } from "babylonjs/Cameras/camera";
  11921. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11922. import { ISceneComponent } from "babylonjs/sceneComponent";
  11923. module "babylonjs/scene" {
  11924. interface Scene {
  11925. /** @hidden */
  11926. _pointerOverSprite: Nullable<Sprite>;
  11927. /** @hidden */
  11928. _pickedDownSprite: Nullable<Sprite>;
  11929. /** @hidden */
  11930. _tempSpritePickingRay: Nullable<Ray>;
  11931. /**
  11932. * All of the sprite managers added to this scene
  11933. * @see http://doc.babylonjs.com/babylon101/sprites
  11934. */
  11935. spriteManagers: Array<ISpriteManager>;
  11936. /**
  11937. * An event triggered when sprites rendering is about to start
  11938. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11939. */
  11940. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11941. /**
  11942. * An event triggered when sprites rendering is done
  11943. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11944. */
  11945. onAfterSpritesRenderingObservable: Observable<Scene>;
  11946. /** @hidden */
  11947. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11948. /** Launch a ray to try to pick a sprite in the scene
  11949. * @param x position on screen
  11950. * @param y position on screen
  11951. * @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
  11952. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11953. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11954. * @returns a PickingInfo
  11955. */
  11956. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11957. /** Use the given ray to pick a sprite in the scene
  11958. * @param ray The ray (in world space) to use to pick meshes
  11959. * @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
  11960. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11961. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11962. * @returns a PickingInfo
  11963. */
  11964. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11965. /**
  11966. * Force the sprite under the pointer
  11967. * @param sprite defines the sprite to use
  11968. */
  11969. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11970. /**
  11971. * Gets the sprite under the pointer
  11972. * @returns a Sprite or null if no sprite is under the pointer
  11973. */
  11974. getPointerOverSprite(): Nullable<Sprite>;
  11975. }
  11976. }
  11977. /**
  11978. * Defines the sprite scene component responsible to manage sprites
  11979. * in a given scene.
  11980. */
  11981. export class SpriteSceneComponent implements ISceneComponent {
  11982. /**
  11983. * The component name helpfull to identify the component in the list of scene components.
  11984. */
  11985. readonly name: string;
  11986. /**
  11987. * The scene the component belongs to.
  11988. */
  11989. scene: Scene;
  11990. /** @hidden */
  11991. private _spritePredicate;
  11992. /**
  11993. * Creates a new instance of the component for the given scene
  11994. * @param scene Defines the scene to register the component in
  11995. */
  11996. constructor(scene: Scene);
  11997. /**
  11998. * Registers the component in a given scene
  11999. */
  12000. register(): void;
  12001. /**
  12002. * Rebuilds the elements related to this component in case of
  12003. * context lost for instance.
  12004. */
  12005. rebuild(): void;
  12006. /**
  12007. * Disposes the component and the associated ressources.
  12008. */
  12009. dispose(): void;
  12010. private _pickSpriteButKeepRay;
  12011. private _pointerMove;
  12012. private _pointerDown;
  12013. private _pointerUp;
  12014. }
  12015. }
  12016. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12017. /** @hidden */
  12018. export var fogFragmentDeclaration: {
  12019. name: string;
  12020. shader: string;
  12021. };
  12022. }
  12023. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12024. /** @hidden */
  12025. export var fogFragment: {
  12026. name: string;
  12027. shader: string;
  12028. };
  12029. }
  12030. declare module "babylonjs/Shaders/sprites.fragment" {
  12031. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12032. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12033. /** @hidden */
  12034. export var spritesPixelShader: {
  12035. name: string;
  12036. shader: string;
  12037. };
  12038. }
  12039. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12040. /** @hidden */
  12041. export var fogVertexDeclaration: {
  12042. name: string;
  12043. shader: string;
  12044. };
  12045. }
  12046. declare module "babylonjs/Shaders/sprites.vertex" {
  12047. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12048. /** @hidden */
  12049. export var spritesVertexShader: {
  12050. name: string;
  12051. shader: string;
  12052. };
  12053. }
  12054. declare module "babylonjs/Sprites/spriteManager" {
  12055. import { IDisposable, Scene } from "babylonjs/scene";
  12056. import { Nullable } from "babylonjs/types";
  12057. import { Observable } from "babylonjs/Misc/observable";
  12058. import { Sprite } from "babylonjs/Sprites/sprite";
  12059. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12060. import { Camera } from "babylonjs/Cameras/camera";
  12061. import { Texture } from "babylonjs/Materials/Textures/texture";
  12062. import "babylonjs/Shaders/sprites.fragment";
  12063. import "babylonjs/Shaders/sprites.vertex";
  12064. import { Ray } from "babylonjs/Culling/ray";
  12065. /**
  12066. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12067. */
  12068. export interface ISpriteManager extends IDisposable {
  12069. /**
  12070. * Restricts the camera to viewing objects with the same layerMask.
  12071. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12072. */
  12073. layerMask: number;
  12074. /**
  12075. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12076. */
  12077. isPickable: boolean;
  12078. /**
  12079. * Specifies the rendering group id for this mesh (0 by default)
  12080. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12081. */
  12082. renderingGroupId: number;
  12083. /**
  12084. * Defines the list of sprites managed by the manager.
  12085. */
  12086. sprites: Array<Sprite>;
  12087. /**
  12088. * Tests the intersection of a sprite with a specific ray.
  12089. * @param ray The ray we are sending to test the collision
  12090. * @param camera The camera space we are sending rays in
  12091. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12092. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12093. * @returns picking info or null.
  12094. */
  12095. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12096. /**
  12097. * Renders the list of sprites on screen.
  12098. */
  12099. render(): void;
  12100. }
  12101. /**
  12102. * Class used to manage multiple sprites on the same spritesheet
  12103. * @see http://doc.babylonjs.com/babylon101/sprites
  12104. */
  12105. export class SpriteManager implements ISpriteManager {
  12106. /** defines the manager's name */
  12107. name: string;
  12108. /** Gets the list of sprites */
  12109. sprites: Sprite[];
  12110. /** Gets or sets the rendering group id (0 by default) */
  12111. renderingGroupId: number;
  12112. /** Gets or sets camera layer mask */
  12113. layerMask: number;
  12114. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12115. fogEnabled: boolean;
  12116. /** Gets or sets a boolean indicating if the sprites are pickable */
  12117. isPickable: boolean;
  12118. /** Defines the default width of a cell in the spritesheet */
  12119. cellWidth: number;
  12120. /** Defines the default height of a cell in the spritesheet */
  12121. cellHeight: number;
  12122. /**
  12123. * An event triggered when the manager is disposed.
  12124. */
  12125. onDisposeObservable: Observable<SpriteManager>;
  12126. private _onDisposeObserver;
  12127. /**
  12128. * Callback called when the manager is disposed
  12129. */
  12130. onDispose: () => void;
  12131. private _capacity;
  12132. private _spriteTexture;
  12133. private _epsilon;
  12134. private _scene;
  12135. private _vertexData;
  12136. private _buffer;
  12137. private _vertexBuffers;
  12138. private _indexBuffer;
  12139. private _effectBase;
  12140. private _effectFog;
  12141. /**
  12142. * Gets or sets the spritesheet texture
  12143. */
  12144. texture: Texture;
  12145. /**
  12146. * Creates a new sprite manager
  12147. * @param name defines the manager's name
  12148. * @param imgUrl defines the sprite sheet url
  12149. * @param capacity defines the maximum allowed number of sprites
  12150. * @param cellSize defines the size of a sprite cell
  12151. * @param scene defines the hosting scene
  12152. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12153. * @param samplingMode defines the smapling mode to use with spritesheet
  12154. */
  12155. constructor(
  12156. /** defines the manager's name */
  12157. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12158. private _appendSpriteVertex;
  12159. /**
  12160. * Intersects the sprites with a ray
  12161. * @param ray defines the ray to intersect with
  12162. * @param camera defines the current active camera
  12163. * @param predicate defines a predicate used to select candidate sprites
  12164. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12165. * @returns null if no hit or a PickingInfo
  12166. */
  12167. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12168. /**
  12169. * Render all child sprites
  12170. */
  12171. render(): void;
  12172. /**
  12173. * Release associated resources
  12174. */
  12175. dispose(): void;
  12176. }
  12177. }
  12178. declare module "babylonjs/Sprites/sprite" {
  12179. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12180. import { Nullable } from "babylonjs/types";
  12181. import { ActionManager } from "babylonjs/Actions/actionManager";
  12182. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12183. /**
  12184. * Class used to represent a sprite
  12185. * @see http://doc.babylonjs.com/babylon101/sprites
  12186. */
  12187. export class Sprite {
  12188. /** defines the name */
  12189. name: string;
  12190. /** Gets or sets the current world position */
  12191. position: Vector3;
  12192. /** Gets or sets the main color */
  12193. color: Color4;
  12194. /** Gets or sets the width */
  12195. width: number;
  12196. /** Gets or sets the height */
  12197. height: number;
  12198. /** Gets or sets rotation angle */
  12199. angle: number;
  12200. /** Gets or sets the cell index in the sprite sheet */
  12201. cellIndex: number;
  12202. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12203. invertU: number;
  12204. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12205. invertV: number;
  12206. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12207. disposeWhenFinishedAnimating: boolean;
  12208. /** Gets the list of attached animations */
  12209. animations: Animation[];
  12210. /** Gets or sets a boolean indicating if the sprite can be picked */
  12211. isPickable: boolean;
  12212. /**
  12213. * Gets or sets the associated action manager
  12214. */
  12215. actionManager: Nullable<ActionManager>;
  12216. private _animationStarted;
  12217. private _loopAnimation;
  12218. private _fromIndex;
  12219. private _toIndex;
  12220. private _delay;
  12221. private _direction;
  12222. private _manager;
  12223. private _time;
  12224. private _onAnimationEnd;
  12225. /**
  12226. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12227. */
  12228. isVisible: boolean;
  12229. /**
  12230. * Gets or sets the sprite size
  12231. */
  12232. size: number;
  12233. /**
  12234. * Creates a new Sprite
  12235. * @param name defines the name
  12236. * @param manager defines the manager
  12237. */
  12238. constructor(
  12239. /** defines the name */
  12240. name: string, manager: ISpriteManager);
  12241. /**
  12242. * Starts an animation
  12243. * @param from defines the initial key
  12244. * @param to defines the end key
  12245. * @param loop defines if the animation must loop
  12246. * @param delay defines the start delay (in ms)
  12247. * @param onAnimationEnd defines a callback to call when animation ends
  12248. */
  12249. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12250. /** Stops current animation (if any) */
  12251. stopAnimation(): void;
  12252. /** @hidden */
  12253. _animate(deltaTime: number): void;
  12254. /** Release associated resources */
  12255. dispose(): void;
  12256. }
  12257. }
  12258. declare module "babylonjs/Collisions/pickingInfo" {
  12259. import { Nullable } from "babylonjs/types";
  12260. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12262. import { Sprite } from "babylonjs/Sprites/sprite";
  12263. import { Ray } from "babylonjs/Culling/ray";
  12264. /**
  12265. * Information about the result of picking within a scene
  12266. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12267. */
  12268. export class PickingInfo {
  12269. /** @hidden */
  12270. _pickingUnavailable: boolean;
  12271. /**
  12272. * If the pick collided with an object
  12273. */
  12274. hit: boolean;
  12275. /**
  12276. * Distance away where the pick collided
  12277. */
  12278. distance: number;
  12279. /**
  12280. * The location of pick collision
  12281. */
  12282. pickedPoint: Nullable<Vector3>;
  12283. /**
  12284. * The mesh corresponding the the pick collision
  12285. */
  12286. pickedMesh: Nullable<AbstractMesh>;
  12287. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12288. bu: number;
  12289. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12290. bv: number;
  12291. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12292. faceId: number;
  12293. /** Id of the the submesh that was picked */
  12294. subMeshId: number;
  12295. /** If a sprite was picked, this will be the sprite the pick collided with */
  12296. pickedSprite: Nullable<Sprite>;
  12297. /**
  12298. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12299. */
  12300. originMesh: Nullable<AbstractMesh>;
  12301. /**
  12302. * The ray that was used to perform the picking.
  12303. */
  12304. ray: Nullable<Ray>;
  12305. /**
  12306. * Gets the normal correspodning to the face the pick collided with
  12307. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12308. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12309. * @returns The normal correspodning to the face the pick collided with
  12310. */
  12311. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12312. /**
  12313. * Gets the texture coordinates of where the pick occured
  12314. * @returns the vector containing the coordnates of the texture
  12315. */
  12316. getTextureCoordinates(): Nullable<Vector2>;
  12317. }
  12318. }
  12319. declare module "babylonjs/Events/pointerEvents" {
  12320. import { Nullable } from "babylonjs/types";
  12321. import { Vector2 } from "babylonjs/Maths/math";
  12322. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12323. import { Ray } from "babylonjs/Culling/ray";
  12324. /**
  12325. * Gather the list of pointer event types as constants.
  12326. */
  12327. export class PointerEventTypes {
  12328. /**
  12329. * 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.
  12330. */
  12331. static readonly POINTERDOWN: number;
  12332. /**
  12333. * The pointerup event is fired when a pointer is no longer active.
  12334. */
  12335. static readonly POINTERUP: number;
  12336. /**
  12337. * The pointermove event is fired when a pointer changes coordinates.
  12338. */
  12339. static readonly POINTERMOVE: number;
  12340. /**
  12341. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12342. */
  12343. static readonly POINTERWHEEL: number;
  12344. /**
  12345. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12346. */
  12347. static readonly POINTERPICK: number;
  12348. /**
  12349. * The pointertap event is fired when a the object has been touched and released without drag.
  12350. */
  12351. static readonly POINTERTAP: number;
  12352. /**
  12353. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12354. */
  12355. static readonly POINTERDOUBLETAP: number;
  12356. }
  12357. /**
  12358. * Base class of pointer info types.
  12359. */
  12360. export class PointerInfoBase {
  12361. /**
  12362. * Defines the type of event (PointerEventTypes)
  12363. */
  12364. type: number;
  12365. /**
  12366. * Defines the related dom event
  12367. */
  12368. event: PointerEvent | MouseWheelEvent;
  12369. /**
  12370. * Instantiates the base class of pointers info.
  12371. * @param type Defines the type of event (PointerEventTypes)
  12372. * @param event Defines the related dom event
  12373. */
  12374. constructor(
  12375. /**
  12376. * Defines the type of event (PointerEventTypes)
  12377. */
  12378. type: number,
  12379. /**
  12380. * Defines the related dom event
  12381. */
  12382. event: PointerEvent | MouseWheelEvent);
  12383. }
  12384. /**
  12385. * This class is used to store pointer related info for the onPrePointerObservable event.
  12386. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12387. */
  12388. export class PointerInfoPre extends PointerInfoBase {
  12389. /**
  12390. * Ray from a pointer if availible (eg. 6dof controller)
  12391. */
  12392. ray: Nullable<Ray>;
  12393. /**
  12394. * Defines the local position of the pointer on the canvas.
  12395. */
  12396. localPosition: Vector2;
  12397. /**
  12398. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12399. */
  12400. skipOnPointerObservable: boolean;
  12401. /**
  12402. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12403. * @param type Defines the type of event (PointerEventTypes)
  12404. * @param event Defines the related dom event
  12405. * @param localX Defines the local x coordinates of the pointer when the event occured
  12406. * @param localY Defines the local y coordinates of the pointer when the event occured
  12407. */
  12408. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12409. }
  12410. /**
  12411. * This type contains all the data related to a pointer event in Babylon.js.
  12412. * 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.
  12413. */
  12414. export class PointerInfo extends PointerInfoBase {
  12415. /**
  12416. * Defines the picking info associated to the info (if any)\
  12417. */
  12418. pickInfo: Nullable<PickingInfo>;
  12419. /**
  12420. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12421. * @param type Defines the type of event (PointerEventTypes)
  12422. * @param event Defines the related dom event
  12423. * @param pickInfo Defines the picking info associated to the info (if any)\
  12424. */
  12425. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12426. /**
  12427. * Defines the picking info associated to the info (if any)\
  12428. */
  12429. pickInfo: Nullable<PickingInfo>);
  12430. }
  12431. /**
  12432. * Data relating to a touch event on the screen.
  12433. */
  12434. export interface PointerTouch {
  12435. /**
  12436. * X coordinate of touch.
  12437. */
  12438. x: number;
  12439. /**
  12440. * Y coordinate of touch.
  12441. */
  12442. y: number;
  12443. /**
  12444. * Id of touch. Unique for each finger.
  12445. */
  12446. pointerId: number;
  12447. /**
  12448. * Event type passed from DOM.
  12449. */
  12450. type: any;
  12451. }
  12452. }
  12453. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12454. import { Observable } from "babylonjs/Misc/observable";
  12455. import { Nullable } from "babylonjs/types";
  12456. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12457. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12458. /**
  12459. * Manage the mouse inputs to control the movement of a free camera.
  12460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12461. */
  12462. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12463. /**
  12464. * Define if touch is enabled in the mouse input
  12465. */
  12466. touchEnabled: boolean;
  12467. /**
  12468. * Defines the camera the input is attached to.
  12469. */
  12470. camera: FreeCamera;
  12471. /**
  12472. * Defines the buttons associated with the input to handle camera move.
  12473. */
  12474. buttons: number[];
  12475. /**
  12476. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12477. */
  12478. angularSensibility: number;
  12479. private _pointerInput;
  12480. private _onMouseMove;
  12481. private _observer;
  12482. private previousPosition;
  12483. /**
  12484. * Observable for when a pointer move event occurs containing the move offset
  12485. */
  12486. onPointerMovedObservable: Observable<{
  12487. offsetX: number;
  12488. offsetY: number;
  12489. }>;
  12490. /**
  12491. * @hidden
  12492. * If the camera should be rotated automatically based on pointer movement
  12493. */
  12494. _allowCameraRotation: boolean;
  12495. /**
  12496. * Manage the mouse inputs to control the movement of a free camera.
  12497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12498. * @param touchEnabled Defines if touch is enabled or not
  12499. */
  12500. constructor(
  12501. /**
  12502. * Define if touch is enabled in the mouse input
  12503. */
  12504. touchEnabled?: boolean);
  12505. /**
  12506. * Attach the input controls to a specific dom element to get the input from.
  12507. * @param element Defines the element the controls should be listened from
  12508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12509. */
  12510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12511. /**
  12512. * Called on JS contextmenu event.
  12513. * Override this method to provide functionality.
  12514. */
  12515. protected onContextMenu(evt: PointerEvent): void;
  12516. /**
  12517. * Detach the current controls from the specified dom element.
  12518. * @param element Defines the element to stop listening the inputs from
  12519. */
  12520. detachControl(element: Nullable<HTMLElement>): void;
  12521. /**
  12522. * Gets the class name of the current intput.
  12523. * @returns the class name
  12524. */
  12525. getClassName(): string;
  12526. /**
  12527. * Get the friendly name associated with the input class.
  12528. * @returns the input friendly name
  12529. */
  12530. getSimpleName(): string;
  12531. }
  12532. }
  12533. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12534. import { Nullable } from "babylonjs/types";
  12535. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12536. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12537. /**
  12538. * Manage the touch inputs to control the movement of a free camera.
  12539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12540. */
  12541. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12542. /**
  12543. * Defines the camera the input is attached to.
  12544. */
  12545. camera: FreeCamera;
  12546. /**
  12547. * Defines the touch sensibility for rotation.
  12548. * The higher the faster.
  12549. */
  12550. touchAngularSensibility: number;
  12551. /**
  12552. * Defines the touch sensibility for move.
  12553. * The higher the faster.
  12554. */
  12555. touchMoveSensibility: number;
  12556. private _offsetX;
  12557. private _offsetY;
  12558. private _pointerPressed;
  12559. private _pointerInput;
  12560. private _observer;
  12561. private _onLostFocus;
  12562. /**
  12563. * Attach the input controls to a specific dom element to get the input from.
  12564. * @param element Defines the element the controls should be listened from
  12565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12566. */
  12567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12568. /**
  12569. * Detach the current controls from the specified dom element.
  12570. * @param element Defines the element to stop listening the inputs from
  12571. */
  12572. detachControl(element: Nullable<HTMLElement>): void;
  12573. /**
  12574. * Update the current camera state depending on the inputs that have been used this frame.
  12575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12576. */
  12577. checkInputs(): void;
  12578. /**
  12579. * Gets the class name of the current intput.
  12580. * @returns the class name
  12581. */
  12582. getClassName(): string;
  12583. /**
  12584. * Get the friendly name associated with the input class.
  12585. * @returns the input friendly name
  12586. */
  12587. getSimpleName(): string;
  12588. }
  12589. }
  12590. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12591. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12592. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12593. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12594. import { Nullable } from "babylonjs/types";
  12595. /**
  12596. * Default Inputs manager for the FreeCamera.
  12597. * It groups all the default supported inputs for ease of use.
  12598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12599. */
  12600. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12601. /**
  12602. * @hidden
  12603. */
  12604. _mouseInput: Nullable<FreeCameraMouseInput>;
  12605. /**
  12606. * Instantiates a new FreeCameraInputsManager.
  12607. * @param camera Defines the camera the inputs belong to
  12608. */
  12609. constructor(camera: FreeCamera);
  12610. /**
  12611. * Add keyboard input support to the input manager.
  12612. * @returns the current input manager
  12613. */
  12614. addKeyboard(): FreeCameraInputsManager;
  12615. /**
  12616. * Add mouse input support to the input manager.
  12617. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12618. * @returns the current input manager
  12619. */
  12620. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12621. /**
  12622. * Removes the mouse input support from the manager
  12623. * @returns the current input manager
  12624. */
  12625. removeMouse(): FreeCameraInputsManager;
  12626. /**
  12627. * Add touch input support to the input manager.
  12628. * @returns the current input manager
  12629. */
  12630. addTouch(): FreeCameraInputsManager;
  12631. /**
  12632. * Remove all attached input methods from a camera
  12633. */
  12634. clear(): void;
  12635. }
  12636. }
  12637. declare module "babylonjs/Cameras/freeCamera" {
  12638. import { Vector3 } from "babylonjs/Maths/math";
  12639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12640. import { Scene } from "babylonjs/scene";
  12641. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12642. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12643. /**
  12644. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12645. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12646. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12647. */
  12648. export class FreeCamera extends TargetCamera {
  12649. /**
  12650. * Define the collision ellipsoid of the camera.
  12651. * This is helpful to simulate a camera body like the player body around the camera
  12652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12653. */
  12654. ellipsoid: Vector3;
  12655. /**
  12656. * Define an offset for the position of the ellipsoid around the camera.
  12657. * This can be helpful to determine the center of the body near the gravity center of the body
  12658. * instead of its head.
  12659. */
  12660. ellipsoidOffset: Vector3;
  12661. /**
  12662. * Enable or disable collisions of the camera with the rest of the scene objects.
  12663. */
  12664. checkCollisions: boolean;
  12665. /**
  12666. * Enable or disable gravity on the camera.
  12667. */
  12668. applyGravity: boolean;
  12669. /**
  12670. * Define the input manager associated to the camera.
  12671. */
  12672. inputs: FreeCameraInputsManager;
  12673. /**
  12674. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12675. * Higher values reduce sensitivity.
  12676. */
  12677. /**
  12678. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12679. * Higher values reduce sensitivity.
  12680. */
  12681. angularSensibility: number;
  12682. /**
  12683. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12684. */
  12685. keysUp: number[];
  12686. /**
  12687. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12688. */
  12689. keysDown: number[];
  12690. /**
  12691. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12692. */
  12693. keysLeft: number[];
  12694. /**
  12695. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12696. */
  12697. keysRight: number[];
  12698. /**
  12699. * Event raised when the camera collide with a mesh in the scene.
  12700. */
  12701. onCollide: (collidedMesh: AbstractMesh) => void;
  12702. private _collider;
  12703. private _needMoveForGravity;
  12704. private _oldPosition;
  12705. private _diffPosition;
  12706. private _newPosition;
  12707. /** @hidden */
  12708. _localDirection: Vector3;
  12709. /** @hidden */
  12710. _transformedDirection: Vector3;
  12711. /**
  12712. * Instantiates a Free Camera.
  12713. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12714. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12715. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12716. * @param name Define the name of the camera in the scene
  12717. * @param position Define the start position of the camera in the scene
  12718. * @param scene Define the scene the camera belongs to
  12719. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12720. */
  12721. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12722. /**
  12723. * Attached controls to the current camera.
  12724. * @param element Defines the element the controls should be listened from
  12725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12726. */
  12727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12728. /**
  12729. * Detach the current controls from the camera.
  12730. * The camera will stop reacting to inputs.
  12731. * @param element Defines the element to stop listening the inputs from
  12732. */
  12733. detachControl(element: HTMLElement): void;
  12734. private _collisionMask;
  12735. /**
  12736. * Define a collision mask to limit the list of object the camera can collide with
  12737. */
  12738. collisionMask: number;
  12739. /** @hidden */
  12740. _collideWithWorld(displacement: Vector3): void;
  12741. private _onCollisionPositionChange;
  12742. /** @hidden */
  12743. _checkInputs(): void;
  12744. /** @hidden */
  12745. _decideIfNeedsToMove(): boolean;
  12746. /** @hidden */
  12747. _updatePosition(): void;
  12748. /**
  12749. * Destroy the camera and release the current resources hold by it.
  12750. */
  12751. dispose(): void;
  12752. /**
  12753. * Gets the current object class name.
  12754. * @return the class name
  12755. */
  12756. getClassName(): string;
  12757. }
  12758. }
  12759. declare module "babylonjs/Gamepads/gamepad" {
  12760. import { Observable } from "babylonjs/Misc/observable";
  12761. /**
  12762. * Represents a gamepad control stick position
  12763. */
  12764. export class StickValues {
  12765. /**
  12766. * The x component of the control stick
  12767. */
  12768. x: number;
  12769. /**
  12770. * The y component of the control stick
  12771. */
  12772. y: number;
  12773. /**
  12774. * Initializes the gamepad x and y control stick values
  12775. * @param x The x component of the gamepad control stick value
  12776. * @param y The y component of the gamepad control stick value
  12777. */
  12778. constructor(
  12779. /**
  12780. * The x component of the control stick
  12781. */
  12782. x: number,
  12783. /**
  12784. * The y component of the control stick
  12785. */
  12786. y: number);
  12787. }
  12788. /**
  12789. * An interface which manages callbacks for gamepad button changes
  12790. */
  12791. export interface GamepadButtonChanges {
  12792. /**
  12793. * Called when a gamepad has been changed
  12794. */
  12795. changed: boolean;
  12796. /**
  12797. * Called when a gamepad press event has been triggered
  12798. */
  12799. pressChanged: boolean;
  12800. /**
  12801. * Called when a touch event has been triggered
  12802. */
  12803. touchChanged: boolean;
  12804. /**
  12805. * Called when a value has changed
  12806. */
  12807. valueChanged: boolean;
  12808. }
  12809. /**
  12810. * Represents a gamepad
  12811. */
  12812. export class Gamepad {
  12813. /**
  12814. * The id of the gamepad
  12815. */
  12816. id: string;
  12817. /**
  12818. * The index of the gamepad
  12819. */
  12820. index: number;
  12821. /**
  12822. * The browser gamepad
  12823. */
  12824. browserGamepad: any;
  12825. /**
  12826. * Specifies what type of gamepad this represents
  12827. */
  12828. type: number;
  12829. private _leftStick;
  12830. private _rightStick;
  12831. /** @hidden */
  12832. _isConnected: boolean;
  12833. private _leftStickAxisX;
  12834. private _leftStickAxisY;
  12835. private _rightStickAxisX;
  12836. private _rightStickAxisY;
  12837. /**
  12838. * Triggered when the left control stick has been changed
  12839. */
  12840. private _onleftstickchanged;
  12841. /**
  12842. * Triggered when the right control stick has been changed
  12843. */
  12844. private _onrightstickchanged;
  12845. /**
  12846. * Represents a gamepad controller
  12847. */
  12848. static GAMEPAD: number;
  12849. /**
  12850. * Represents a generic controller
  12851. */
  12852. static GENERIC: number;
  12853. /**
  12854. * Represents an XBox controller
  12855. */
  12856. static XBOX: number;
  12857. /**
  12858. * Represents a pose-enabled controller
  12859. */
  12860. static POSE_ENABLED: number;
  12861. /**
  12862. * Specifies whether the left control stick should be Y-inverted
  12863. */
  12864. protected _invertLeftStickY: boolean;
  12865. /**
  12866. * Specifies if the gamepad has been connected
  12867. */
  12868. readonly isConnected: boolean;
  12869. /**
  12870. * Initializes the gamepad
  12871. * @param id The id of the gamepad
  12872. * @param index The index of the gamepad
  12873. * @param browserGamepad The browser gamepad
  12874. * @param leftStickX The x component of the left joystick
  12875. * @param leftStickY The y component of the left joystick
  12876. * @param rightStickX The x component of the right joystick
  12877. * @param rightStickY The y component of the right joystick
  12878. */
  12879. constructor(
  12880. /**
  12881. * The id of the gamepad
  12882. */
  12883. id: string,
  12884. /**
  12885. * The index of the gamepad
  12886. */
  12887. index: number,
  12888. /**
  12889. * The browser gamepad
  12890. */
  12891. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12892. /**
  12893. * Callback triggered when the left joystick has changed
  12894. * @param callback
  12895. */
  12896. onleftstickchanged(callback: (values: StickValues) => void): void;
  12897. /**
  12898. * Callback triggered when the right joystick has changed
  12899. * @param callback
  12900. */
  12901. onrightstickchanged(callback: (values: StickValues) => void): void;
  12902. /**
  12903. * Gets the left joystick
  12904. */
  12905. /**
  12906. * Sets the left joystick values
  12907. */
  12908. leftStick: StickValues;
  12909. /**
  12910. * Gets the right joystick
  12911. */
  12912. /**
  12913. * Sets the right joystick value
  12914. */
  12915. rightStick: StickValues;
  12916. /**
  12917. * Updates the gamepad joystick positions
  12918. */
  12919. update(): void;
  12920. /**
  12921. * Disposes the gamepad
  12922. */
  12923. dispose(): void;
  12924. }
  12925. /**
  12926. * Represents a generic gamepad
  12927. */
  12928. export class GenericPad extends Gamepad {
  12929. private _buttons;
  12930. private _onbuttondown;
  12931. private _onbuttonup;
  12932. /**
  12933. * Observable triggered when a button has been pressed
  12934. */
  12935. onButtonDownObservable: Observable<number>;
  12936. /**
  12937. * Observable triggered when a button has been released
  12938. */
  12939. onButtonUpObservable: Observable<number>;
  12940. /**
  12941. * Callback triggered when a button has been pressed
  12942. * @param callback Called when a button has been pressed
  12943. */
  12944. onbuttondown(callback: (buttonPressed: number) => void): void;
  12945. /**
  12946. * Callback triggered when a button has been released
  12947. * @param callback Called when a button has been released
  12948. */
  12949. onbuttonup(callback: (buttonReleased: number) => void): void;
  12950. /**
  12951. * Initializes the generic gamepad
  12952. * @param id The id of the generic gamepad
  12953. * @param index The index of the generic gamepad
  12954. * @param browserGamepad The browser gamepad
  12955. */
  12956. constructor(id: string, index: number, browserGamepad: any);
  12957. private _setButtonValue;
  12958. /**
  12959. * Updates the generic gamepad
  12960. */
  12961. update(): void;
  12962. /**
  12963. * Disposes the generic gamepad
  12964. */
  12965. dispose(): void;
  12966. }
  12967. }
  12968. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12969. import { Observable } from "babylonjs/Misc/observable";
  12970. import { Nullable } from "babylonjs/types";
  12971. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12972. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12974. import { Ray } from "babylonjs/Culling/ray";
  12975. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12976. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12977. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12978. /**
  12979. * Defines the types of pose enabled controllers that are supported
  12980. */
  12981. export enum PoseEnabledControllerType {
  12982. /**
  12983. * HTC Vive
  12984. */
  12985. VIVE = 0,
  12986. /**
  12987. * Oculus Rift
  12988. */
  12989. OCULUS = 1,
  12990. /**
  12991. * Windows mixed reality
  12992. */
  12993. WINDOWS = 2,
  12994. /**
  12995. * Samsung gear VR
  12996. */
  12997. GEAR_VR = 3,
  12998. /**
  12999. * Google Daydream
  13000. */
  13001. DAYDREAM = 4,
  13002. /**
  13003. * Generic
  13004. */
  13005. GENERIC = 5
  13006. }
  13007. /**
  13008. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13009. */
  13010. export interface MutableGamepadButton {
  13011. /**
  13012. * Value of the button/trigger
  13013. */
  13014. value: number;
  13015. /**
  13016. * If the button/trigger is currently touched
  13017. */
  13018. touched: boolean;
  13019. /**
  13020. * If the button/trigger is currently pressed
  13021. */
  13022. pressed: boolean;
  13023. }
  13024. /**
  13025. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13026. * @hidden
  13027. */
  13028. export interface ExtendedGamepadButton extends GamepadButton {
  13029. /**
  13030. * If the button/trigger is currently pressed
  13031. */
  13032. readonly pressed: boolean;
  13033. /**
  13034. * If the button/trigger is currently touched
  13035. */
  13036. readonly touched: boolean;
  13037. /**
  13038. * Value of the button/trigger
  13039. */
  13040. readonly value: number;
  13041. }
  13042. /** @hidden */
  13043. export interface _GamePadFactory {
  13044. /**
  13045. * Returns wether or not the current gamepad can be created for this type of controller.
  13046. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13047. * @returns true if it can be created, otherwise false
  13048. */
  13049. canCreate(gamepadInfo: any): boolean;
  13050. /**
  13051. * Creates a new instance of the Gamepad.
  13052. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13053. * @returns the new gamepad instance
  13054. */
  13055. create(gamepadInfo: any): Gamepad;
  13056. }
  13057. /**
  13058. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13059. */
  13060. export class PoseEnabledControllerHelper {
  13061. /** @hidden */
  13062. static _ControllerFactories: _GamePadFactory[];
  13063. /** @hidden */
  13064. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13065. /**
  13066. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13067. * @param vrGamepad the gamepad to initialized
  13068. * @returns a vr controller of the type the gamepad identified as
  13069. */
  13070. static InitiateController(vrGamepad: any): Gamepad;
  13071. }
  13072. /**
  13073. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13074. */
  13075. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13076. private _deviceRoomPosition;
  13077. private _deviceRoomRotationQuaternion;
  13078. /**
  13079. * The device position in babylon space
  13080. */
  13081. devicePosition: Vector3;
  13082. /**
  13083. * The device rotation in babylon space
  13084. */
  13085. deviceRotationQuaternion: Quaternion;
  13086. /**
  13087. * The scale factor of the device in babylon space
  13088. */
  13089. deviceScaleFactor: number;
  13090. /**
  13091. * (Likely devicePosition should be used instead) The device position in its room space
  13092. */
  13093. position: Vector3;
  13094. /**
  13095. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13096. */
  13097. rotationQuaternion: Quaternion;
  13098. /**
  13099. * The type of controller (Eg. Windows mixed reality)
  13100. */
  13101. controllerType: PoseEnabledControllerType;
  13102. protected _calculatedPosition: Vector3;
  13103. private _calculatedRotation;
  13104. /**
  13105. * The raw pose from the device
  13106. */
  13107. rawPose: DevicePose;
  13108. private _trackPosition;
  13109. private _maxRotationDistFromHeadset;
  13110. private _draggedRoomRotation;
  13111. /**
  13112. * @hidden
  13113. */
  13114. _disableTrackPosition(fixedPosition: Vector3): void;
  13115. /**
  13116. * Internal, the mesh attached to the controller
  13117. * @hidden
  13118. */
  13119. _mesh: Nullable<AbstractMesh>;
  13120. private _poseControlledCamera;
  13121. private _leftHandSystemQuaternion;
  13122. /**
  13123. * Internal, matrix used to convert room space to babylon space
  13124. * @hidden
  13125. */
  13126. _deviceToWorld: Matrix;
  13127. /**
  13128. * Node to be used when casting a ray from the controller
  13129. * @hidden
  13130. */
  13131. _pointingPoseNode: Nullable<TransformNode>;
  13132. /**
  13133. * Name of the child mesh that can be used to cast a ray from the controller
  13134. */
  13135. static readonly POINTING_POSE: string;
  13136. /**
  13137. * Creates a new PoseEnabledController from a gamepad
  13138. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13139. */
  13140. constructor(browserGamepad: any);
  13141. private _workingMatrix;
  13142. /**
  13143. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13144. */
  13145. update(): void;
  13146. /**
  13147. * Updates only the pose device and mesh without doing any button event checking
  13148. */
  13149. protected _updatePoseAndMesh(): void;
  13150. /**
  13151. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13152. * @param poseData raw pose fromthe device
  13153. */
  13154. updateFromDevice(poseData: DevicePose): void;
  13155. /**
  13156. * @hidden
  13157. */
  13158. _meshAttachedObservable: Observable<AbstractMesh>;
  13159. /**
  13160. * Attaches a mesh to the controller
  13161. * @param mesh the mesh to be attached
  13162. */
  13163. attachToMesh(mesh: AbstractMesh): void;
  13164. /**
  13165. * Attaches the controllers mesh to a camera
  13166. * @param camera the camera the mesh should be attached to
  13167. */
  13168. attachToPoseControlledCamera(camera: TargetCamera): void;
  13169. /**
  13170. * Disposes of the controller
  13171. */
  13172. dispose(): void;
  13173. /**
  13174. * The mesh that is attached to the controller
  13175. */
  13176. readonly mesh: Nullable<AbstractMesh>;
  13177. /**
  13178. * Gets the ray of the controller in the direction the controller is pointing
  13179. * @param length the length the resulting ray should be
  13180. * @returns a ray in the direction the controller is pointing
  13181. */
  13182. getForwardRay(length?: number): Ray;
  13183. }
  13184. }
  13185. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13186. import { Observable } from "babylonjs/Misc/observable";
  13187. import { Scene } from "babylonjs/scene";
  13188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13189. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13190. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13191. /**
  13192. * Defines the WebVRController object that represents controllers tracked in 3D space
  13193. */
  13194. export abstract class WebVRController extends PoseEnabledController {
  13195. /**
  13196. * Internal, the default controller model for the controller
  13197. */
  13198. protected _defaultModel: AbstractMesh;
  13199. /**
  13200. * Fired when the trigger state has changed
  13201. */
  13202. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13203. /**
  13204. * Fired when the main button state has changed
  13205. */
  13206. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13207. /**
  13208. * Fired when the secondary button state has changed
  13209. */
  13210. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13211. /**
  13212. * Fired when the pad state has changed
  13213. */
  13214. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13215. /**
  13216. * Fired when controllers stick values have changed
  13217. */
  13218. onPadValuesChangedObservable: Observable<StickValues>;
  13219. /**
  13220. * Array of button availible on the controller
  13221. */
  13222. protected _buttons: Array<MutableGamepadButton>;
  13223. private _onButtonStateChange;
  13224. /**
  13225. * Fired when a controller button's state has changed
  13226. * @param callback the callback containing the button that was modified
  13227. */
  13228. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13229. /**
  13230. * X and Y axis corrisponding to the controllers joystick
  13231. */
  13232. pad: StickValues;
  13233. /**
  13234. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13235. */
  13236. hand: string;
  13237. /**
  13238. * The default controller model for the controller
  13239. */
  13240. readonly defaultModel: AbstractMesh;
  13241. /**
  13242. * Creates a new WebVRController from a gamepad
  13243. * @param vrGamepad the gamepad that the WebVRController should be created from
  13244. */
  13245. constructor(vrGamepad: any);
  13246. /**
  13247. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13248. */
  13249. update(): void;
  13250. /**
  13251. * Function to be called when a button is modified
  13252. */
  13253. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13254. /**
  13255. * Loads a mesh and attaches it to the controller
  13256. * @param scene the scene the mesh should be added to
  13257. * @param meshLoaded callback for when the mesh has been loaded
  13258. */
  13259. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13260. private _setButtonValue;
  13261. private _changes;
  13262. private _checkChanges;
  13263. /**
  13264. * Disposes of th webVRCOntroller
  13265. */
  13266. dispose(): void;
  13267. }
  13268. }
  13269. declare module "babylonjs/Lights/hemisphericLight" {
  13270. import { Nullable } from "babylonjs/types";
  13271. import { Scene } from "babylonjs/scene";
  13272. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13273. import { Effect } from "babylonjs/Materials/effect";
  13274. import { Light } from "babylonjs/Lights/light";
  13275. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13276. /**
  13277. * The HemisphericLight simulates the ambient environment light,
  13278. * so the passed direction is the light reflection direction, not the incoming direction.
  13279. */
  13280. export class HemisphericLight extends Light {
  13281. /**
  13282. * The groundColor is the light in the opposite direction to the one specified during creation.
  13283. * 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.
  13284. */
  13285. groundColor: Color3;
  13286. /**
  13287. * The light reflection direction, not the incoming direction.
  13288. */
  13289. direction: Vector3;
  13290. /**
  13291. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13292. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13293. * The HemisphericLight can't cast shadows.
  13294. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13295. * @param name The friendly name of the light
  13296. * @param direction The direction of the light reflection
  13297. * @param scene The scene the light belongs to
  13298. */
  13299. constructor(name: string, direction: Vector3, scene: Scene);
  13300. protected _buildUniformLayout(): void;
  13301. /**
  13302. * Returns the string "HemisphericLight".
  13303. * @return The class name
  13304. */
  13305. getClassName(): string;
  13306. /**
  13307. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13308. * Returns the updated direction.
  13309. * @param target The target the direction should point to
  13310. * @return The computed direction
  13311. */
  13312. setDirectionToTarget(target: Vector3): Vector3;
  13313. /**
  13314. * Returns the shadow generator associated to the light.
  13315. * @returns Always null for hemispheric lights because it does not support shadows.
  13316. */
  13317. getShadowGenerator(): Nullable<IShadowGenerator>;
  13318. /**
  13319. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13320. * @param effect The effect to update
  13321. * @param lightIndex The index of the light in the effect to update
  13322. * @returns The hemispheric light
  13323. */
  13324. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13325. /**
  13326. * Computes the world matrix of the node
  13327. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13328. * @param useWasUpdatedFlag defines a reserved property
  13329. * @returns the world matrix
  13330. */
  13331. computeWorldMatrix(): Matrix;
  13332. /**
  13333. * Returns the integer 3.
  13334. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13335. */
  13336. getTypeID(): number;
  13337. /**
  13338. * Prepares the list of defines specific to the light type.
  13339. * @param defines the list of defines
  13340. * @param lightIndex defines the index of the light for the effect
  13341. */
  13342. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13343. }
  13344. }
  13345. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13346. /** @hidden */
  13347. export var vrMultiviewToSingleviewPixelShader: {
  13348. name: string;
  13349. shader: string;
  13350. };
  13351. }
  13352. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13353. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13354. import { Scene } from "babylonjs/scene";
  13355. /**
  13356. * Renders to multiple views with a single draw call
  13357. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13358. */
  13359. export class MultiviewRenderTarget extends RenderTargetTexture {
  13360. /**
  13361. * Creates a multiview render target
  13362. * @param scene scene used with the render target
  13363. * @param size the size of the render target (used for each view)
  13364. */
  13365. constructor(scene: Scene, size?: number | {
  13366. width: number;
  13367. height: number;
  13368. } | {
  13369. ratio: number;
  13370. });
  13371. /**
  13372. * @hidden
  13373. * @param faceIndex the face index, if its a cube texture
  13374. */
  13375. _bindFrameBuffer(faceIndex?: number): void;
  13376. /**
  13377. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13378. * @returns the view count
  13379. */
  13380. getViewCount(): number;
  13381. }
  13382. }
  13383. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13384. import { Camera } from "babylonjs/Cameras/camera";
  13385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13386. import { Nullable } from "babylonjs/types";
  13387. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13388. import { Matrix } from "babylonjs/Maths/math";
  13389. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13390. module "babylonjs/Engines/engine" {
  13391. interface Engine {
  13392. /**
  13393. * Creates a new multiview render target
  13394. * @param width defines the width of the texture
  13395. * @param height defines the height of the texture
  13396. * @returns the created multiview texture
  13397. */
  13398. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13399. /**
  13400. * Binds a multiview framebuffer to be drawn to
  13401. * @param multiviewTexture texture to bind
  13402. */
  13403. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13404. }
  13405. }
  13406. module "babylonjs/Cameras/camera" {
  13407. interface Camera {
  13408. /**
  13409. * @hidden
  13410. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13411. */
  13412. _useMultiviewToSingleView: boolean;
  13413. /**
  13414. * @hidden
  13415. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13416. */
  13417. _multiviewTexture: Nullable<RenderTargetTexture>;
  13418. /**
  13419. * @hidden
  13420. * ensures the multiview texture of the camera exists and has the specified width/height
  13421. * @param width height to set on the multiview texture
  13422. * @param height width to set on the multiview texture
  13423. */
  13424. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13425. }
  13426. }
  13427. module "babylonjs/scene" {
  13428. interface Scene {
  13429. /** @hidden */
  13430. _transformMatrixR: Matrix;
  13431. /** @hidden */
  13432. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13433. /** @hidden */
  13434. _createMultiviewUbo(): void;
  13435. /** @hidden */
  13436. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13437. /** @hidden */
  13438. _renderMultiviewToSingleView(camera: Camera): void;
  13439. }
  13440. }
  13441. }
  13442. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13443. import { Camera } from "babylonjs/Cameras/camera";
  13444. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13445. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13446. import "babylonjs/Engines/Extensions/engine.multiview";
  13447. /**
  13448. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13449. * This will not be used for webXR as it supports displaying texture arrays directly
  13450. */
  13451. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13452. /**
  13453. * Initializes a VRMultiviewToSingleview
  13454. * @param name name of the post process
  13455. * @param camera camera to be applied to
  13456. * @param scaleFactor scaling factor to the size of the output texture
  13457. */
  13458. constructor(name: string, camera: Camera, scaleFactor: number);
  13459. }
  13460. }
  13461. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13462. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13463. import { Nullable } from "babylonjs/types";
  13464. import { Size } from "babylonjs/Maths/math";
  13465. import { Observable } from "babylonjs/Misc/observable";
  13466. module "babylonjs/Engines/engine" {
  13467. /**
  13468. * Defines the interface used by display changed events
  13469. */
  13470. interface IDisplayChangedEventArgs {
  13471. /** Gets the vrDisplay object (if any) */
  13472. vrDisplay: Nullable<any>;
  13473. /** Gets a boolean indicating if webVR is supported */
  13474. vrSupported: boolean;
  13475. }
  13476. interface Engine {
  13477. /** @hidden */
  13478. _vrDisplay: any;
  13479. /** @hidden */
  13480. _vrSupported: boolean;
  13481. /** @hidden */
  13482. _oldSize: Size;
  13483. /** @hidden */
  13484. _oldHardwareScaleFactor: number;
  13485. /** @hidden */
  13486. _vrExclusivePointerMode: boolean;
  13487. /** @hidden */
  13488. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13489. /** @hidden */
  13490. _onVRDisplayPointerRestricted: () => void;
  13491. /** @hidden */
  13492. _onVRDisplayPointerUnrestricted: () => void;
  13493. /** @hidden */
  13494. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13495. /** @hidden */
  13496. _onVrDisplayDisconnect: Nullable<() => void>;
  13497. /** @hidden */
  13498. _onVrDisplayPresentChange: Nullable<() => void>;
  13499. /**
  13500. * Observable signaled when VR display mode changes
  13501. */
  13502. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13503. /**
  13504. * Observable signaled when VR request present is complete
  13505. */
  13506. onVRRequestPresentComplete: Observable<boolean>;
  13507. /**
  13508. * Observable signaled when VR request present starts
  13509. */
  13510. onVRRequestPresentStart: Observable<Engine>;
  13511. /**
  13512. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13513. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13514. */
  13515. isInVRExclusivePointerMode: boolean;
  13516. /**
  13517. * Gets a boolean indicating if a webVR device was detected
  13518. * @returns true if a webVR device was detected
  13519. */
  13520. isVRDevicePresent(): boolean;
  13521. /**
  13522. * Gets the current webVR device
  13523. * @returns the current webVR device (or null)
  13524. */
  13525. getVRDevice(): any;
  13526. /**
  13527. * Initializes a webVR display and starts listening to display change events
  13528. * The onVRDisplayChangedObservable will be notified upon these changes
  13529. * @returns A promise containing a VRDisplay and if vr is supported
  13530. */
  13531. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13532. /** @hidden */
  13533. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13534. /**
  13535. * Call this function to switch to webVR mode
  13536. * Will do nothing if webVR is not supported or if there is no webVR device
  13537. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13538. */
  13539. enableVR(): void;
  13540. /** @hidden */
  13541. _onVRFullScreenTriggered(): void;
  13542. }
  13543. }
  13544. }
  13545. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13546. import { Nullable } from "babylonjs/types";
  13547. import { Observable } from "babylonjs/Misc/observable";
  13548. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13549. import { Scene } from "babylonjs/scene";
  13550. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13551. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13552. import { Node } from "babylonjs/node";
  13553. import { Ray } from "babylonjs/Culling/ray";
  13554. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13555. import "babylonjs/Engines/Extensions/engine.webVR";
  13556. /**
  13557. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13558. * IMPORTANT!! The data is right-hand data.
  13559. * @export
  13560. * @interface DevicePose
  13561. */
  13562. export interface DevicePose {
  13563. /**
  13564. * The position of the device, values in array are [x,y,z].
  13565. */
  13566. readonly position: Nullable<Float32Array>;
  13567. /**
  13568. * The linearVelocity of the device, values in array are [x,y,z].
  13569. */
  13570. readonly linearVelocity: Nullable<Float32Array>;
  13571. /**
  13572. * The linearAcceleration of the device, values in array are [x,y,z].
  13573. */
  13574. readonly linearAcceleration: Nullable<Float32Array>;
  13575. /**
  13576. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13577. */
  13578. readonly orientation: Nullable<Float32Array>;
  13579. /**
  13580. * The angularVelocity of the device, values in array are [x,y,z].
  13581. */
  13582. readonly angularVelocity: Nullable<Float32Array>;
  13583. /**
  13584. * The angularAcceleration of the device, values in array are [x,y,z].
  13585. */
  13586. readonly angularAcceleration: Nullable<Float32Array>;
  13587. }
  13588. /**
  13589. * Interface representing a pose controlled object in Babylon.
  13590. * A pose controlled object has both regular pose values as well as pose values
  13591. * from an external device such as a VR head mounted display
  13592. */
  13593. export interface PoseControlled {
  13594. /**
  13595. * The position of the object in babylon space.
  13596. */
  13597. position: Vector3;
  13598. /**
  13599. * The rotation quaternion of the object in babylon space.
  13600. */
  13601. rotationQuaternion: Quaternion;
  13602. /**
  13603. * The position of the device in babylon space.
  13604. */
  13605. devicePosition?: Vector3;
  13606. /**
  13607. * The rotation quaternion of the device in babylon space.
  13608. */
  13609. deviceRotationQuaternion: Quaternion;
  13610. /**
  13611. * The raw pose coming from the device.
  13612. */
  13613. rawPose: Nullable<DevicePose>;
  13614. /**
  13615. * The scale of the device to be used when translating from device space to babylon space.
  13616. */
  13617. deviceScaleFactor: number;
  13618. /**
  13619. * Updates the poseControlled values based on the input device pose.
  13620. * @param poseData the pose data to update the object with
  13621. */
  13622. updateFromDevice(poseData: DevicePose): void;
  13623. }
  13624. /**
  13625. * Set of options to customize the webVRCamera
  13626. */
  13627. export interface WebVROptions {
  13628. /**
  13629. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13630. */
  13631. trackPosition?: boolean;
  13632. /**
  13633. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13634. */
  13635. positionScale?: number;
  13636. /**
  13637. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13638. */
  13639. displayName?: string;
  13640. /**
  13641. * Should the native controller meshes be initialized. (default: true)
  13642. */
  13643. controllerMeshes?: boolean;
  13644. /**
  13645. * Creating a default HemiLight only on controllers. (default: true)
  13646. */
  13647. defaultLightingOnControllers?: boolean;
  13648. /**
  13649. * If you don't want to use the default VR button of the helper. (default: false)
  13650. */
  13651. useCustomVRButton?: boolean;
  13652. /**
  13653. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13654. */
  13655. customVRButton?: HTMLButtonElement;
  13656. /**
  13657. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13658. */
  13659. rayLength?: number;
  13660. /**
  13661. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13662. */
  13663. defaultHeight?: number;
  13664. /**
  13665. * If multiview should be used if availible (default: false)
  13666. */
  13667. useMultiview?: boolean;
  13668. }
  13669. /**
  13670. * This represents a WebVR camera.
  13671. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13672. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13673. */
  13674. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13675. private webVROptions;
  13676. /**
  13677. * @hidden
  13678. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13679. */
  13680. _vrDevice: any;
  13681. /**
  13682. * The rawPose of the vrDevice.
  13683. */
  13684. rawPose: Nullable<DevicePose>;
  13685. private _onVREnabled;
  13686. private _specsVersion;
  13687. private _attached;
  13688. private _frameData;
  13689. protected _descendants: Array<Node>;
  13690. private _deviceRoomPosition;
  13691. /** @hidden */
  13692. _deviceRoomRotationQuaternion: Quaternion;
  13693. private _standingMatrix;
  13694. /**
  13695. * Represents device position in babylon space.
  13696. */
  13697. devicePosition: Vector3;
  13698. /**
  13699. * Represents device rotation in babylon space.
  13700. */
  13701. deviceRotationQuaternion: Quaternion;
  13702. /**
  13703. * The scale of the device to be used when translating from device space to babylon space.
  13704. */
  13705. deviceScaleFactor: number;
  13706. private _deviceToWorld;
  13707. private _worldToDevice;
  13708. /**
  13709. * References to the webVR controllers for the vrDevice.
  13710. */
  13711. controllers: Array<WebVRController>;
  13712. /**
  13713. * Emits an event when a controller is attached.
  13714. */
  13715. onControllersAttachedObservable: Observable<WebVRController[]>;
  13716. /**
  13717. * Emits an event when a controller's mesh has been loaded;
  13718. */
  13719. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13720. /**
  13721. * Emits an event when the HMD's pose has been updated.
  13722. */
  13723. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13724. private _poseSet;
  13725. /**
  13726. * If the rig cameras be used as parent instead of this camera.
  13727. */
  13728. rigParenting: boolean;
  13729. private _lightOnControllers;
  13730. private _defaultHeight?;
  13731. /**
  13732. * Instantiates a WebVRFreeCamera.
  13733. * @param name The name of the WebVRFreeCamera
  13734. * @param position The starting anchor position for the camera
  13735. * @param scene The scene the camera belongs to
  13736. * @param webVROptions a set of customizable options for the webVRCamera
  13737. */
  13738. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13739. /**
  13740. * Gets the device distance from the ground in meters.
  13741. * @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.
  13742. */
  13743. deviceDistanceToRoomGround(): number;
  13744. /**
  13745. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13746. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13747. */
  13748. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13749. /**
  13750. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13751. * @returns A promise with a boolean set to if the standing matrix is supported.
  13752. */
  13753. useStandingMatrixAsync(): Promise<boolean>;
  13754. /**
  13755. * Disposes the camera
  13756. */
  13757. dispose(): void;
  13758. /**
  13759. * Gets a vrController by name.
  13760. * @param name The name of the controller to retreive
  13761. * @returns the controller matching the name specified or null if not found
  13762. */
  13763. getControllerByName(name: string): Nullable<WebVRController>;
  13764. private _leftController;
  13765. /**
  13766. * The controller corrisponding to the users left hand.
  13767. */
  13768. readonly leftController: Nullable<WebVRController>;
  13769. private _rightController;
  13770. /**
  13771. * The controller corrisponding to the users right hand.
  13772. */
  13773. readonly rightController: Nullable<WebVRController>;
  13774. /**
  13775. * Casts a ray forward from the vrCamera's gaze.
  13776. * @param length Length of the ray (default: 100)
  13777. * @returns the ray corrisponding to the gaze
  13778. */
  13779. getForwardRay(length?: number): Ray;
  13780. /**
  13781. * @hidden
  13782. * Updates the camera based on device's frame data
  13783. */
  13784. _checkInputs(): void;
  13785. /**
  13786. * Updates the poseControlled values based on the input device pose.
  13787. * @param poseData Pose coming from the device
  13788. */
  13789. updateFromDevice(poseData: DevicePose): void;
  13790. private _htmlElementAttached;
  13791. private _detachIfAttached;
  13792. /**
  13793. * WebVR's attach control will start broadcasting frames to the device.
  13794. * Note that in certain browsers (chrome for example) this function must be called
  13795. * within a user-interaction callback. Example:
  13796. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13797. *
  13798. * @param element html element to attach the vrDevice to
  13799. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13800. */
  13801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13802. /**
  13803. * Detaches the camera from the html element and disables VR
  13804. *
  13805. * @param element html element to detach from
  13806. */
  13807. detachControl(element: HTMLElement): void;
  13808. /**
  13809. * @returns the name of this class
  13810. */
  13811. getClassName(): string;
  13812. /**
  13813. * Calls resetPose on the vrDisplay
  13814. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13815. */
  13816. resetToCurrentRotation(): void;
  13817. /**
  13818. * @hidden
  13819. * Updates the rig cameras (left and right eye)
  13820. */
  13821. _updateRigCameras(): void;
  13822. private _workingVector;
  13823. private _oneVector;
  13824. private _workingMatrix;
  13825. private updateCacheCalled;
  13826. private _correctPositionIfNotTrackPosition;
  13827. /**
  13828. * @hidden
  13829. * Updates the cached values of the camera
  13830. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13831. */
  13832. _updateCache(ignoreParentClass?: boolean): void;
  13833. /**
  13834. * @hidden
  13835. * Get current device position in babylon world
  13836. */
  13837. _computeDevicePosition(): void;
  13838. /**
  13839. * Updates the current device position and rotation in the babylon world
  13840. */
  13841. update(): void;
  13842. /**
  13843. * @hidden
  13844. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13845. * @returns an identity matrix
  13846. */
  13847. _getViewMatrix(): Matrix;
  13848. private _tmpMatrix;
  13849. /**
  13850. * This function is called by the two RIG cameras.
  13851. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13852. * @hidden
  13853. */
  13854. _getWebVRViewMatrix(): Matrix;
  13855. /** @hidden */
  13856. _getWebVRProjectionMatrix(): Matrix;
  13857. private _onGamepadConnectedObserver;
  13858. private _onGamepadDisconnectedObserver;
  13859. private _updateCacheWhenTrackingDisabledObserver;
  13860. /**
  13861. * Initializes the controllers and their meshes
  13862. */
  13863. initControllers(): void;
  13864. }
  13865. }
  13866. declare module "babylonjs/PostProcesses/postProcess" {
  13867. import { Nullable } from "babylonjs/types";
  13868. import { SmartArray } from "babylonjs/Misc/smartArray";
  13869. import { Observable } from "babylonjs/Misc/observable";
  13870. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13871. import { Camera } from "babylonjs/Cameras/camera";
  13872. import { Effect } from "babylonjs/Materials/effect";
  13873. import "babylonjs/Shaders/postprocess.vertex";
  13874. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13876. import { Engine } from "babylonjs/Engines/engine";
  13877. /**
  13878. * Size options for a post process
  13879. */
  13880. export type PostProcessOptions = {
  13881. width: number;
  13882. height: number;
  13883. };
  13884. /**
  13885. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13886. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13887. */
  13888. export class PostProcess {
  13889. /** Name of the PostProcess. */
  13890. name: string;
  13891. /**
  13892. * Gets or sets the unique id of the post process
  13893. */
  13894. uniqueId: number;
  13895. /**
  13896. * Width of the texture to apply the post process on
  13897. */
  13898. width: number;
  13899. /**
  13900. * Height of the texture to apply the post process on
  13901. */
  13902. height: number;
  13903. /**
  13904. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13905. * @hidden
  13906. */
  13907. _outputTexture: Nullable<InternalTexture>;
  13908. /**
  13909. * Sampling mode used by the shader
  13910. * See https://doc.babylonjs.com/classes/3.1/texture
  13911. */
  13912. renderTargetSamplingMode: number;
  13913. /**
  13914. * Clear color to use when screen clearing
  13915. */
  13916. clearColor: Color4;
  13917. /**
  13918. * If the buffer needs to be cleared before applying the post process. (default: true)
  13919. * Should be set to false if shader will overwrite all previous pixels.
  13920. */
  13921. autoClear: boolean;
  13922. /**
  13923. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13924. */
  13925. alphaMode: number;
  13926. /**
  13927. * Sets the setAlphaBlendConstants of the babylon engine
  13928. */
  13929. alphaConstants: Color4;
  13930. /**
  13931. * Animations to be used for the post processing
  13932. */
  13933. animations: import("babylonjs/Animations/animation").Animation[];
  13934. /**
  13935. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13936. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13937. */
  13938. enablePixelPerfectMode: boolean;
  13939. /**
  13940. * Force the postprocess to be applied without taking in account viewport
  13941. */
  13942. forceFullscreenViewport: boolean;
  13943. /**
  13944. * List of inspectable custom properties (used by the Inspector)
  13945. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13946. */
  13947. inspectableCustomProperties: IInspectable[];
  13948. /**
  13949. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13950. *
  13951. * | Value | Type | Description |
  13952. * | ----- | ----------------------------------- | ----------- |
  13953. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13954. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13955. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13956. *
  13957. */
  13958. scaleMode: number;
  13959. /**
  13960. * Force textures to be a power of two (default: false)
  13961. */
  13962. alwaysForcePOT: boolean;
  13963. private _samples;
  13964. /**
  13965. * Number of sample textures (default: 1)
  13966. */
  13967. samples: number;
  13968. /**
  13969. * Modify the scale of the post process to be the same as the viewport (default: false)
  13970. */
  13971. adaptScaleToCurrentViewport: boolean;
  13972. private _camera;
  13973. private _scene;
  13974. private _engine;
  13975. private _options;
  13976. private _reusable;
  13977. private _textureType;
  13978. /**
  13979. * Smart array of input and output textures for the post process.
  13980. * @hidden
  13981. */
  13982. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13983. /**
  13984. * The index in _textures that corresponds to the output texture.
  13985. * @hidden
  13986. */
  13987. _currentRenderTextureInd: number;
  13988. private _effect;
  13989. private _samplers;
  13990. private _fragmentUrl;
  13991. private _vertexUrl;
  13992. private _parameters;
  13993. private _scaleRatio;
  13994. protected _indexParameters: any;
  13995. private _shareOutputWithPostProcess;
  13996. private _texelSize;
  13997. private _forcedOutputTexture;
  13998. /**
  13999. * Returns the fragment url or shader name used in the post process.
  14000. * @returns the fragment url or name in the shader store.
  14001. */
  14002. getEffectName(): string;
  14003. /**
  14004. * An event triggered when the postprocess is activated.
  14005. */
  14006. onActivateObservable: Observable<Camera>;
  14007. private _onActivateObserver;
  14008. /**
  14009. * A function that is added to the onActivateObservable
  14010. */
  14011. onActivate: Nullable<(camera: Camera) => void>;
  14012. /**
  14013. * An event triggered when the postprocess changes its size.
  14014. */
  14015. onSizeChangedObservable: Observable<PostProcess>;
  14016. private _onSizeChangedObserver;
  14017. /**
  14018. * A function that is added to the onSizeChangedObservable
  14019. */
  14020. onSizeChanged: (postProcess: PostProcess) => void;
  14021. /**
  14022. * An event triggered when the postprocess applies its effect.
  14023. */
  14024. onApplyObservable: Observable<Effect>;
  14025. private _onApplyObserver;
  14026. /**
  14027. * A function that is added to the onApplyObservable
  14028. */
  14029. onApply: (effect: Effect) => void;
  14030. /**
  14031. * An event triggered before rendering the postprocess
  14032. */
  14033. onBeforeRenderObservable: Observable<Effect>;
  14034. private _onBeforeRenderObserver;
  14035. /**
  14036. * A function that is added to the onBeforeRenderObservable
  14037. */
  14038. onBeforeRender: (effect: Effect) => void;
  14039. /**
  14040. * An event triggered after rendering the postprocess
  14041. */
  14042. onAfterRenderObservable: Observable<Effect>;
  14043. private _onAfterRenderObserver;
  14044. /**
  14045. * A function that is added to the onAfterRenderObservable
  14046. */
  14047. onAfterRender: (efect: Effect) => void;
  14048. /**
  14049. * 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
  14050. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14051. */
  14052. inputTexture: InternalTexture;
  14053. /**
  14054. * Gets the camera which post process is applied to.
  14055. * @returns The camera the post process is applied to.
  14056. */
  14057. getCamera(): Camera;
  14058. /**
  14059. * Gets the texel size of the postprocess.
  14060. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14061. */
  14062. readonly texelSize: Vector2;
  14063. /**
  14064. * Creates a new instance PostProcess
  14065. * @param name The name of the PostProcess.
  14066. * @param fragmentUrl The url of the fragment shader to be used.
  14067. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14068. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14069. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14070. * @param camera The camera to apply the render pass to.
  14071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14072. * @param engine The engine which the post process will be applied. (default: current engine)
  14073. * @param reusable If the post process can be reused on the same frame. (default: false)
  14074. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14075. * @param textureType Type of textures used when performing the post process. (default: 0)
  14076. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14077. * @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
  14078. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14079. */
  14080. constructor(
  14081. /** Name of the PostProcess. */
  14082. 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);
  14083. /**
  14084. * Gets a string idenfifying the name of the class
  14085. * @returns "PostProcess" string
  14086. */
  14087. getClassName(): string;
  14088. /**
  14089. * Gets the engine which this post process belongs to.
  14090. * @returns The engine the post process was enabled with.
  14091. */
  14092. getEngine(): Engine;
  14093. /**
  14094. * The effect that is created when initializing the post process.
  14095. * @returns The created effect corrisponding the the postprocess.
  14096. */
  14097. getEffect(): Effect;
  14098. /**
  14099. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14100. * @param postProcess The post process to share the output with.
  14101. * @returns This post process.
  14102. */
  14103. shareOutputWith(postProcess: PostProcess): PostProcess;
  14104. /**
  14105. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14106. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14107. */
  14108. useOwnOutput(): void;
  14109. /**
  14110. * Updates the effect with the current post process compile time values and recompiles the shader.
  14111. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14112. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14113. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14114. * @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
  14115. * @param onCompiled Called when the shader has been compiled.
  14116. * @param onError Called if there is an error when compiling a shader.
  14117. */
  14118. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14119. /**
  14120. * The post process is reusable if it can be used multiple times within one frame.
  14121. * @returns If the post process is reusable
  14122. */
  14123. isReusable(): boolean;
  14124. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14125. markTextureDirty(): void;
  14126. /**
  14127. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14128. * 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.
  14129. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14130. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14131. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14132. * @returns The target texture that was bound to be written to.
  14133. */
  14134. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14135. /**
  14136. * If the post process is supported.
  14137. */
  14138. readonly isSupported: boolean;
  14139. /**
  14140. * The aspect ratio of the output texture.
  14141. */
  14142. readonly aspectRatio: number;
  14143. /**
  14144. * Get a value indicating if the post-process is ready to be used
  14145. * @returns true if the post-process is ready (shader is compiled)
  14146. */
  14147. isReady(): boolean;
  14148. /**
  14149. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14150. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14151. */
  14152. apply(): Nullable<Effect>;
  14153. private _disposeTextures;
  14154. /**
  14155. * Disposes the post process.
  14156. * @param camera The camera to dispose the post process on.
  14157. */
  14158. dispose(camera?: Camera): void;
  14159. }
  14160. }
  14161. declare module "babylonjs/PostProcesses/postProcessManager" {
  14162. import { Nullable } from "babylonjs/types";
  14163. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14164. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14165. import { Scene } from "babylonjs/scene";
  14166. /**
  14167. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14168. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14169. */
  14170. export class PostProcessManager {
  14171. private _scene;
  14172. private _indexBuffer;
  14173. private _vertexBuffers;
  14174. /**
  14175. * Creates a new instance PostProcess
  14176. * @param scene The scene that the post process is associated with.
  14177. */
  14178. constructor(scene: Scene);
  14179. private _prepareBuffers;
  14180. private _buildIndexBuffer;
  14181. /**
  14182. * Rebuilds the vertex buffers of the manager.
  14183. * @hidden
  14184. */
  14185. _rebuild(): void;
  14186. /**
  14187. * Prepares a frame to be run through a post process.
  14188. * @param sourceTexture The input texture to the post procesess. (default: null)
  14189. * @param postProcesses An array of post processes to be run. (default: null)
  14190. * @returns True if the post processes were able to be run.
  14191. * @hidden
  14192. */
  14193. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14194. /**
  14195. * Manually render a set of post processes to a texture.
  14196. * @param postProcesses An array of post processes to be run.
  14197. * @param targetTexture The target texture to render to.
  14198. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14199. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14200. * @param lodLevel defines which lod of the texture to render to
  14201. */
  14202. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14203. /**
  14204. * Finalize the result of the output of the postprocesses.
  14205. * @param doNotPresent If true the result will not be displayed to the screen.
  14206. * @param targetTexture The target texture to render to.
  14207. * @param faceIndex The index of the face to bind the target texture to.
  14208. * @param postProcesses The array of post processes to render.
  14209. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14210. * @hidden
  14211. */
  14212. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14213. /**
  14214. * Disposes of the post process manager.
  14215. */
  14216. dispose(): void;
  14217. }
  14218. }
  14219. declare module "babylonjs/Layers/layerSceneComponent" {
  14220. import { Scene } from "babylonjs/scene";
  14221. import { ISceneComponent } from "babylonjs/sceneComponent";
  14222. import { Layer } from "babylonjs/Layers/layer";
  14223. module "babylonjs/abstractScene" {
  14224. interface AbstractScene {
  14225. /**
  14226. * The list of layers (background and foreground) of the scene
  14227. */
  14228. layers: Array<Layer>;
  14229. }
  14230. }
  14231. /**
  14232. * Defines the layer scene component responsible to manage any layers
  14233. * in a given scene.
  14234. */
  14235. export class LayerSceneComponent implements ISceneComponent {
  14236. /**
  14237. * The component name helpfull to identify the component in the list of scene components.
  14238. */
  14239. readonly name: string;
  14240. /**
  14241. * The scene the component belongs to.
  14242. */
  14243. scene: Scene;
  14244. private _engine;
  14245. /**
  14246. * Creates a new instance of the component for the given scene
  14247. * @param scene Defines the scene to register the component in
  14248. */
  14249. constructor(scene: Scene);
  14250. /**
  14251. * Registers the component in a given scene
  14252. */
  14253. register(): void;
  14254. /**
  14255. * Rebuilds the elements related to this component in case of
  14256. * context lost for instance.
  14257. */
  14258. rebuild(): void;
  14259. /**
  14260. * Disposes the component and the associated ressources.
  14261. */
  14262. dispose(): void;
  14263. private _draw;
  14264. private _drawCameraPredicate;
  14265. private _drawCameraBackground;
  14266. private _drawCameraForeground;
  14267. private _drawRenderTargetPredicate;
  14268. private _drawRenderTargetBackground;
  14269. private _drawRenderTargetForeground;
  14270. }
  14271. }
  14272. declare module "babylonjs/Shaders/layer.fragment" {
  14273. /** @hidden */
  14274. export var layerPixelShader: {
  14275. name: string;
  14276. shader: string;
  14277. };
  14278. }
  14279. declare module "babylonjs/Shaders/layer.vertex" {
  14280. /** @hidden */
  14281. export var layerVertexShader: {
  14282. name: string;
  14283. shader: string;
  14284. };
  14285. }
  14286. declare module "babylonjs/Layers/layer" {
  14287. import { Observable } from "babylonjs/Misc/observable";
  14288. import { Nullable } from "babylonjs/types";
  14289. import { Scene } from "babylonjs/scene";
  14290. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14291. import { Texture } from "babylonjs/Materials/Textures/texture";
  14292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14293. import "babylonjs/Shaders/layer.fragment";
  14294. import "babylonjs/Shaders/layer.vertex";
  14295. /**
  14296. * This represents a full screen 2d layer.
  14297. * This can be useful to display a picture in the background of your scene for instance.
  14298. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14299. */
  14300. export class Layer {
  14301. /**
  14302. * Define the name of the layer.
  14303. */
  14304. name: string;
  14305. /**
  14306. * Define the texture the layer should display.
  14307. */
  14308. texture: Nullable<Texture>;
  14309. /**
  14310. * Is the layer in background or foreground.
  14311. */
  14312. isBackground: boolean;
  14313. /**
  14314. * Define the color of the layer (instead of texture).
  14315. */
  14316. color: Color4;
  14317. /**
  14318. * Define the scale of the layer in order to zoom in out of the texture.
  14319. */
  14320. scale: Vector2;
  14321. /**
  14322. * Define an offset for the layer in order to shift the texture.
  14323. */
  14324. offset: Vector2;
  14325. /**
  14326. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14327. */
  14328. alphaBlendingMode: number;
  14329. /**
  14330. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14331. * Alpha test will not mix with the background color in case of transparency.
  14332. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14333. */
  14334. alphaTest: boolean;
  14335. /**
  14336. * Define a mask to restrict the layer to only some of the scene cameras.
  14337. */
  14338. layerMask: number;
  14339. /**
  14340. * Define the list of render target the layer is visible into.
  14341. */
  14342. renderTargetTextures: RenderTargetTexture[];
  14343. /**
  14344. * Define if the layer is only used in renderTarget or if it also
  14345. * renders in the main frame buffer of the canvas.
  14346. */
  14347. renderOnlyInRenderTargetTextures: boolean;
  14348. private _scene;
  14349. private _vertexBuffers;
  14350. private _indexBuffer;
  14351. private _effect;
  14352. private _alphaTestEffect;
  14353. /**
  14354. * An event triggered when the layer is disposed.
  14355. */
  14356. onDisposeObservable: Observable<Layer>;
  14357. private _onDisposeObserver;
  14358. /**
  14359. * Back compatibility with callback before the onDisposeObservable existed.
  14360. * The set callback will be triggered when the layer has been disposed.
  14361. */
  14362. onDispose: () => void;
  14363. /**
  14364. * An event triggered before rendering the scene
  14365. */
  14366. onBeforeRenderObservable: Observable<Layer>;
  14367. private _onBeforeRenderObserver;
  14368. /**
  14369. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14370. * The set callback will be triggered just before rendering the layer.
  14371. */
  14372. onBeforeRender: () => void;
  14373. /**
  14374. * An event triggered after rendering the scene
  14375. */
  14376. onAfterRenderObservable: Observable<Layer>;
  14377. private _onAfterRenderObserver;
  14378. /**
  14379. * Back compatibility with callback before the onAfterRenderObservable existed.
  14380. * The set callback will be triggered just after rendering the layer.
  14381. */
  14382. onAfterRender: () => void;
  14383. /**
  14384. * Instantiates a new layer.
  14385. * This represents a full screen 2d layer.
  14386. * This can be useful to display a picture in the background of your scene for instance.
  14387. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14388. * @param name Define the name of the layer in the scene
  14389. * @param imgUrl Define the url of the texture to display in the layer
  14390. * @param scene Define the scene the layer belongs to
  14391. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14392. * @param color Defines a color for the layer
  14393. */
  14394. constructor(
  14395. /**
  14396. * Define the name of the layer.
  14397. */
  14398. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14399. private _createIndexBuffer;
  14400. /** @hidden */
  14401. _rebuild(): void;
  14402. /**
  14403. * Renders the layer in the scene.
  14404. */
  14405. render(): void;
  14406. /**
  14407. * Disposes and releases the associated ressources.
  14408. */
  14409. dispose(): void;
  14410. }
  14411. }
  14412. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14413. import { Scene } from "babylonjs/scene";
  14414. import { ISceneComponent } from "babylonjs/sceneComponent";
  14415. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14416. module "babylonjs/abstractScene" {
  14417. interface AbstractScene {
  14418. /**
  14419. * The list of procedural textures added to the scene
  14420. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14421. */
  14422. proceduralTextures: Array<ProceduralTexture>;
  14423. }
  14424. }
  14425. /**
  14426. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14427. * in a given scene.
  14428. */
  14429. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14430. /**
  14431. * The component name helpfull to identify the component in the list of scene components.
  14432. */
  14433. readonly name: string;
  14434. /**
  14435. * The scene the component belongs to.
  14436. */
  14437. scene: Scene;
  14438. /**
  14439. * Creates a new instance of the component for the given scene
  14440. * @param scene Defines the scene to register the component in
  14441. */
  14442. constructor(scene: Scene);
  14443. /**
  14444. * Registers the component in a given scene
  14445. */
  14446. register(): void;
  14447. /**
  14448. * Rebuilds the elements related to this component in case of
  14449. * context lost for instance.
  14450. */
  14451. rebuild(): void;
  14452. /**
  14453. * Disposes the component and the associated ressources.
  14454. */
  14455. dispose(): void;
  14456. private _beforeClear;
  14457. }
  14458. }
  14459. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14460. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14461. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14462. module "babylonjs/Engines/engine" {
  14463. interface Engine {
  14464. /**
  14465. * Creates a new render target cube texture
  14466. * @param size defines the size of the texture
  14467. * @param options defines the options used to create the texture
  14468. * @returns a new render target cube texture stored in an InternalTexture
  14469. */
  14470. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14471. }
  14472. }
  14473. }
  14474. declare module "babylonjs/Shaders/procedural.vertex" {
  14475. /** @hidden */
  14476. export var proceduralVertexShader: {
  14477. name: string;
  14478. shader: string;
  14479. };
  14480. }
  14481. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14482. import { Observable } from "babylonjs/Misc/observable";
  14483. import { Nullable } from "babylonjs/types";
  14484. import { Scene } from "babylonjs/scene";
  14485. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14486. import { Effect } from "babylonjs/Materials/effect";
  14487. import { Texture } from "babylonjs/Materials/Textures/texture";
  14488. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14489. import "babylonjs/Shaders/procedural.vertex";
  14490. /**
  14491. * 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.
  14492. * This is the base class of any Procedural texture and contains most of the shareable code.
  14493. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14494. */
  14495. export class ProceduralTexture extends Texture {
  14496. isCube: boolean;
  14497. /**
  14498. * Define if the texture is enabled or not (disabled texture will not render)
  14499. */
  14500. isEnabled: boolean;
  14501. /**
  14502. * Define if the texture must be cleared before rendering (default is true)
  14503. */
  14504. autoClear: boolean;
  14505. /**
  14506. * Callback called when the texture is generated
  14507. */
  14508. onGenerated: () => void;
  14509. /**
  14510. * Event raised when the texture is generated
  14511. */
  14512. onGeneratedObservable: Observable<ProceduralTexture>;
  14513. /** @hidden */
  14514. _generateMipMaps: boolean;
  14515. /** @hidden **/
  14516. _effect: Effect;
  14517. /** @hidden */
  14518. _textures: {
  14519. [key: string]: Texture;
  14520. };
  14521. private _size;
  14522. private _currentRefreshId;
  14523. private _refreshRate;
  14524. private _vertexBuffers;
  14525. private _indexBuffer;
  14526. private _uniforms;
  14527. private _samplers;
  14528. private _fragment;
  14529. private _floats;
  14530. private _ints;
  14531. private _floatsArrays;
  14532. private _colors3;
  14533. private _colors4;
  14534. private _vectors2;
  14535. private _vectors3;
  14536. private _matrices;
  14537. private _fallbackTexture;
  14538. private _fallbackTextureUsed;
  14539. private _engine;
  14540. private _cachedDefines;
  14541. private _contentUpdateId;
  14542. private _contentData;
  14543. /**
  14544. * Instantiates a new procedural texture.
  14545. * 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.
  14546. * This is the base class of any Procedural texture and contains most of the shareable code.
  14547. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14548. * @param name Define the name of the texture
  14549. * @param size Define the size of the texture to create
  14550. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14551. * @param scene Define the scene the texture belongs to
  14552. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14553. * @param generateMipMaps Define if the texture should creates mip maps or not
  14554. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14555. */
  14556. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14557. /**
  14558. * The effect that is created when initializing the post process.
  14559. * @returns The created effect corrisponding the the postprocess.
  14560. */
  14561. getEffect(): Effect;
  14562. /**
  14563. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14564. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14565. */
  14566. getContent(): Nullable<ArrayBufferView>;
  14567. private _createIndexBuffer;
  14568. /** @hidden */
  14569. _rebuild(): void;
  14570. /**
  14571. * Resets the texture in order to recreate its associated resources.
  14572. * This can be called in case of context loss
  14573. */
  14574. reset(): void;
  14575. protected _getDefines(): string;
  14576. /**
  14577. * Is the texture ready to be used ? (rendered at least once)
  14578. * @returns true if ready, otherwise, false.
  14579. */
  14580. isReady(): boolean;
  14581. /**
  14582. * Resets the refresh counter of the texture and start bak from scratch.
  14583. * Could be useful to regenerate the texture if it is setup to render only once.
  14584. */
  14585. resetRefreshCounter(): void;
  14586. /**
  14587. * Set the fragment shader to use in order to render the texture.
  14588. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14589. */
  14590. setFragment(fragment: any): void;
  14591. /**
  14592. * Define the refresh rate of the texture or the rendering frequency.
  14593. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14594. */
  14595. refreshRate: number;
  14596. /** @hidden */
  14597. _shouldRender(): boolean;
  14598. /**
  14599. * Get the size the texture is rendering at.
  14600. * @returns the size (texture is always squared)
  14601. */
  14602. getRenderSize(): number;
  14603. /**
  14604. * Resize the texture to new value.
  14605. * @param size Define the new size the texture should have
  14606. * @param generateMipMaps Define whether the new texture should create mip maps
  14607. */
  14608. resize(size: number, generateMipMaps: boolean): void;
  14609. private _checkUniform;
  14610. /**
  14611. * Set a texture in the shader program used to render.
  14612. * @param name Define the name of the uniform samplers as defined in the shader
  14613. * @param texture Define the texture to bind to this sampler
  14614. * @return the texture itself allowing "fluent" like uniform updates
  14615. */
  14616. setTexture(name: string, texture: Texture): ProceduralTexture;
  14617. /**
  14618. * Set a float in the shader.
  14619. * @param name Define the name of the uniform as defined in the shader
  14620. * @param value Define the value to give to the uniform
  14621. * @return the texture itself allowing "fluent" like uniform updates
  14622. */
  14623. setFloat(name: string, value: number): ProceduralTexture;
  14624. /**
  14625. * Set a int in the shader.
  14626. * @param name Define the name of the uniform as defined in the shader
  14627. * @param value Define the value to give to the uniform
  14628. * @return the texture itself allowing "fluent" like uniform updates
  14629. */
  14630. setInt(name: string, value: number): ProceduralTexture;
  14631. /**
  14632. * Set an array of floats in the shader.
  14633. * @param name Define the name of the uniform as defined in the shader
  14634. * @param value Define the value to give to the uniform
  14635. * @return the texture itself allowing "fluent" like uniform updates
  14636. */
  14637. setFloats(name: string, value: number[]): ProceduralTexture;
  14638. /**
  14639. * Set a vec3 in the shader from a Color3.
  14640. * @param name Define the name of the uniform as defined in the shader
  14641. * @param value Define the value to give to the uniform
  14642. * @return the texture itself allowing "fluent" like uniform updates
  14643. */
  14644. setColor3(name: string, value: Color3): ProceduralTexture;
  14645. /**
  14646. * Set a vec4 in the shader from a Color4.
  14647. * @param name Define the name of the uniform as defined in the shader
  14648. * @param value Define the value to give to the uniform
  14649. * @return the texture itself allowing "fluent" like uniform updates
  14650. */
  14651. setColor4(name: string, value: Color4): ProceduralTexture;
  14652. /**
  14653. * Set a vec2 in the shader from a Vector2.
  14654. * @param name Define the name of the uniform as defined in the shader
  14655. * @param value Define the value to give to the uniform
  14656. * @return the texture itself allowing "fluent" like uniform updates
  14657. */
  14658. setVector2(name: string, value: Vector2): ProceduralTexture;
  14659. /**
  14660. * Set a vec3 in the shader from a Vector3.
  14661. * @param name Define the name of the uniform as defined in the shader
  14662. * @param value Define the value to give to the uniform
  14663. * @return the texture itself allowing "fluent" like uniform updates
  14664. */
  14665. setVector3(name: string, value: Vector3): ProceduralTexture;
  14666. /**
  14667. * Set a mat4 in the shader from a MAtrix.
  14668. * @param name Define the name of the uniform as defined in the shader
  14669. * @param value Define the value to give to the uniform
  14670. * @return the texture itself allowing "fluent" like uniform updates
  14671. */
  14672. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14673. /**
  14674. * Render the texture to its associated render target.
  14675. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14676. */
  14677. render(useCameraPostProcess?: boolean): void;
  14678. /**
  14679. * Clone the texture.
  14680. * @returns the cloned texture
  14681. */
  14682. clone(): ProceduralTexture;
  14683. /**
  14684. * Dispose the texture and release its asoociated resources.
  14685. */
  14686. dispose(): void;
  14687. }
  14688. }
  14689. declare module "babylonjs/Particles/baseParticleSystem" {
  14690. import { Nullable } from "babylonjs/types";
  14691. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14693. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14694. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14695. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14696. import { Scene } from "babylonjs/scene";
  14697. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14698. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14699. import { Texture } from "babylonjs/Materials/Textures/texture";
  14700. import { Animation } from "babylonjs/Animations/animation";
  14701. /**
  14702. * This represents the base class for particle system in Babylon.
  14703. * 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.
  14704. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14705. * @example https://doc.babylonjs.com/babylon101/particles
  14706. */
  14707. export class BaseParticleSystem {
  14708. /**
  14709. * Source color is added to the destination color without alpha affecting the result
  14710. */
  14711. static BLENDMODE_ONEONE: number;
  14712. /**
  14713. * Blend current color and particle color using particle’s alpha
  14714. */
  14715. static BLENDMODE_STANDARD: number;
  14716. /**
  14717. * Add current color and particle color multiplied by particle’s alpha
  14718. */
  14719. static BLENDMODE_ADD: number;
  14720. /**
  14721. * Multiply current color with particle color
  14722. */
  14723. static BLENDMODE_MULTIPLY: number;
  14724. /**
  14725. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14726. */
  14727. static BLENDMODE_MULTIPLYADD: number;
  14728. /**
  14729. * List of animations used by the particle system.
  14730. */
  14731. animations: Animation[];
  14732. /**
  14733. * The id of the Particle system.
  14734. */
  14735. id: string;
  14736. /**
  14737. * The friendly name of the Particle system.
  14738. */
  14739. name: string;
  14740. /**
  14741. * The rendering group used by the Particle system to chose when to render.
  14742. */
  14743. renderingGroupId: number;
  14744. /**
  14745. * The emitter represents the Mesh or position we are attaching the particle system to.
  14746. */
  14747. emitter: Nullable<AbstractMesh | Vector3>;
  14748. /**
  14749. * The maximum number of particles to emit per frame
  14750. */
  14751. emitRate: number;
  14752. /**
  14753. * If you want to launch only a few particles at once, that can be done, as well.
  14754. */
  14755. manualEmitCount: number;
  14756. /**
  14757. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14758. */
  14759. updateSpeed: number;
  14760. /**
  14761. * The amount of time the particle system is running (depends of the overall update speed).
  14762. */
  14763. targetStopDuration: number;
  14764. /**
  14765. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14766. */
  14767. disposeOnStop: boolean;
  14768. /**
  14769. * Minimum power of emitting particles.
  14770. */
  14771. minEmitPower: number;
  14772. /**
  14773. * Maximum power of emitting particles.
  14774. */
  14775. maxEmitPower: number;
  14776. /**
  14777. * Minimum life time of emitting particles.
  14778. */
  14779. minLifeTime: number;
  14780. /**
  14781. * Maximum life time of emitting particles.
  14782. */
  14783. maxLifeTime: number;
  14784. /**
  14785. * Minimum Size of emitting particles.
  14786. */
  14787. minSize: number;
  14788. /**
  14789. * Maximum Size of emitting particles.
  14790. */
  14791. maxSize: number;
  14792. /**
  14793. * Minimum scale of emitting particles on X axis.
  14794. */
  14795. minScaleX: number;
  14796. /**
  14797. * Maximum scale of emitting particles on X axis.
  14798. */
  14799. maxScaleX: number;
  14800. /**
  14801. * Minimum scale of emitting particles on Y axis.
  14802. */
  14803. minScaleY: number;
  14804. /**
  14805. * Maximum scale of emitting particles on Y axis.
  14806. */
  14807. maxScaleY: number;
  14808. /**
  14809. * Gets or sets the minimal initial rotation in radians.
  14810. */
  14811. minInitialRotation: number;
  14812. /**
  14813. * Gets or sets the maximal initial rotation in radians.
  14814. */
  14815. maxInitialRotation: number;
  14816. /**
  14817. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14818. */
  14819. minAngularSpeed: number;
  14820. /**
  14821. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14822. */
  14823. maxAngularSpeed: number;
  14824. /**
  14825. * The texture used to render each particle. (this can be a spritesheet)
  14826. */
  14827. particleTexture: Nullable<Texture>;
  14828. /**
  14829. * The layer mask we are rendering the particles through.
  14830. */
  14831. layerMask: number;
  14832. /**
  14833. * This can help using your own shader to render the particle system.
  14834. * The according effect will be created
  14835. */
  14836. customShader: any;
  14837. /**
  14838. * By default particle system starts as soon as they are created. This prevents the
  14839. * automatic start to happen and let you decide when to start emitting particles.
  14840. */
  14841. preventAutoStart: boolean;
  14842. private _noiseTexture;
  14843. /**
  14844. * Gets or sets a texture used to add random noise to particle positions
  14845. */
  14846. noiseTexture: Nullable<ProceduralTexture>;
  14847. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14848. noiseStrength: Vector3;
  14849. /**
  14850. * Callback triggered when the particle animation is ending.
  14851. */
  14852. onAnimationEnd: Nullable<() => void>;
  14853. /**
  14854. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14855. */
  14856. blendMode: number;
  14857. /**
  14858. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14859. * to override the particles.
  14860. */
  14861. forceDepthWrite: boolean;
  14862. /** 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 */
  14863. preWarmCycles: number;
  14864. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14865. preWarmStepOffset: number;
  14866. /**
  14867. * 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)
  14868. */
  14869. spriteCellChangeSpeed: number;
  14870. /**
  14871. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14872. */
  14873. startSpriteCellID: number;
  14874. /**
  14875. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14876. */
  14877. endSpriteCellID: number;
  14878. /**
  14879. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14880. */
  14881. spriteCellWidth: number;
  14882. /**
  14883. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14884. */
  14885. spriteCellHeight: number;
  14886. /**
  14887. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14888. */
  14889. spriteRandomStartCell: boolean;
  14890. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14891. translationPivot: Vector2;
  14892. /** @hidden */
  14893. protected _isAnimationSheetEnabled: boolean;
  14894. /**
  14895. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14896. */
  14897. beginAnimationOnStart: boolean;
  14898. /**
  14899. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14900. */
  14901. beginAnimationFrom: number;
  14902. /**
  14903. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14904. */
  14905. beginAnimationTo: number;
  14906. /**
  14907. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14908. */
  14909. beginAnimationLoop: boolean;
  14910. /**
  14911. * Gets or sets a world offset applied to all particles
  14912. */
  14913. worldOffset: Vector3;
  14914. /**
  14915. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14916. */
  14917. isAnimationSheetEnabled: boolean;
  14918. /**
  14919. * Get hosting scene
  14920. * @returns the scene
  14921. */
  14922. getScene(): Scene;
  14923. /**
  14924. * You can use gravity if you want to give an orientation to your particles.
  14925. */
  14926. gravity: Vector3;
  14927. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14928. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14929. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14930. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14931. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14932. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14933. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14934. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14935. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14936. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14937. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14938. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14939. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14940. /**
  14941. * Defines the delay in milliseconds before starting the system (0 by default)
  14942. */
  14943. startDelay: number;
  14944. /**
  14945. * Gets the current list of drag gradients.
  14946. * You must use addDragGradient and removeDragGradient to udpate this list
  14947. * @returns the list of drag gradients
  14948. */
  14949. getDragGradients(): Nullable<Array<FactorGradient>>;
  14950. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14951. limitVelocityDamping: number;
  14952. /**
  14953. * Gets the current list of limit velocity gradients.
  14954. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14955. * @returns the list of limit velocity gradients
  14956. */
  14957. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14958. /**
  14959. * Gets the current list of color gradients.
  14960. * You must use addColorGradient and removeColorGradient to udpate this list
  14961. * @returns the list of color gradients
  14962. */
  14963. getColorGradients(): Nullable<Array<ColorGradient>>;
  14964. /**
  14965. * Gets the current list of size gradients.
  14966. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14967. * @returns the list of size gradients
  14968. */
  14969. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14970. /**
  14971. * Gets the current list of color remap gradients.
  14972. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14973. * @returns the list of color remap gradients
  14974. */
  14975. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14976. /**
  14977. * Gets the current list of alpha remap gradients.
  14978. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14979. * @returns the list of alpha remap gradients
  14980. */
  14981. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14982. /**
  14983. * Gets the current list of life time gradients.
  14984. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14985. * @returns the list of life time gradients
  14986. */
  14987. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14988. /**
  14989. * Gets the current list of angular speed gradients.
  14990. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14991. * @returns the list of angular speed gradients
  14992. */
  14993. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14994. /**
  14995. * Gets the current list of velocity gradients.
  14996. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14997. * @returns the list of velocity gradients
  14998. */
  14999. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15000. /**
  15001. * Gets the current list of start size gradients.
  15002. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15003. * @returns the list of start size gradients
  15004. */
  15005. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15006. /**
  15007. * Gets the current list of emit rate gradients.
  15008. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15009. * @returns the list of emit rate gradients
  15010. */
  15011. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15012. /**
  15013. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15014. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15015. */
  15016. direction1: Vector3;
  15017. /**
  15018. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15019. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15020. */
  15021. direction2: Vector3;
  15022. /**
  15023. * 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.
  15024. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15025. */
  15026. minEmitBox: Vector3;
  15027. /**
  15028. * 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.
  15029. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15030. */
  15031. maxEmitBox: Vector3;
  15032. /**
  15033. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15034. */
  15035. color1: Color4;
  15036. /**
  15037. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15038. */
  15039. color2: Color4;
  15040. /**
  15041. * Color the particle will have at the end of its lifetime
  15042. */
  15043. colorDead: Color4;
  15044. /**
  15045. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15046. */
  15047. textureMask: Color4;
  15048. /**
  15049. * The particle emitter type defines the emitter used by the particle system.
  15050. * It can be for example box, sphere, or cone...
  15051. */
  15052. particleEmitterType: IParticleEmitterType;
  15053. /** @hidden */
  15054. _isSubEmitter: boolean;
  15055. /**
  15056. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15057. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15058. */
  15059. billboardMode: number;
  15060. protected _isBillboardBased: boolean;
  15061. /**
  15062. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15063. */
  15064. isBillboardBased: boolean;
  15065. /**
  15066. * The scene the particle system belongs to.
  15067. */
  15068. protected _scene: Scene;
  15069. /**
  15070. * Local cache of defines for image processing.
  15071. */
  15072. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15073. /**
  15074. * Default configuration related to image processing available in the standard Material.
  15075. */
  15076. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15077. /**
  15078. * Gets the image processing configuration used either in this material.
  15079. */
  15080. /**
  15081. * Sets the Default image processing configuration used either in the this material.
  15082. *
  15083. * If sets to null, the scene one is in use.
  15084. */
  15085. imageProcessingConfiguration: ImageProcessingConfiguration;
  15086. /**
  15087. * Attaches a new image processing configuration to the Standard Material.
  15088. * @param configuration
  15089. */
  15090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15091. /** @hidden */
  15092. protected _reset(): void;
  15093. /** @hidden */
  15094. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15095. /**
  15096. * Instantiates a particle system.
  15097. * 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.
  15098. * @param name The name of the particle system
  15099. */
  15100. constructor(name: string);
  15101. /**
  15102. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15103. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15104. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15105. * @returns the emitter
  15106. */
  15107. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15108. /**
  15109. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15110. * @param radius The radius of the hemisphere to emit from
  15111. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15112. * @returns the emitter
  15113. */
  15114. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15115. /**
  15116. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15117. * @param radius The radius of the sphere to emit from
  15118. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15119. * @returns the emitter
  15120. */
  15121. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15122. /**
  15123. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15124. * @param radius The radius of the sphere to emit from
  15125. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15126. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15127. * @returns the emitter
  15128. */
  15129. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15130. /**
  15131. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15132. * @param radius The radius of the emission cylinder
  15133. * @param height The height of the emission cylinder
  15134. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15135. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15136. * @returns the emitter
  15137. */
  15138. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15139. /**
  15140. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15141. * @param radius The radius of the cylinder to emit from
  15142. * @param height The height of the emission cylinder
  15143. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15144. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15145. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15146. * @returns the emitter
  15147. */
  15148. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15149. /**
  15150. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15151. * @param radius The radius of the cone to emit from
  15152. * @param angle The base angle of the cone
  15153. * @returns the emitter
  15154. */
  15155. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15156. /**
  15157. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15158. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15159. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15160. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15161. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15162. * @returns the emitter
  15163. */
  15164. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15165. }
  15166. }
  15167. declare module "babylonjs/Particles/subEmitter" {
  15168. import { Scene } from "babylonjs/scene";
  15169. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15170. /**
  15171. * Type of sub emitter
  15172. */
  15173. export enum SubEmitterType {
  15174. /**
  15175. * Attached to the particle over it's lifetime
  15176. */
  15177. ATTACHED = 0,
  15178. /**
  15179. * Created when the particle dies
  15180. */
  15181. END = 1
  15182. }
  15183. /**
  15184. * Sub emitter class used to emit particles from an existing particle
  15185. */
  15186. export class SubEmitter {
  15187. /**
  15188. * the particle system to be used by the sub emitter
  15189. */
  15190. particleSystem: ParticleSystem;
  15191. /**
  15192. * Type of the submitter (Default: END)
  15193. */
  15194. type: SubEmitterType;
  15195. /**
  15196. * 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)
  15197. * Note: This only is supported when using an emitter of type Mesh
  15198. */
  15199. inheritDirection: boolean;
  15200. /**
  15201. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15202. */
  15203. inheritedVelocityAmount: number;
  15204. /**
  15205. * Creates a sub emitter
  15206. * @param particleSystem the particle system to be used by the sub emitter
  15207. */
  15208. constructor(
  15209. /**
  15210. * the particle system to be used by the sub emitter
  15211. */
  15212. particleSystem: ParticleSystem);
  15213. /**
  15214. * Clones the sub emitter
  15215. * @returns the cloned sub emitter
  15216. */
  15217. clone(): SubEmitter;
  15218. /**
  15219. * Serialize current object to a JSON object
  15220. * @returns the serialized object
  15221. */
  15222. serialize(): any;
  15223. /** @hidden */
  15224. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15225. /**
  15226. * Creates a new SubEmitter from a serialized JSON version
  15227. * @param serializationObject defines the JSON object to read from
  15228. * @param scene defines the hosting scene
  15229. * @param rootUrl defines the rootUrl for data loading
  15230. * @returns a new SubEmitter
  15231. */
  15232. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15233. /** Release associated resources */
  15234. dispose(): void;
  15235. }
  15236. }
  15237. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15238. /** @hidden */
  15239. export var clipPlaneFragmentDeclaration: {
  15240. name: string;
  15241. shader: string;
  15242. };
  15243. }
  15244. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15245. /** @hidden */
  15246. export var imageProcessingDeclaration: {
  15247. name: string;
  15248. shader: string;
  15249. };
  15250. }
  15251. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15252. /** @hidden */
  15253. export var imageProcessingFunctions: {
  15254. name: string;
  15255. shader: string;
  15256. };
  15257. }
  15258. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15259. /** @hidden */
  15260. export var clipPlaneFragment: {
  15261. name: string;
  15262. shader: string;
  15263. };
  15264. }
  15265. declare module "babylonjs/Shaders/particles.fragment" {
  15266. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15267. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15268. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15269. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15270. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15271. /** @hidden */
  15272. export var particlesPixelShader: {
  15273. name: string;
  15274. shader: string;
  15275. };
  15276. }
  15277. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15278. /** @hidden */
  15279. export var clipPlaneVertexDeclaration: {
  15280. name: string;
  15281. shader: string;
  15282. };
  15283. }
  15284. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15285. /** @hidden */
  15286. export var clipPlaneVertex: {
  15287. name: string;
  15288. shader: string;
  15289. };
  15290. }
  15291. declare module "babylonjs/Shaders/particles.vertex" {
  15292. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15293. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15294. /** @hidden */
  15295. export var particlesVertexShader: {
  15296. name: string;
  15297. shader: string;
  15298. };
  15299. }
  15300. declare module "babylonjs/Particles/particleSystem" {
  15301. import { Nullable } from "babylonjs/types";
  15302. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15303. import { Observable } from "babylonjs/Misc/observable";
  15304. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15305. import { Effect } from "babylonjs/Materials/effect";
  15306. import { Scene, IDisposable } from "babylonjs/scene";
  15307. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15308. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15309. import { Particle } from "babylonjs/Particles/particle";
  15310. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15311. import "babylonjs/Shaders/particles.fragment";
  15312. import "babylonjs/Shaders/particles.vertex";
  15313. /**
  15314. * This represents a particle system in Babylon.
  15315. * 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.
  15316. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15317. * @example https://doc.babylonjs.com/babylon101/particles
  15318. */
  15319. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15320. /**
  15321. * Billboard mode will only apply to Y axis
  15322. */
  15323. static readonly BILLBOARDMODE_Y: number;
  15324. /**
  15325. * Billboard mode will apply to all axes
  15326. */
  15327. static readonly BILLBOARDMODE_ALL: number;
  15328. /**
  15329. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15330. */
  15331. static readonly BILLBOARDMODE_STRETCHED: number;
  15332. /**
  15333. * This function can be defined to provide custom update for active particles.
  15334. * This function will be called instead of regular update (age, position, color, etc.).
  15335. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15336. */
  15337. updateFunction: (particles: Particle[]) => void;
  15338. private _emitterWorldMatrix;
  15339. /**
  15340. * This function can be defined to specify initial direction for every new particle.
  15341. * It by default use the emitterType defined function
  15342. */
  15343. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15344. /**
  15345. * This function can be defined to specify initial position for every new particle.
  15346. * It by default use the emitterType defined function
  15347. */
  15348. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15349. /**
  15350. * @hidden
  15351. */
  15352. _inheritedVelocityOffset: Vector3;
  15353. /**
  15354. * An event triggered when the system is disposed
  15355. */
  15356. onDisposeObservable: Observable<ParticleSystem>;
  15357. private _onDisposeObserver;
  15358. /**
  15359. * Sets a callback that will be triggered when the system is disposed
  15360. */
  15361. onDispose: () => void;
  15362. private _particles;
  15363. private _epsilon;
  15364. private _capacity;
  15365. private _stockParticles;
  15366. private _newPartsExcess;
  15367. private _vertexData;
  15368. private _vertexBuffer;
  15369. private _vertexBuffers;
  15370. private _spriteBuffer;
  15371. private _indexBuffer;
  15372. private _effect;
  15373. private _customEffect;
  15374. private _cachedDefines;
  15375. private _scaledColorStep;
  15376. private _colorDiff;
  15377. private _scaledDirection;
  15378. private _scaledGravity;
  15379. private _currentRenderId;
  15380. private _alive;
  15381. private _useInstancing;
  15382. private _started;
  15383. private _stopped;
  15384. private _actualFrame;
  15385. private _scaledUpdateSpeed;
  15386. private _vertexBufferSize;
  15387. /** @hidden */
  15388. _currentEmitRateGradient: Nullable<FactorGradient>;
  15389. /** @hidden */
  15390. _currentEmitRate1: number;
  15391. /** @hidden */
  15392. _currentEmitRate2: number;
  15393. /** @hidden */
  15394. _currentStartSizeGradient: Nullable<FactorGradient>;
  15395. /** @hidden */
  15396. _currentStartSize1: number;
  15397. /** @hidden */
  15398. _currentStartSize2: number;
  15399. private readonly _rawTextureWidth;
  15400. private _rampGradientsTexture;
  15401. private _useRampGradients;
  15402. /** Gets or sets a boolean indicating that ramp gradients must be used
  15403. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15404. */
  15405. useRampGradients: boolean;
  15406. /**
  15407. * 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.
  15408. * 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: [])
  15409. */
  15410. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15411. private _subEmitters;
  15412. /**
  15413. * @hidden
  15414. * If the particle systems emitter should be disposed when the particle system is disposed
  15415. */
  15416. _disposeEmitterOnDispose: boolean;
  15417. /**
  15418. * The current active Sub-systems, this property is used by the root particle system only.
  15419. */
  15420. activeSubSystems: Array<ParticleSystem>;
  15421. private _rootParticleSystem;
  15422. /**
  15423. * Gets the current list of active particles
  15424. */
  15425. readonly particles: Particle[];
  15426. /**
  15427. * Returns the string "ParticleSystem"
  15428. * @returns a string containing the class name
  15429. */
  15430. getClassName(): string;
  15431. /**
  15432. * Instantiates a particle system.
  15433. * 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.
  15434. * @param name The name of the particle system
  15435. * @param capacity The max number of particles alive at the same time
  15436. * @param scene The scene the particle system belongs to
  15437. * @param customEffect a custom effect used to change the way particles are rendered by default
  15438. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15439. * @param epsilon Offset used to render the particles
  15440. */
  15441. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15442. private _addFactorGradient;
  15443. private _removeFactorGradient;
  15444. /**
  15445. * Adds a new life time gradient
  15446. * @param gradient defines the gradient to use (between 0 and 1)
  15447. * @param factor defines the life time factor to affect to the specified gradient
  15448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15449. * @returns the current particle system
  15450. */
  15451. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15452. /**
  15453. * Remove a specific life time gradient
  15454. * @param gradient defines the gradient to remove
  15455. * @returns the current particle system
  15456. */
  15457. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15458. /**
  15459. * Adds a new size gradient
  15460. * @param gradient defines the gradient to use (between 0 and 1)
  15461. * @param factor defines the size factor to affect to the specified gradient
  15462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15463. * @returns the current particle system
  15464. */
  15465. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15466. /**
  15467. * Remove a specific size gradient
  15468. * @param gradient defines the gradient to remove
  15469. * @returns the current particle system
  15470. */
  15471. removeSizeGradient(gradient: number): IParticleSystem;
  15472. /**
  15473. * Adds a new color remap gradient
  15474. * @param gradient defines the gradient to use (between 0 and 1)
  15475. * @param min defines the color remap minimal range
  15476. * @param max defines the color remap maximal range
  15477. * @returns the current particle system
  15478. */
  15479. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15480. /**
  15481. * Remove a specific color remap gradient
  15482. * @param gradient defines the gradient to remove
  15483. * @returns the current particle system
  15484. */
  15485. removeColorRemapGradient(gradient: number): IParticleSystem;
  15486. /**
  15487. * Adds a new alpha remap gradient
  15488. * @param gradient defines the gradient to use (between 0 and 1)
  15489. * @param min defines the alpha remap minimal range
  15490. * @param max defines the alpha remap maximal range
  15491. * @returns the current particle system
  15492. */
  15493. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15494. /**
  15495. * Remove a specific alpha remap gradient
  15496. * @param gradient defines the gradient to remove
  15497. * @returns the current particle system
  15498. */
  15499. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15500. /**
  15501. * Adds a new angular speed gradient
  15502. * @param gradient defines the gradient to use (between 0 and 1)
  15503. * @param factor defines the angular speed to affect to the specified gradient
  15504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15505. * @returns the current particle system
  15506. */
  15507. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15508. /**
  15509. * Remove a specific angular speed gradient
  15510. * @param gradient defines the gradient to remove
  15511. * @returns the current particle system
  15512. */
  15513. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15514. /**
  15515. * Adds a new velocity gradient
  15516. * @param gradient defines the gradient to use (between 0 and 1)
  15517. * @param factor defines the velocity to affect to the specified gradient
  15518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15519. * @returns the current particle system
  15520. */
  15521. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15522. /**
  15523. * Remove a specific velocity gradient
  15524. * @param gradient defines the gradient to remove
  15525. * @returns the current particle system
  15526. */
  15527. removeVelocityGradient(gradient: number): IParticleSystem;
  15528. /**
  15529. * Adds a new limit velocity gradient
  15530. * @param gradient defines the gradient to use (between 0 and 1)
  15531. * @param factor defines the limit velocity value to affect to the specified gradient
  15532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15533. * @returns the current particle system
  15534. */
  15535. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15536. /**
  15537. * Remove a specific limit velocity gradient
  15538. * @param gradient defines the gradient to remove
  15539. * @returns the current particle system
  15540. */
  15541. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15542. /**
  15543. * Adds a new drag gradient
  15544. * @param gradient defines the gradient to use (between 0 and 1)
  15545. * @param factor defines the drag value to affect to the specified gradient
  15546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15547. * @returns the current particle system
  15548. */
  15549. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15550. /**
  15551. * Remove a specific drag gradient
  15552. * @param gradient defines the gradient to remove
  15553. * @returns the current particle system
  15554. */
  15555. removeDragGradient(gradient: number): IParticleSystem;
  15556. /**
  15557. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15558. * @param gradient defines the gradient to use (between 0 and 1)
  15559. * @param factor defines the emit rate value to affect to the specified gradient
  15560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15561. * @returns the current particle system
  15562. */
  15563. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15564. /**
  15565. * Remove a specific emit rate gradient
  15566. * @param gradient defines the gradient to remove
  15567. * @returns the current particle system
  15568. */
  15569. removeEmitRateGradient(gradient: number): IParticleSystem;
  15570. /**
  15571. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15572. * @param gradient defines the gradient to use (between 0 and 1)
  15573. * @param factor defines the start size value to affect to the specified gradient
  15574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15575. * @returns the current particle system
  15576. */
  15577. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15578. /**
  15579. * Remove a specific start size gradient
  15580. * @param gradient defines the gradient to remove
  15581. * @returns the current particle system
  15582. */
  15583. removeStartSizeGradient(gradient: number): IParticleSystem;
  15584. private _createRampGradientTexture;
  15585. /**
  15586. * Gets the current list of ramp gradients.
  15587. * You must use addRampGradient and removeRampGradient to udpate this list
  15588. * @returns the list of ramp gradients
  15589. */
  15590. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15591. /**
  15592. * Adds a new ramp gradient used to remap particle colors
  15593. * @param gradient defines the gradient to use (between 0 and 1)
  15594. * @param color defines the color to affect to the specified gradient
  15595. * @returns the current particle system
  15596. */
  15597. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15598. /**
  15599. * Remove a specific ramp gradient
  15600. * @param gradient defines the gradient to remove
  15601. * @returns the current particle system
  15602. */
  15603. removeRampGradient(gradient: number): ParticleSystem;
  15604. /**
  15605. * Adds a new color gradient
  15606. * @param gradient defines the gradient to use (between 0 and 1)
  15607. * @param color1 defines the color to affect to the specified gradient
  15608. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15609. * @returns this particle system
  15610. */
  15611. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15612. /**
  15613. * Remove a specific color gradient
  15614. * @param gradient defines the gradient to remove
  15615. * @returns this particle system
  15616. */
  15617. removeColorGradient(gradient: number): IParticleSystem;
  15618. private _fetchR;
  15619. protected _reset(): void;
  15620. private _resetEffect;
  15621. private _createVertexBuffers;
  15622. private _createIndexBuffer;
  15623. /**
  15624. * Gets the maximum number of particles active at the same time.
  15625. * @returns The max number of active particles.
  15626. */
  15627. getCapacity(): number;
  15628. /**
  15629. * Gets whether there are still active particles in the system.
  15630. * @returns True if it is alive, otherwise false.
  15631. */
  15632. isAlive(): boolean;
  15633. /**
  15634. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15635. * @returns True if it has been started, otherwise false.
  15636. */
  15637. isStarted(): boolean;
  15638. private _prepareSubEmitterInternalArray;
  15639. /**
  15640. * Starts the particle system and begins to emit
  15641. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15642. */
  15643. start(delay?: number): void;
  15644. /**
  15645. * Stops the particle system.
  15646. * @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.
  15647. */
  15648. stop(stopSubEmitters?: boolean): void;
  15649. /**
  15650. * Remove all active particles
  15651. */
  15652. reset(): void;
  15653. /**
  15654. * @hidden (for internal use only)
  15655. */
  15656. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15657. /**
  15658. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15659. * Its lifetime will start back at 0.
  15660. */
  15661. recycleParticle: (particle: Particle) => void;
  15662. private _stopSubEmitters;
  15663. private _createParticle;
  15664. private _removeFromRoot;
  15665. private _emitFromParticle;
  15666. private _update;
  15667. /** @hidden */
  15668. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15669. /** @hidden */
  15670. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15671. /** @hidden */
  15672. private _getEffect;
  15673. /**
  15674. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15675. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15676. */
  15677. animate(preWarmOnly?: boolean): void;
  15678. private _appendParticleVertices;
  15679. /**
  15680. * Rebuilds the particle system.
  15681. */
  15682. rebuild(): void;
  15683. /**
  15684. * Is this system ready to be used/rendered
  15685. * @return true if the system is ready
  15686. */
  15687. isReady(): boolean;
  15688. private _render;
  15689. /**
  15690. * Renders the particle system in its current state.
  15691. * @returns the current number of particles
  15692. */
  15693. render(): number;
  15694. /**
  15695. * Disposes the particle system and free the associated resources
  15696. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15697. */
  15698. dispose(disposeTexture?: boolean): void;
  15699. /**
  15700. * Clones the particle system.
  15701. * @param name The name of the cloned object
  15702. * @param newEmitter The new emitter to use
  15703. * @returns the cloned particle system
  15704. */
  15705. clone(name: string, newEmitter: any): ParticleSystem;
  15706. /**
  15707. * Serializes the particle system to a JSON object.
  15708. * @returns the JSON object
  15709. */
  15710. serialize(): any;
  15711. /** @hidden */
  15712. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15713. /** @hidden */
  15714. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15715. /**
  15716. * Parses a JSON object to create a particle system.
  15717. * @param parsedParticleSystem The JSON object to parse
  15718. * @param scene The scene to create the particle system in
  15719. * @param rootUrl The root url to use to load external dependencies like texture
  15720. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15721. * @returns the Parsed particle system
  15722. */
  15723. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15724. }
  15725. }
  15726. declare module "babylonjs/Particles/particle" {
  15727. import { Nullable } from "babylonjs/types";
  15728. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15729. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15730. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15731. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15732. /**
  15733. * A particle represents one of the element emitted by a particle system.
  15734. * This is mainly define by its coordinates, direction, velocity and age.
  15735. */
  15736. export class Particle {
  15737. /**
  15738. * The particle system the particle belongs to.
  15739. */
  15740. particleSystem: ParticleSystem;
  15741. private static _Count;
  15742. /**
  15743. * Unique ID of the particle
  15744. */
  15745. id: number;
  15746. /**
  15747. * The world position of the particle in the scene.
  15748. */
  15749. position: Vector3;
  15750. /**
  15751. * The world direction of the particle in the scene.
  15752. */
  15753. direction: Vector3;
  15754. /**
  15755. * The color of the particle.
  15756. */
  15757. color: Color4;
  15758. /**
  15759. * The color change of the particle per step.
  15760. */
  15761. colorStep: Color4;
  15762. /**
  15763. * Defines how long will the life of the particle be.
  15764. */
  15765. lifeTime: number;
  15766. /**
  15767. * The current age of the particle.
  15768. */
  15769. age: number;
  15770. /**
  15771. * The current size of the particle.
  15772. */
  15773. size: number;
  15774. /**
  15775. * The current scale of the particle.
  15776. */
  15777. scale: Vector2;
  15778. /**
  15779. * The current angle of the particle.
  15780. */
  15781. angle: number;
  15782. /**
  15783. * Defines how fast is the angle changing.
  15784. */
  15785. angularSpeed: number;
  15786. /**
  15787. * Defines the cell index used by the particle to be rendered from a sprite.
  15788. */
  15789. cellIndex: number;
  15790. /**
  15791. * The information required to support color remapping
  15792. */
  15793. remapData: Vector4;
  15794. /** @hidden */
  15795. _randomCellOffset?: number;
  15796. /** @hidden */
  15797. _initialDirection: Nullable<Vector3>;
  15798. /** @hidden */
  15799. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15800. /** @hidden */
  15801. _initialStartSpriteCellID: number;
  15802. /** @hidden */
  15803. _initialEndSpriteCellID: number;
  15804. /** @hidden */
  15805. _currentColorGradient: Nullable<ColorGradient>;
  15806. /** @hidden */
  15807. _currentColor1: Color4;
  15808. /** @hidden */
  15809. _currentColor2: Color4;
  15810. /** @hidden */
  15811. _currentSizeGradient: Nullable<FactorGradient>;
  15812. /** @hidden */
  15813. _currentSize1: number;
  15814. /** @hidden */
  15815. _currentSize2: number;
  15816. /** @hidden */
  15817. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15818. /** @hidden */
  15819. _currentAngularSpeed1: number;
  15820. /** @hidden */
  15821. _currentAngularSpeed2: number;
  15822. /** @hidden */
  15823. _currentVelocityGradient: Nullable<FactorGradient>;
  15824. /** @hidden */
  15825. _currentVelocity1: number;
  15826. /** @hidden */
  15827. _currentVelocity2: number;
  15828. /** @hidden */
  15829. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15830. /** @hidden */
  15831. _currentLimitVelocity1: number;
  15832. /** @hidden */
  15833. _currentLimitVelocity2: number;
  15834. /** @hidden */
  15835. _currentDragGradient: Nullable<FactorGradient>;
  15836. /** @hidden */
  15837. _currentDrag1: number;
  15838. /** @hidden */
  15839. _currentDrag2: number;
  15840. /** @hidden */
  15841. _randomNoiseCoordinates1: Vector3;
  15842. /** @hidden */
  15843. _randomNoiseCoordinates2: Vector3;
  15844. /**
  15845. * Creates a new instance Particle
  15846. * @param particleSystem the particle system the particle belongs to
  15847. */
  15848. constructor(
  15849. /**
  15850. * The particle system the particle belongs to.
  15851. */
  15852. particleSystem: ParticleSystem);
  15853. private updateCellInfoFromSystem;
  15854. /**
  15855. * Defines how the sprite cell index is updated for the particle
  15856. */
  15857. updateCellIndex(): void;
  15858. /** @hidden */
  15859. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15860. /** @hidden */
  15861. _inheritParticleInfoToSubEmitters(): void;
  15862. /** @hidden */
  15863. _reset(): void;
  15864. /**
  15865. * Copy the properties of particle to another one.
  15866. * @param other the particle to copy the information to.
  15867. */
  15868. copyTo(other: Particle): void;
  15869. }
  15870. }
  15871. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15872. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15873. import { Effect } from "babylonjs/Materials/effect";
  15874. import { Particle } from "babylonjs/Particles/particle";
  15875. /**
  15876. * Particle emitter represents a volume emitting particles.
  15877. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15878. */
  15879. export interface IParticleEmitterType {
  15880. /**
  15881. * Called by the particle System when the direction is computed for the created particle.
  15882. * @param worldMatrix is the world matrix of the particle system
  15883. * @param directionToUpdate is the direction vector to update with the result
  15884. * @param particle is the particle we are computed the direction for
  15885. */
  15886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15887. /**
  15888. * Called by the particle System when the position is computed for the created particle.
  15889. * @param worldMatrix is the world matrix of the particle system
  15890. * @param positionToUpdate is the position vector to update with the result
  15891. * @param particle is the particle we are computed the position for
  15892. */
  15893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15894. /**
  15895. * Clones the current emitter and returns a copy of it
  15896. * @returns the new emitter
  15897. */
  15898. clone(): IParticleEmitterType;
  15899. /**
  15900. * Called by the GPUParticleSystem to setup the update shader
  15901. * @param effect defines the update shader
  15902. */
  15903. applyToShader(effect: Effect): void;
  15904. /**
  15905. * Returns a string to use to update the GPU particles update shader
  15906. * @returns the effect defines string
  15907. */
  15908. getEffectDefines(): string;
  15909. /**
  15910. * Returns a string representing the class name
  15911. * @returns a string containing the class name
  15912. */
  15913. getClassName(): string;
  15914. /**
  15915. * Serializes the particle system to a JSON object.
  15916. * @returns the JSON object
  15917. */
  15918. serialize(): any;
  15919. /**
  15920. * Parse properties from a JSON object
  15921. * @param serializationObject defines the JSON object
  15922. */
  15923. parse(serializationObject: any): void;
  15924. }
  15925. }
  15926. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15927. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15928. import { Effect } from "babylonjs/Materials/effect";
  15929. import { Particle } from "babylonjs/Particles/particle";
  15930. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15931. /**
  15932. * Particle emitter emitting particles from the inside of a box.
  15933. * It emits the particles randomly between 2 given directions.
  15934. */
  15935. export class BoxParticleEmitter implements IParticleEmitterType {
  15936. /**
  15937. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15938. */
  15939. direction1: Vector3;
  15940. /**
  15941. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15942. */
  15943. direction2: Vector3;
  15944. /**
  15945. * 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.
  15946. */
  15947. minEmitBox: Vector3;
  15948. /**
  15949. * 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.
  15950. */
  15951. maxEmitBox: Vector3;
  15952. /**
  15953. * Creates a new instance BoxParticleEmitter
  15954. */
  15955. constructor();
  15956. /**
  15957. * Called by the particle System when the direction is computed for the created particle.
  15958. * @param worldMatrix is the world matrix of the particle system
  15959. * @param directionToUpdate is the direction vector to update with the result
  15960. * @param particle is the particle we are computed the direction for
  15961. */
  15962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15963. /**
  15964. * Called by the particle System when the position is computed for the created particle.
  15965. * @param worldMatrix is the world matrix of the particle system
  15966. * @param positionToUpdate is the position vector to update with the result
  15967. * @param particle is the particle we are computed the position for
  15968. */
  15969. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15970. /**
  15971. * Clones the current emitter and returns a copy of it
  15972. * @returns the new emitter
  15973. */
  15974. clone(): BoxParticleEmitter;
  15975. /**
  15976. * Called by the GPUParticleSystem to setup the update shader
  15977. * @param effect defines the update shader
  15978. */
  15979. applyToShader(effect: Effect): void;
  15980. /**
  15981. * Returns a string to use to update the GPU particles update shader
  15982. * @returns a string containng the defines string
  15983. */
  15984. getEffectDefines(): string;
  15985. /**
  15986. * Returns the string "BoxParticleEmitter"
  15987. * @returns a string containing the class name
  15988. */
  15989. getClassName(): string;
  15990. /**
  15991. * Serializes the particle system to a JSON object.
  15992. * @returns the JSON object
  15993. */
  15994. serialize(): any;
  15995. /**
  15996. * Parse properties from a JSON object
  15997. * @param serializationObject defines the JSON object
  15998. */
  15999. parse(serializationObject: any): void;
  16000. }
  16001. }
  16002. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16003. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16004. import { Effect } from "babylonjs/Materials/effect";
  16005. import { Particle } from "babylonjs/Particles/particle";
  16006. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16007. /**
  16008. * Particle emitter emitting particles from the inside of a cone.
  16009. * It emits the particles alongside the cone volume from the base to the particle.
  16010. * The emission direction might be randomized.
  16011. */
  16012. export class ConeParticleEmitter implements IParticleEmitterType {
  16013. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16014. directionRandomizer: number;
  16015. private _radius;
  16016. private _angle;
  16017. private _height;
  16018. /**
  16019. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16020. */
  16021. radiusRange: number;
  16022. /**
  16023. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16024. */
  16025. heightRange: number;
  16026. /**
  16027. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16028. */
  16029. emitFromSpawnPointOnly: boolean;
  16030. /**
  16031. * Gets or sets the radius of the emission cone
  16032. */
  16033. radius: number;
  16034. /**
  16035. * Gets or sets the angle of the emission cone
  16036. */
  16037. angle: number;
  16038. private _buildHeight;
  16039. /**
  16040. * Creates a new instance ConeParticleEmitter
  16041. * @param radius the radius of the emission cone (1 by default)
  16042. * @param angle the cone base angle (PI by default)
  16043. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16044. */
  16045. constructor(radius?: number, angle?: number,
  16046. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16047. directionRandomizer?: number);
  16048. /**
  16049. * Called by the particle System when the direction is computed for the created particle.
  16050. * @param worldMatrix is the world matrix of the particle system
  16051. * @param directionToUpdate is the direction vector to update with the result
  16052. * @param particle is the particle we are computed the direction for
  16053. */
  16054. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16055. /**
  16056. * Called by the particle System when the position is computed for the created particle.
  16057. * @param worldMatrix is the world matrix of the particle system
  16058. * @param positionToUpdate is the position vector to update with the result
  16059. * @param particle is the particle we are computed the position for
  16060. */
  16061. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16062. /**
  16063. * Clones the current emitter and returns a copy of it
  16064. * @returns the new emitter
  16065. */
  16066. clone(): ConeParticleEmitter;
  16067. /**
  16068. * Called by the GPUParticleSystem to setup the update shader
  16069. * @param effect defines the update shader
  16070. */
  16071. applyToShader(effect: Effect): void;
  16072. /**
  16073. * Returns a string to use to update the GPU particles update shader
  16074. * @returns a string containng the defines string
  16075. */
  16076. getEffectDefines(): string;
  16077. /**
  16078. * Returns the string "ConeParticleEmitter"
  16079. * @returns a string containing the class name
  16080. */
  16081. getClassName(): string;
  16082. /**
  16083. * Serializes the particle system to a JSON object.
  16084. * @returns the JSON object
  16085. */
  16086. serialize(): any;
  16087. /**
  16088. * Parse properties from a JSON object
  16089. * @param serializationObject defines the JSON object
  16090. */
  16091. parse(serializationObject: any): void;
  16092. }
  16093. }
  16094. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16095. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16096. import { Effect } from "babylonjs/Materials/effect";
  16097. import { Particle } from "babylonjs/Particles/particle";
  16098. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16099. /**
  16100. * Particle emitter emitting particles from the inside of a cylinder.
  16101. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16102. */
  16103. export class CylinderParticleEmitter implements IParticleEmitterType {
  16104. /**
  16105. * The radius of the emission cylinder.
  16106. */
  16107. radius: number;
  16108. /**
  16109. * The height of the emission cylinder.
  16110. */
  16111. height: number;
  16112. /**
  16113. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16114. */
  16115. radiusRange: number;
  16116. /**
  16117. * How much to randomize the particle direction [0-1].
  16118. */
  16119. directionRandomizer: number;
  16120. /**
  16121. * Creates a new instance CylinderParticleEmitter
  16122. * @param radius the radius of the emission cylinder (1 by default)
  16123. * @param height the height of the emission cylinder (1 by default)
  16124. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16125. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16126. */
  16127. constructor(
  16128. /**
  16129. * The radius of the emission cylinder.
  16130. */
  16131. radius?: number,
  16132. /**
  16133. * The height of the emission cylinder.
  16134. */
  16135. height?: number,
  16136. /**
  16137. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16138. */
  16139. radiusRange?: number,
  16140. /**
  16141. * How much to randomize the particle direction [0-1].
  16142. */
  16143. directionRandomizer?: number);
  16144. /**
  16145. * Called by the particle System when the direction is computed for the created particle.
  16146. * @param worldMatrix is the world matrix of the particle system
  16147. * @param directionToUpdate is the direction vector to update with the result
  16148. * @param particle is the particle we are computed the direction for
  16149. */
  16150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16151. /**
  16152. * Called by the particle System when the position is computed for the created particle.
  16153. * @param worldMatrix is the world matrix of the particle system
  16154. * @param positionToUpdate is the position vector to update with the result
  16155. * @param particle is the particle we are computed the position for
  16156. */
  16157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16158. /**
  16159. * Clones the current emitter and returns a copy of it
  16160. * @returns the new emitter
  16161. */
  16162. clone(): CylinderParticleEmitter;
  16163. /**
  16164. * Called by the GPUParticleSystem to setup the update shader
  16165. * @param effect defines the update shader
  16166. */
  16167. applyToShader(effect: Effect): void;
  16168. /**
  16169. * Returns a string to use to update the GPU particles update shader
  16170. * @returns a string containng the defines string
  16171. */
  16172. getEffectDefines(): string;
  16173. /**
  16174. * Returns the string "CylinderParticleEmitter"
  16175. * @returns a string containing the class name
  16176. */
  16177. getClassName(): string;
  16178. /**
  16179. * Serializes the particle system to a JSON object.
  16180. * @returns the JSON object
  16181. */
  16182. serialize(): any;
  16183. /**
  16184. * Parse properties from a JSON object
  16185. * @param serializationObject defines the JSON object
  16186. */
  16187. parse(serializationObject: any): void;
  16188. }
  16189. /**
  16190. * Particle emitter emitting particles from the inside of a cylinder.
  16191. * It emits the particles randomly between two vectors.
  16192. */
  16193. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16194. /**
  16195. * The min limit of the emission direction.
  16196. */
  16197. direction1: Vector3;
  16198. /**
  16199. * The max limit of the emission direction.
  16200. */
  16201. direction2: Vector3;
  16202. /**
  16203. * Creates a new instance CylinderDirectedParticleEmitter
  16204. * @param radius the radius of the emission cylinder (1 by default)
  16205. * @param height the height of the emission cylinder (1 by default)
  16206. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16207. * @param direction1 the min limit of the emission direction (up vector by default)
  16208. * @param direction2 the max limit of the emission direction (up vector by default)
  16209. */
  16210. constructor(radius?: number, height?: number, radiusRange?: number,
  16211. /**
  16212. * The min limit of the emission direction.
  16213. */
  16214. direction1?: Vector3,
  16215. /**
  16216. * The max limit of the emission direction.
  16217. */
  16218. direction2?: Vector3);
  16219. /**
  16220. * Called by the particle System when the direction is computed for the created particle.
  16221. * @param worldMatrix is the world matrix of the particle system
  16222. * @param directionToUpdate is the direction vector to update with the result
  16223. * @param particle is the particle we are computed the direction for
  16224. */
  16225. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16226. /**
  16227. * Clones the current emitter and returns a copy of it
  16228. * @returns the new emitter
  16229. */
  16230. clone(): CylinderDirectedParticleEmitter;
  16231. /**
  16232. * Called by the GPUParticleSystem to setup the update shader
  16233. * @param effect defines the update shader
  16234. */
  16235. applyToShader(effect: Effect): void;
  16236. /**
  16237. * Returns a string to use to update the GPU particles update shader
  16238. * @returns a string containng the defines string
  16239. */
  16240. getEffectDefines(): string;
  16241. /**
  16242. * Returns the string "CylinderDirectedParticleEmitter"
  16243. * @returns a string containing the class name
  16244. */
  16245. getClassName(): string;
  16246. /**
  16247. * Serializes the particle system to a JSON object.
  16248. * @returns the JSON object
  16249. */
  16250. serialize(): any;
  16251. /**
  16252. * Parse properties from a JSON object
  16253. * @param serializationObject defines the JSON object
  16254. */
  16255. parse(serializationObject: any): void;
  16256. }
  16257. }
  16258. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16259. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16260. import { Effect } from "babylonjs/Materials/effect";
  16261. import { Particle } from "babylonjs/Particles/particle";
  16262. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16263. /**
  16264. * Particle emitter emitting particles from the inside of a hemisphere.
  16265. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16266. */
  16267. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16268. /**
  16269. * The radius of the emission hemisphere.
  16270. */
  16271. radius: number;
  16272. /**
  16273. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16274. */
  16275. radiusRange: number;
  16276. /**
  16277. * How much to randomize the particle direction [0-1].
  16278. */
  16279. directionRandomizer: number;
  16280. /**
  16281. * Creates a new instance HemisphericParticleEmitter
  16282. * @param radius the radius of the emission hemisphere (1 by default)
  16283. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16284. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16285. */
  16286. constructor(
  16287. /**
  16288. * The radius of the emission hemisphere.
  16289. */
  16290. radius?: number,
  16291. /**
  16292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16293. */
  16294. radiusRange?: number,
  16295. /**
  16296. * How much to randomize the particle direction [0-1].
  16297. */
  16298. directionRandomizer?: number);
  16299. /**
  16300. * Called by the particle System when the direction is computed for the created particle.
  16301. * @param worldMatrix is the world matrix of the particle system
  16302. * @param directionToUpdate is the direction vector to update with the result
  16303. * @param particle is the particle we are computed the direction for
  16304. */
  16305. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16306. /**
  16307. * Called by the particle System when the position is computed for the created particle.
  16308. * @param worldMatrix is the world matrix of the particle system
  16309. * @param positionToUpdate is the position vector to update with the result
  16310. * @param particle is the particle we are computed the position for
  16311. */
  16312. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16313. /**
  16314. * Clones the current emitter and returns a copy of it
  16315. * @returns the new emitter
  16316. */
  16317. clone(): HemisphericParticleEmitter;
  16318. /**
  16319. * Called by the GPUParticleSystem to setup the update shader
  16320. * @param effect defines the update shader
  16321. */
  16322. applyToShader(effect: Effect): void;
  16323. /**
  16324. * Returns a string to use to update the GPU particles update shader
  16325. * @returns a string containng the defines string
  16326. */
  16327. getEffectDefines(): string;
  16328. /**
  16329. * Returns the string "HemisphericParticleEmitter"
  16330. * @returns a string containing the class name
  16331. */
  16332. getClassName(): string;
  16333. /**
  16334. * Serializes the particle system to a JSON object.
  16335. * @returns the JSON object
  16336. */
  16337. serialize(): any;
  16338. /**
  16339. * Parse properties from a JSON object
  16340. * @param serializationObject defines the JSON object
  16341. */
  16342. parse(serializationObject: any): void;
  16343. }
  16344. }
  16345. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16346. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16347. import { Effect } from "babylonjs/Materials/effect";
  16348. import { Particle } from "babylonjs/Particles/particle";
  16349. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16350. /**
  16351. * Particle emitter emitting particles from a point.
  16352. * It emits the particles randomly between 2 given directions.
  16353. */
  16354. export class PointParticleEmitter implements IParticleEmitterType {
  16355. /**
  16356. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16357. */
  16358. direction1: Vector3;
  16359. /**
  16360. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16361. */
  16362. direction2: Vector3;
  16363. /**
  16364. * Creates a new instance PointParticleEmitter
  16365. */
  16366. constructor();
  16367. /**
  16368. * Called by the particle System when the direction is computed for the created particle.
  16369. * @param worldMatrix is the world matrix of the particle system
  16370. * @param directionToUpdate is the direction vector to update with the result
  16371. * @param particle is the particle we are computed the direction for
  16372. */
  16373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16374. /**
  16375. * Called by the particle System when the position is computed for the created particle.
  16376. * @param worldMatrix is the world matrix of the particle system
  16377. * @param positionToUpdate is the position vector to update with the result
  16378. * @param particle is the particle we are computed the position for
  16379. */
  16380. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16381. /**
  16382. * Clones the current emitter and returns a copy of it
  16383. * @returns the new emitter
  16384. */
  16385. clone(): PointParticleEmitter;
  16386. /**
  16387. * Called by the GPUParticleSystem to setup the update shader
  16388. * @param effect defines the update shader
  16389. */
  16390. applyToShader(effect: Effect): void;
  16391. /**
  16392. * Returns a string to use to update the GPU particles update shader
  16393. * @returns a string containng the defines string
  16394. */
  16395. getEffectDefines(): string;
  16396. /**
  16397. * Returns the string "PointParticleEmitter"
  16398. * @returns a string containing the class name
  16399. */
  16400. getClassName(): string;
  16401. /**
  16402. * Serializes the particle system to a JSON object.
  16403. * @returns the JSON object
  16404. */
  16405. serialize(): any;
  16406. /**
  16407. * Parse properties from a JSON object
  16408. * @param serializationObject defines the JSON object
  16409. */
  16410. parse(serializationObject: any): void;
  16411. }
  16412. }
  16413. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16414. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16415. import { Effect } from "babylonjs/Materials/effect";
  16416. import { Particle } from "babylonjs/Particles/particle";
  16417. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16418. /**
  16419. * Particle emitter emitting particles from the inside of a sphere.
  16420. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16421. */
  16422. export class SphereParticleEmitter implements IParticleEmitterType {
  16423. /**
  16424. * The radius of the emission sphere.
  16425. */
  16426. radius: number;
  16427. /**
  16428. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16429. */
  16430. radiusRange: number;
  16431. /**
  16432. * How much to randomize the particle direction [0-1].
  16433. */
  16434. directionRandomizer: number;
  16435. /**
  16436. * Creates a new instance SphereParticleEmitter
  16437. * @param radius the radius of the emission sphere (1 by default)
  16438. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16439. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16440. */
  16441. constructor(
  16442. /**
  16443. * The radius of the emission sphere.
  16444. */
  16445. radius?: number,
  16446. /**
  16447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16448. */
  16449. radiusRange?: number,
  16450. /**
  16451. * How much to randomize the particle direction [0-1].
  16452. */
  16453. directionRandomizer?: number);
  16454. /**
  16455. * Called by the particle System when the direction is computed for the created particle.
  16456. * @param worldMatrix is the world matrix of the particle system
  16457. * @param directionToUpdate is the direction vector to update with the result
  16458. * @param particle is the particle we are computed the direction for
  16459. */
  16460. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16461. /**
  16462. * Called by the particle System when the position is computed for the created particle.
  16463. * @param worldMatrix is the world matrix of the particle system
  16464. * @param positionToUpdate is the position vector to update with the result
  16465. * @param particle is the particle we are computed the position for
  16466. */
  16467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16468. /**
  16469. * Clones the current emitter and returns a copy of it
  16470. * @returns the new emitter
  16471. */
  16472. clone(): SphereParticleEmitter;
  16473. /**
  16474. * Called by the GPUParticleSystem to setup the update shader
  16475. * @param effect defines the update shader
  16476. */
  16477. applyToShader(effect: Effect): void;
  16478. /**
  16479. * Returns a string to use to update the GPU particles update shader
  16480. * @returns a string containng the defines string
  16481. */
  16482. getEffectDefines(): string;
  16483. /**
  16484. * Returns the string "SphereParticleEmitter"
  16485. * @returns a string containing the class name
  16486. */
  16487. getClassName(): string;
  16488. /**
  16489. * Serializes the particle system to a JSON object.
  16490. * @returns the JSON object
  16491. */
  16492. serialize(): any;
  16493. /**
  16494. * Parse properties from a JSON object
  16495. * @param serializationObject defines the JSON object
  16496. */
  16497. parse(serializationObject: any): void;
  16498. }
  16499. /**
  16500. * Particle emitter emitting particles from the inside of a sphere.
  16501. * It emits the particles randomly between two vectors.
  16502. */
  16503. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16504. /**
  16505. * The min limit of the emission direction.
  16506. */
  16507. direction1: Vector3;
  16508. /**
  16509. * The max limit of the emission direction.
  16510. */
  16511. direction2: Vector3;
  16512. /**
  16513. * Creates a new instance SphereDirectedParticleEmitter
  16514. * @param radius the radius of the emission sphere (1 by default)
  16515. * @param direction1 the min limit of the emission direction (up vector by default)
  16516. * @param direction2 the max limit of the emission direction (up vector by default)
  16517. */
  16518. constructor(radius?: number,
  16519. /**
  16520. * The min limit of the emission direction.
  16521. */
  16522. direction1?: Vector3,
  16523. /**
  16524. * The max limit of the emission direction.
  16525. */
  16526. direction2?: Vector3);
  16527. /**
  16528. * Called by the particle System when the direction is computed for the created particle.
  16529. * @param worldMatrix is the world matrix of the particle system
  16530. * @param directionToUpdate is the direction vector to update with the result
  16531. * @param particle is the particle we are computed the direction for
  16532. */
  16533. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16534. /**
  16535. * Clones the current emitter and returns a copy of it
  16536. * @returns the new emitter
  16537. */
  16538. clone(): SphereDirectedParticleEmitter;
  16539. /**
  16540. * Called by the GPUParticleSystem to setup the update shader
  16541. * @param effect defines the update shader
  16542. */
  16543. applyToShader(effect: Effect): void;
  16544. /**
  16545. * Returns a string to use to update the GPU particles update shader
  16546. * @returns a string containng the defines string
  16547. */
  16548. getEffectDefines(): string;
  16549. /**
  16550. * Returns the string "SphereDirectedParticleEmitter"
  16551. * @returns a string containing the class name
  16552. */
  16553. getClassName(): string;
  16554. /**
  16555. * Serializes the particle system to a JSON object.
  16556. * @returns the JSON object
  16557. */
  16558. serialize(): any;
  16559. /**
  16560. * Parse properties from a JSON object
  16561. * @param serializationObject defines the JSON object
  16562. */
  16563. parse(serializationObject: any): void;
  16564. }
  16565. }
  16566. declare module "babylonjs/Particles/EmitterTypes/index" {
  16567. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16568. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16569. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16570. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16571. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16572. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16573. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16574. }
  16575. declare module "babylonjs/Particles/IParticleSystem" {
  16576. import { Nullable } from "babylonjs/types";
  16577. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16580. import { Texture } from "babylonjs/Materials/Textures/texture";
  16581. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16582. import { Scene } from "babylonjs/scene";
  16583. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16584. import { Animation } from "babylonjs/Animations/animation";
  16585. /**
  16586. * Interface representing a particle system in Babylon.js.
  16587. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16588. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16589. */
  16590. export interface IParticleSystem {
  16591. /**
  16592. * List of animations used by the particle system.
  16593. */
  16594. animations: Animation[];
  16595. /**
  16596. * The id of the Particle system.
  16597. */
  16598. id: string;
  16599. /**
  16600. * The name of the Particle system.
  16601. */
  16602. name: string;
  16603. /**
  16604. * The emitter represents the Mesh or position we are attaching the particle system to.
  16605. */
  16606. emitter: Nullable<AbstractMesh | Vector3>;
  16607. /**
  16608. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16609. */
  16610. isBillboardBased: boolean;
  16611. /**
  16612. * The rendering group used by the Particle system to chose when to render.
  16613. */
  16614. renderingGroupId: number;
  16615. /**
  16616. * The layer mask we are rendering the particles through.
  16617. */
  16618. layerMask: number;
  16619. /**
  16620. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16621. */
  16622. updateSpeed: number;
  16623. /**
  16624. * The amount of time the particle system is running (depends of the overall update speed).
  16625. */
  16626. targetStopDuration: number;
  16627. /**
  16628. * The texture used to render each particle. (this can be a spritesheet)
  16629. */
  16630. particleTexture: Nullable<Texture>;
  16631. /**
  16632. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16633. */
  16634. blendMode: number;
  16635. /**
  16636. * Minimum life time of emitting particles.
  16637. */
  16638. minLifeTime: number;
  16639. /**
  16640. * Maximum life time of emitting particles.
  16641. */
  16642. maxLifeTime: number;
  16643. /**
  16644. * Minimum Size of emitting particles.
  16645. */
  16646. minSize: number;
  16647. /**
  16648. * Maximum Size of emitting particles.
  16649. */
  16650. maxSize: number;
  16651. /**
  16652. * Minimum scale of emitting particles on X axis.
  16653. */
  16654. minScaleX: number;
  16655. /**
  16656. * Maximum scale of emitting particles on X axis.
  16657. */
  16658. maxScaleX: number;
  16659. /**
  16660. * Minimum scale of emitting particles on Y axis.
  16661. */
  16662. minScaleY: number;
  16663. /**
  16664. * Maximum scale of emitting particles on Y axis.
  16665. */
  16666. maxScaleY: number;
  16667. /**
  16668. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16669. */
  16670. color1: Color4;
  16671. /**
  16672. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16673. */
  16674. color2: Color4;
  16675. /**
  16676. * Color the particle will have at the end of its lifetime.
  16677. */
  16678. colorDead: Color4;
  16679. /**
  16680. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16681. */
  16682. emitRate: number;
  16683. /**
  16684. * You can use gravity if you want to give an orientation to your particles.
  16685. */
  16686. gravity: Vector3;
  16687. /**
  16688. * Minimum power of emitting particles.
  16689. */
  16690. minEmitPower: number;
  16691. /**
  16692. * Maximum power of emitting particles.
  16693. */
  16694. maxEmitPower: number;
  16695. /**
  16696. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16697. */
  16698. minAngularSpeed: number;
  16699. /**
  16700. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16701. */
  16702. maxAngularSpeed: number;
  16703. /**
  16704. * Gets or sets the minimal initial rotation in radians.
  16705. */
  16706. minInitialRotation: number;
  16707. /**
  16708. * Gets or sets the maximal initial rotation in radians.
  16709. */
  16710. maxInitialRotation: number;
  16711. /**
  16712. * The particle emitter type defines the emitter used by the particle system.
  16713. * It can be for example box, sphere, or cone...
  16714. */
  16715. particleEmitterType: Nullable<IParticleEmitterType>;
  16716. /**
  16717. * Defines the delay in milliseconds before starting the system (0 by default)
  16718. */
  16719. startDelay: number;
  16720. /**
  16721. * 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
  16722. */
  16723. preWarmCycles: number;
  16724. /**
  16725. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16726. */
  16727. preWarmStepOffset: number;
  16728. /**
  16729. * 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)
  16730. */
  16731. spriteCellChangeSpeed: number;
  16732. /**
  16733. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16734. */
  16735. startSpriteCellID: number;
  16736. /**
  16737. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16738. */
  16739. endSpriteCellID: number;
  16740. /**
  16741. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16742. */
  16743. spriteCellWidth: number;
  16744. /**
  16745. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16746. */
  16747. spriteCellHeight: number;
  16748. /**
  16749. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16750. */
  16751. spriteRandomStartCell: boolean;
  16752. /**
  16753. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16754. */
  16755. isAnimationSheetEnabled: boolean;
  16756. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16757. translationPivot: Vector2;
  16758. /**
  16759. * Gets or sets a texture used to add random noise to particle positions
  16760. */
  16761. noiseTexture: Nullable<BaseTexture>;
  16762. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16763. noiseStrength: Vector3;
  16764. /**
  16765. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16766. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16767. */
  16768. billboardMode: number;
  16769. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16770. limitVelocityDamping: number;
  16771. /**
  16772. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16773. */
  16774. beginAnimationOnStart: boolean;
  16775. /**
  16776. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16777. */
  16778. beginAnimationFrom: number;
  16779. /**
  16780. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16781. */
  16782. beginAnimationTo: number;
  16783. /**
  16784. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16785. */
  16786. beginAnimationLoop: boolean;
  16787. /**
  16788. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16789. */
  16790. disposeOnStop: boolean;
  16791. /**
  16792. * Gets the maximum number of particles active at the same time.
  16793. * @returns The max number of active particles.
  16794. */
  16795. getCapacity(): number;
  16796. /**
  16797. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16798. * @returns True if it has been started, otherwise false.
  16799. */
  16800. isStarted(): boolean;
  16801. /**
  16802. * Animates the particle system for this frame.
  16803. */
  16804. animate(): void;
  16805. /**
  16806. * Renders the particle system in its current state.
  16807. * @returns the current number of particles
  16808. */
  16809. render(): number;
  16810. /**
  16811. * Dispose the particle system and frees its associated resources.
  16812. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16813. */
  16814. dispose(disposeTexture?: boolean): void;
  16815. /**
  16816. * Clones the particle system.
  16817. * @param name The name of the cloned object
  16818. * @param newEmitter The new emitter to use
  16819. * @returns the cloned particle system
  16820. */
  16821. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16822. /**
  16823. * Serializes the particle system to a JSON object.
  16824. * @returns the JSON object
  16825. */
  16826. serialize(): any;
  16827. /**
  16828. * Rebuild the particle system
  16829. */
  16830. rebuild(): void;
  16831. /**
  16832. * Starts the particle system and begins to emit
  16833. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16834. */
  16835. start(delay?: number): void;
  16836. /**
  16837. * Stops the particle system.
  16838. */
  16839. stop(): void;
  16840. /**
  16841. * Remove all active particles
  16842. */
  16843. reset(): void;
  16844. /**
  16845. * Is this system ready to be used/rendered
  16846. * @return true if the system is ready
  16847. */
  16848. isReady(): boolean;
  16849. /**
  16850. * Adds a new color gradient
  16851. * @param gradient defines the gradient to use (between 0 and 1)
  16852. * @param color1 defines the color to affect to the specified gradient
  16853. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16854. * @returns the current particle system
  16855. */
  16856. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16857. /**
  16858. * Remove a specific color gradient
  16859. * @param gradient defines the gradient to remove
  16860. * @returns the current particle system
  16861. */
  16862. removeColorGradient(gradient: number): IParticleSystem;
  16863. /**
  16864. * Adds a new size gradient
  16865. * @param gradient defines the gradient to use (between 0 and 1)
  16866. * @param factor defines the size factor to affect to the specified gradient
  16867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16868. * @returns the current particle system
  16869. */
  16870. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16871. /**
  16872. * Remove a specific size gradient
  16873. * @param gradient defines the gradient to remove
  16874. * @returns the current particle system
  16875. */
  16876. removeSizeGradient(gradient: number): IParticleSystem;
  16877. /**
  16878. * Gets the current list of color gradients.
  16879. * You must use addColorGradient and removeColorGradient to udpate this list
  16880. * @returns the list of color gradients
  16881. */
  16882. getColorGradients(): Nullable<Array<ColorGradient>>;
  16883. /**
  16884. * Gets the current list of size gradients.
  16885. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16886. * @returns the list of size gradients
  16887. */
  16888. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16889. /**
  16890. * Gets the current list of angular speed gradients.
  16891. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16892. * @returns the list of angular speed gradients
  16893. */
  16894. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16895. /**
  16896. * Adds a new angular speed gradient
  16897. * @param gradient defines the gradient to use (between 0 and 1)
  16898. * @param factor defines the angular speed to affect to the specified gradient
  16899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16900. * @returns the current particle system
  16901. */
  16902. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16903. /**
  16904. * Remove a specific angular speed gradient
  16905. * @param gradient defines the gradient to remove
  16906. * @returns the current particle system
  16907. */
  16908. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16909. /**
  16910. * Gets the current list of velocity gradients.
  16911. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16912. * @returns the list of velocity gradients
  16913. */
  16914. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16915. /**
  16916. * Adds a new velocity gradient
  16917. * @param gradient defines the gradient to use (between 0 and 1)
  16918. * @param factor defines the velocity to affect to the specified gradient
  16919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16920. * @returns the current particle system
  16921. */
  16922. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16923. /**
  16924. * Remove a specific velocity gradient
  16925. * @param gradient defines the gradient to remove
  16926. * @returns the current particle system
  16927. */
  16928. removeVelocityGradient(gradient: number): IParticleSystem;
  16929. /**
  16930. * Gets the current list of limit velocity gradients.
  16931. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16932. * @returns the list of limit velocity gradients
  16933. */
  16934. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16935. /**
  16936. * Adds a new limit velocity gradient
  16937. * @param gradient defines the gradient to use (between 0 and 1)
  16938. * @param factor defines the limit velocity to affect to the specified gradient
  16939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16940. * @returns the current particle system
  16941. */
  16942. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16943. /**
  16944. * Remove a specific limit velocity gradient
  16945. * @param gradient defines the gradient to remove
  16946. * @returns the current particle system
  16947. */
  16948. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16949. /**
  16950. * Adds a new drag gradient
  16951. * @param gradient defines the gradient to use (between 0 and 1)
  16952. * @param factor defines the drag to affect to the specified gradient
  16953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16954. * @returns the current particle system
  16955. */
  16956. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16957. /**
  16958. * Remove a specific drag gradient
  16959. * @param gradient defines the gradient to remove
  16960. * @returns the current particle system
  16961. */
  16962. removeDragGradient(gradient: number): IParticleSystem;
  16963. /**
  16964. * Gets the current list of drag gradients.
  16965. * You must use addDragGradient and removeDragGradient to udpate this list
  16966. * @returns the list of drag gradients
  16967. */
  16968. getDragGradients(): Nullable<Array<FactorGradient>>;
  16969. /**
  16970. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16971. * @param gradient defines the gradient to use (between 0 and 1)
  16972. * @param factor defines the emit rate to affect to the specified gradient
  16973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16974. * @returns the current particle system
  16975. */
  16976. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16977. /**
  16978. * Remove a specific emit rate gradient
  16979. * @param gradient defines the gradient to remove
  16980. * @returns the current particle system
  16981. */
  16982. removeEmitRateGradient(gradient: number): IParticleSystem;
  16983. /**
  16984. * Gets the current list of emit rate gradients.
  16985. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16986. * @returns the list of emit rate gradients
  16987. */
  16988. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16989. /**
  16990. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16991. * @param gradient defines the gradient to use (between 0 and 1)
  16992. * @param factor defines the start size to affect to the specified gradient
  16993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16994. * @returns the current particle system
  16995. */
  16996. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16997. /**
  16998. * Remove a specific start size gradient
  16999. * @param gradient defines the gradient to remove
  17000. * @returns the current particle system
  17001. */
  17002. removeStartSizeGradient(gradient: number): IParticleSystem;
  17003. /**
  17004. * Gets the current list of start size gradients.
  17005. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17006. * @returns the list of start size gradients
  17007. */
  17008. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17009. /**
  17010. * Adds a new life time gradient
  17011. * @param gradient defines the gradient to use (between 0 and 1)
  17012. * @param factor defines the life time factor to affect to the specified gradient
  17013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17014. * @returns the current particle system
  17015. */
  17016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17017. /**
  17018. * Remove a specific life time gradient
  17019. * @param gradient defines the gradient to remove
  17020. * @returns the current particle system
  17021. */
  17022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17023. /**
  17024. * Gets the current list of life time gradients.
  17025. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17026. * @returns the list of life time gradients
  17027. */
  17028. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17029. /**
  17030. * Gets the current list of color gradients.
  17031. * You must use addColorGradient and removeColorGradient to udpate this list
  17032. * @returns the list of color gradients
  17033. */
  17034. getColorGradients(): Nullable<Array<ColorGradient>>;
  17035. /**
  17036. * Adds a new ramp gradient used to remap particle colors
  17037. * @param gradient defines the gradient to use (between 0 and 1)
  17038. * @param color defines the color to affect to the specified gradient
  17039. * @returns the current particle system
  17040. */
  17041. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17042. /**
  17043. * Gets the current list of ramp gradients.
  17044. * You must use addRampGradient and removeRampGradient to udpate this list
  17045. * @returns the list of ramp gradients
  17046. */
  17047. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17048. /** Gets or sets a boolean indicating that ramp gradients must be used
  17049. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17050. */
  17051. useRampGradients: boolean;
  17052. /**
  17053. * Adds a new color remap gradient
  17054. * @param gradient defines the gradient to use (between 0 and 1)
  17055. * @param min defines the color remap minimal range
  17056. * @param max defines the color remap maximal range
  17057. * @returns the current particle system
  17058. */
  17059. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17060. /**
  17061. * Gets the current list of color remap gradients.
  17062. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17063. * @returns the list of color remap gradients
  17064. */
  17065. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17066. /**
  17067. * Adds a new alpha remap gradient
  17068. * @param gradient defines the gradient to use (between 0 and 1)
  17069. * @param min defines the alpha remap minimal range
  17070. * @param max defines the alpha remap maximal range
  17071. * @returns the current particle system
  17072. */
  17073. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17074. /**
  17075. * Gets the current list of alpha remap gradients.
  17076. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17077. * @returns the list of alpha remap gradients
  17078. */
  17079. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17080. /**
  17081. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17082. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17083. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17084. * @returns the emitter
  17085. */
  17086. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17087. /**
  17088. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17089. * @param radius The radius of the hemisphere to emit from
  17090. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17091. * @returns the emitter
  17092. */
  17093. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17094. /**
  17095. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17096. * @param radius The radius of the sphere to emit from
  17097. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17098. * @returns the emitter
  17099. */
  17100. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17101. /**
  17102. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17103. * @param radius The radius of the sphere to emit from
  17104. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17105. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17106. * @returns the emitter
  17107. */
  17108. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17109. /**
  17110. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17111. * @param radius The radius of the emission cylinder
  17112. * @param height The height of the emission cylinder
  17113. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17114. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17115. * @returns the emitter
  17116. */
  17117. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17118. /**
  17119. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17120. * @param radius The radius of the cylinder to emit from
  17121. * @param height The height of the emission cylinder
  17122. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17123. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17124. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17125. * @returns the emitter
  17126. */
  17127. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17128. /**
  17129. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17130. * @param radius The radius of the cone to emit from
  17131. * @param angle The base angle of the cone
  17132. * @returns the emitter
  17133. */
  17134. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17135. /**
  17136. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17137. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17138. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17139. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17140. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17141. * @returns the emitter
  17142. */
  17143. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17144. /**
  17145. * Get hosting scene
  17146. * @returns the scene
  17147. */
  17148. getScene(): Scene;
  17149. }
  17150. }
  17151. declare module "babylonjs/Meshes/instancedMesh" {
  17152. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17153. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17154. import { Camera } from "babylonjs/Cameras/camera";
  17155. import { Node } from "babylonjs/node";
  17156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17157. import { Mesh } from "babylonjs/Meshes/mesh";
  17158. import { Material } from "babylonjs/Materials/material";
  17159. import { Skeleton } from "babylonjs/Bones/skeleton";
  17160. import { Light } from "babylonjs/Lights/light";
  17161. /**
  17162. * Creates an instance based on a source mesh.
  17163. */
  17164. export class InstancedMesh extends AbstractMesh {
  17165. private _sourceMesh;
  17166. private _currentLOD;
  17167. /** @hidden */
  17168. _indexInSourceMeshInstanceArray: number;
  17169. constructor(name: string, source: Mesh);
  17170. /**
  17171. * Returns the string "InstancedMesh".
  17172. */
  17173. getClassName(): string;
  17174. /** Gets the list of lights affecting that mesh */
  17175. readonly lightSources: Light[];
  17176. _resyncLightSources(): void;
  17177. _resyncLighSource(light: Light): void;
  17178. _removeLightSource(light: Light): void;
  17179. /**
  17180. * If the source mesh receives shadows
  17181. */
  17182. readonly receiveShadows: boolean;
  17183. /**
  17184. * The material of the source mesh
  17185. */
  17186. readonly material: Nullable<Material>;
  17187. /**
  17188. * Visibility of the source mesh
  17189. */
  17190. readonly visibility: number;
  17191. /**
  17192. * Skeleton of the source mesh
  17193. */
  17194. readonly skeleton: Nullable<Skeleton>;
  17195. /**
  17196. * Rendering ground id of the source mesh
  17197. */
  17198. renderingGroupId: number;
  17199. /**
  17200. * Returns the total number of vertices (integer).
  17201. */
  17202. getTotalVertices(): number;
  17203. /**
  17204. * Returns a positive integer : the total number of indices in this mesh geometry.
  17205. * @returns the numner of indices or zero if the mesh has no geometry.
  17206. */
  17207. getTotalIndices(): number;
  17208. /**
  17209. * The source mesh of the instance
  17210. */
  17211. readonly sourceMesh: Mesh;
  17212. /**
  17213. * Is this node ready to be used/rendered
  17214. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17215. * @return {boolean} is it ready
  17216. */
  17217. isReady(completeCheck?: boolean): boolean;
  17218. /**
  17219. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17220. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17221. * @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.
  17222. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17223. */
  17224. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17225. /**
  17226. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17227. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17228. * The `data` are either a numeric array either a Float32Array.
  17229. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17230. * 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).
  17231. * Note that a new underlying VertexBuffer object is created each call.
  17232. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17233. *
  17234. * Possible `kind` values :
  17235. * - VertexBuffer.PositionKind
  17236. * - VertexBuffer.UVKind
  17237. * - VertexBuffer.UV2Kind
  17238. * - VertexBuffer.UV3Kind
  17239. * - VertexBuffer.UV4Kind
  17240. * - VertexBuffer.UV5Kind
  17241. * - VertexBuffer.UV6Kind
  17242. * - VertexBuffer.ColorKind
  17243. * - VertexBuffer.MatricesIndicesKind
  17244. * - VertexBuffer.MatricesIndicesExtraKind
  17245. * - VertexBuffer.MatricesWeightsKind
  17246. * - VertexBuffer.MatricesWeightsExtraKind
  17247. *
  17248. * Returns the Mesh.
  17249. */
  17250. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17251. /**
  17252. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17253. * If the mesh has no geometry, it is simply returned as it is.
  17254. * The `data` are either a numeric array either a Float32Array.
  17255. * No new underlying VertexBuffer object is created.
  17256. * 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.
  17257. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17258. *
  17259. * Possible `kind` values :
  17260. * - VertexBuffer.PositionKind
  17261. * - VertexBuffer.UVKind
  17262. * - VertexBuffer.UV2Kind
  17263. * - VertexBuffer.UV3Kind
  17264. * - VertexBuffer.UV4Kind
  17265. * - VertexBuffer.UV5Kind
  17266. * - VertexBuffer.UV6Kind
  17267. * - VertexBuffer.ColorKind
  17268. * - VertexBuffer.MatricesIndicesKind
  17269. * - VertexBuffer.MatricesIndicesExtraKind
  17270. * - VertexBuffer.MatricesWeightsKind
  17271. * - VertexBuffer.MatricesWeightsExtraKind
  17272. *
  17273. * Returns the Mesh.
  17274. */
  17275. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17276. /**
  17277. * Sets the mesh indices.
  17278. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17279. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17280. * This method creates a new index buffer each call.
  17281. * Returns the Mesh.
  17282. */
  17283. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17284. /**
  17285. * Boolean : True if the mesh owns the requested kind of data.
  17286. */
  17287. isVerticesDataPresent(kind: string): boolean;
  17288. /**
  17289. * Returns an array of indices (IndicesArray).
  17290. */
  17291. getIndices(): Nullable<IndicesArray>;
  17292. readonly _positions: Nullable<Vector3[]>;
  17293. /**
  17294. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17295. * This means the mesh underlying bounding box and sphere are recomputed.
  17296. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17297. * @returns the current mesh
  17298. */
  17299. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17300. /** @hidden */
  17301. _preActivate(): InstancedMesh;
  17302. /** @hidden */
  17303. _activate(renderId: number): boolean;
  17304. /** @hidden */
  17305. _postActivate(): void;
  17306. getWorldMatrix(): Matrix;
  17307. readonly isAnInstance: boolean;
  17308. /**
  17309. * Returns the current associated LOD AbstractMesh.
  17310. */
  17311. getLOD(camera: Camera): AbstractMesh;
  17312. /** @hidden */
  17313. _syncSubMeshes(): InstancedMesh;
  17314. /** @hidden */
  17315. _generatePointsArray(): boolean;
  17316. /**
  17317. * Creates a new InstancedMesh from the current mesh.
  17318. * - name (string) : the cloned mesh name
  17319. * - newParent (optional Node) : the optional Node to parent the clone to.
  17320. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17321. *
  17322. * Returns the clone.
  17323. */
  17324. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17325. /**
  17326. * Disposes the InstancedMesh.
  17327. * Returns nothing.
  17328. */
  17329. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17330. }
  17331. }
  17332. declare module "babylonjs/Materials/shaderMaterial" {
  17333. import { Scene } from "babylonjs/scene";
  17334. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17336. import { Mesh } from "babylonjs/Meshes/mesh";
  17337. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17339. import { Texture } from "babylonjs/Materials/Textures/texture";
  17340. import { Material } from "babylonjs/Materials/material";
  17341. /**
  17342. * Defines the options associated with the creation of a shader material.
  17343. */
  17344. export interface IShaderMaterialOptions {
  17345. /**
  17346. * Does the material work in alpha blend mode
  17347. */
  17348. needAlphaBlending: boolean;
  17349. /**
  17350. * Does the material work in alpha test mode
  17351. */
  17352. needAlphaTesting: boolean;
  17353. /**
  17354. * The list of attribute names used in the shader
  17355. */
  17356. attributes: string[];
  17357. /**
  17358. * The list of unifrom names used in the shader
  17359. */
  17360. uniforms: string[];
  17361. /**
  17362. * The list of UBO names used in the shader
  17363. */
  17364. uniformBuffers: string[];
  17365. /**
  17366. * The list of sampler names used in the shader
  17367. */
  17368. samplers: string[];
  17369. /**
  17370. * The list of defines used in the shader
  17371. */
  17372. defines: string[];
  17373. }
  17374. /**
  17375. * 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.
  17376. *
  17377. * This returned material effects how the mesh will look based on the code in the shaders.
  17378. *
  17379. * @see http://doc.babylonjs.com/how_to/shader_material
  17380. */
  17381. export class ShaderMaterial extends Material {
  17382. private _shaderPath;
  17383. private _options;
  17384. private _textures;
  17385. private _textureArrays;
  17386. private _floats;
  17387. private _ints;
  17388. private _floatsArrays;
  17389. private _colors3;
  17390. private _colors3Arrays;
  17391. private _colors4;
  17392. private _vectors2;
  17393. private _vectors3;
  17394. private _vectors4;
  17395. private _matrices;
  17396. private _matrices3x3;
  17397. private _matrices2x2;
  17398. private _vectors2Arrays;
  17399. private _vectors3Arrays;
  17400. private _cachedWorldViewMatrix;
  17401. private _renderId;
  17402. /**
  17403. * Instantiate a new shader material.
  17404. * 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.
  17405. * This returned material effects how the mesh will look based on the code in the shaders.
  17406. * @see http://doc.babylonjs.com/how_to/shader_material
  17407. * @param name Define the name of the material in the scene
  17408. * @param scene Define the scene the material belongs to
  17409. * @param shaderPath Defines the route to the shader code in one of three ways:
  17410. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17411. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17412. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17413. * @param options Define the options used to create the shader
  17414. */
  17415. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17416. /**
  17417. * Gets the options used to compile the shader.
  17418. * They can be modified to trigger a new compilation
  17419. */
  17420. readonly options: IShaderMaterialOptions;
  17421. /**
  17422. * Gets the current class name of the material e.g. "ShaderMaterial"
  17423. * Mainly use in serialization.
  17424. * @returns the class name
  17425. */
  17426. getClassName(): string;
  17427. /**
  17428. * Specifies if the material will require alpha blending
  17429. * @returns a boolean specifying if alpha blending is needed
  17430. */
  17431. needAlphaBlending(): boolean;
  17432. /**
  17433. * Specifies if this material should be rendered in alpha test mode
  17434. * @returns a boolean specifying if an alpha test is needed.
  17435. */
  17436. needAlphaTesting(): boolean;
  17437. private _checkUniform;
  17438. /**
  17439. * Set a texture in the shader.
  17440. * @param name Define the name of the uniform samplers as defined in the shader
  17441. * @param texture Define the texture to bind to this sampler
  17442. * @return the material itself allowing "fluent" like uniform updates
  17443. */
  17444. setTexture(name: string, texture: Texture): ShaderMaterial;
  17445. /**
  17446. * Set a texture array in the shader.
  17447. * @param name Define the name of the uniform sampler array as defined in the shader
  17448. * @param textures Define the list of textures to bind to this sampler
  17449. * @return the material itself allowing "fluent" like uniform updates
  17450. */
  17451. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17452. /**
  17453. * Set a float in the shader.
  17454. * @param name Define the name of the uniform as defined in the shader
  17455. * @param value Define the value to give to the uniform
  17456. * @return the material itself allowing "fluent" like uniform updates
  17457. */
  17458. setFloat(name: string, value: number): ShaderMaterial;
  17459. /**
  17460. * Set a int in the shader.
  17461. * @param name Define the name of the uniform as defined in the shader
  17462. * @param value Define the value to give to the uniform
  17463. * @return the material itself allowing "fluent" like uniform updates
  17464. */
  17465. setInt(name: string, value: number): ShaderMaterial;
  17466. /**
  17467. * Set an array of floats in the shader.
  17468. * @param name Define the name of the uniform as defined in the shader
  17469. * @param value Define the value to give to the uniform
  17470. * @return the material itself allowing "fluent" like uniform updates
  17471. */
  17472. setFloats(name: string, value: number[]): ShaderMaterial;
  17473. /**
  17474. * Set a vec3 in the shader from a Color3.
  17475. * @param name Define the name of the uniform as defined in the shader
  17476. * @param value Define the value to give to the uniform
  17477. * @return the material itself allowing "fluent" like uniform updates
  17478. */
  17479. setColor3(name: string, value: Color3): ShaderMaterial;
  17480. /**
  17481. * Set a vec3 array in the shader from a Color3 array.
  17482. * @param name Define the name of the uniform as defined in the shader
  17483. * @param value Define the value to give to the uniform
  17484. * @return the material itself allowing "fluent" like uniform updates
  17485. */
  17486. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17487. /**
  17488. * Set a vec4 in the shader from a Color4.
  17489. * @param name Define the name of the uniform as defined in the shader
  17490. * @param value Define the value to give to the uniform
  17491. * @return the material itself allowing "fluent" like uniform updates
  17492. */
  17493. setColor4(name: string, value: Color4): ShaderMaterial;
  17494. /**
  17495. * Set a vec2 in the shader from a Vector2.
  17496. * @param name Define the name of the uniform as defined in the shader
  17497. * @param value Define the value to give to the uniform
  17498. * @return the material itself allowing "fluent" like uniform updates
  17499. */
  17500. setVector2(name: string, value: Vector2): ShaderMaterial;
  17501. /**
  17502. * Set a vec3 in the shader from a Vector3.
  17503. * @param name Define the name of the uniform as defined in the shader
  17504. * @param value Define the value to give to the uniform
  17505. * @return the material itself allowing "fluent" like uniform updates
  17506. */
  17507. setVector3(name: string, value: Vector3): ShaderMaterial;
  17508. /**
  17509. * Set a vec4 in the shader from a Vector4.
  17510. * @param name Define the name of the uniform as defined in the shader
  17511. * @param value Define the value to give to the uniform
  17512. * @return the material itself allowing "fluent" like uniform updates
  17513. */
  17514. setVector4(name: string, value: Vector4): ShaderMaterial;
  17515. /**
  17516. * Set a mat4 in the shader from a Matrix.
  17517. * @param name Define the name of the uniform as defined in the shader
  17518. * @param value Define the value to give to the uniform
  17519. * @return the material itself allowing "fluent" like uniform updates
  17520. */
  17521. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17522. /**
  17523. * Set a mat3 in the shader from a Float32Array.
  17524. * @param name Define the name of the uniform as defined in the shader
  17525. * @param value Define the value to give to the uniform
  17526. * @return the material itself allowing "fluent" like uniform updates
  17527. */
  17528. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17529. /**
  17530. * Set a mat2 in the shader from a Float32Array.
  17531. * @param name Define the name of the uniform as defined in the shader
  17532. * @param value Define the value to give to the uniform
  17533. * @return the material itself allowing "fluent" like uniform updates
  17534. */
  17535. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17536. /**
  17537. * Set a vec2 array in the shader from a number array.
  17538. * @param name Define the name of the uniform as defined in the shader
  17539. * @param value Define the value to give to the uniform
  17540. * @return the material itself allowing "fluent" like uniform updates
  17541. */
  17542. setArray2(name: string, value: number[]): ShaderMaterial;
  17543. /**
  17544. * Set a vec3 array in the shader from a number array.
  17545. * @param name Define the name of the uniform as defined in the shader
  17546. * @param value Define the value to give to the uniform
  17547. * @return the material itself allowing "fluent" like uniform updates
  17548. */
  17549. setArray3(name: string, value: number[]): ShaderMaterial;
  17550. private _checkCache;
  17551. /**
  17552. * Specifies that the submesh is ready to be used
  17553. * @param mesh defines the mesh to check
  17554. * @param subMesh defines which submesh to check
  17555. * @param useInstances specifies that instances should be used
  17556. * @returns a boolean indicating that the submesh is ready or not
  17557. */
  17558. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17559. /**
  17560. * Checks if the material is ready to render the requested mesh
  17561. * @param mesh Define the mesh to render
  17562. * @param useInstances Define whether or not the material is used with instances
  17563. * @returns true if ready, otherwise false
  17564. */
  17565. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17566. /**
  17567. * Binds the world matrix to the material
  17568. * @param world defines the world transformation matrix
  17569. */
  17570. bindOnlyWorldMatrix(world: Matrix): void;
  17571. /**
  17572. * Binds the material to the mesh
  17573. * @param world defines the world transformation matrix
  17574. * @param mesh defines the mesh to bind the material to
  17575. */
  17576. bind(world: Matrix, mesh?: Mesh): void;
  17577. /**
  17578. * Gets the active textures from the material
  17579. * @returns an array of textures
  17580. */
  17581. getActiveTextures(): BaseTexture[];
  17582. /**
  17583. * Specifies if the material uses a texture
  17584. * @param texture defines the texture to check against the material
  17585. * @returns a boolean specifying if the material uses the texture
  17586. */
  17587. hasTexture(texture: BaseTexture): boolean;
  17588. /**
  17589. * Makes a duplicate of the material, and gives it a new name
  17590. * @param name defines the new name for the duplicated material
  17591. * @returns the cloned material
  17592. */
  17593. clone(name: string): ShaderMaterial;
  17594. /**
  17595. * Disposes the material
  17596. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17597. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17598. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17599. */
  17600. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17601. /**
  17602. * Serializes this material in a JSON representation
  17603. * @returns the serialized material object
  17604. */
  17605. serialize(): any;
  17606. /**
  17607. * Creates a shader material from parsed shader material data
  17608. * @param source defines the JSON represnetation of the material
  17609. * @param scene defines the hosting scene
  17610. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17611. * @returns a new material
  17612. */
  17613. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17614. }
  17615. }
  17616. declare module "babylonjs/Shaders/color.fragment" {
  17617. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17618. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17619. /** @hidden */
  17620. export var colorPixelShader: {
  17621. name: string;
  17622. shader: string;
  17623. };
  17624. }
  17625. declare module "babylonjs/Shaders/color.vertex" {
  17626. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17627. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17628. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17629. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17630. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17631. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17632. /** @hidden */
  17633. export var colorVertexShader: {
  17634. name: string;
  17635. shader: string;
  17636. };
  17637. }
  17638. declare module "babylonjs/Meshes/linesMesh" {
  17639. import { Nullable } from "babylonjs/types";
  17640. import { Scene } from "babylonjs/scene";
  17641. import { Color3 } from "babylonjs/Maths/math";
  17642. import { Node } from "babylonjs/node";
  17643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17644. import { Mesh } from "babylonjs/Meshes/mesh";
  17645. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17646. import { Effect } from "babylonjs/Materials/effect";
  17647. import { Material } from "babylonjs/Materials/material";
  17648. import "babylonjs/Shaders/color.fragment";
  17649. import "babylonjs/Shaders/color.vertex";
  17650. /**
  17651. * Line mesh
  17652. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17653. */
  17654. export class LinesMesh extends Mesh {
  17655. /**
  17656. * If vertex color should be applied to the mesh
  17657. */
  17658. useVertexColor?: boolean | undefined;
  17659. /**
  17660. * If vertex alpha should be applied to the mesh
  17661. */
  17662. useVertexAlpha?: boolean | undefined;
  17663. /**
  17664. * Color of the line (Default: White)
  17665. */
  17666. color: Color3;
  17667. /**
  17668. * Alpha of the line (Default: 1)
  17669. */
  17670. alpha: number;
  17671. /**
  17672. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17673. * This margin is expressed in world space coordinates, so its value may vary.
  17674. * Default value is 0.1
  17675. */
  17676. intersectionThreshold: number;
  17677. private _colorShader;
  17678. /**
  17679. * Creates a new LinesMesh
  17680. * @param name defines the name
  17681. * @param scene defines the hosting scene
  17682. * @param parent defines the parent mesh if any
  17683. * @param source defines the optional source LinesMesh used to clone data from
  17684. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17685. * When false, achieved by calling a clone(), also passing False.
  17686. * This will make creation of children, recursive.
  17687. * @param useVertexColor defines if this LinesMesh supports vertex color
  17688. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17689. */
  17690. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17691. /**
  17692. * If vertex color should be applied to the mesh
  17693. */
  17694. useVertexColor?: boolean | undefined,
  17695. /**
  17696. * If vertex alpha should be applied to the mesh
  17697. */
  17698. useVertexAlpha?: boolean | undefined);
  17699. private _addClipPlaneDefine;
  17700. private _removeClipPlaneDefine;
  17701. isReady(): boolean;
  17702. /**
  17703. * Returns the string "LineMesh"
  17704. */
  17705. getClassName(): string;
  17706. /**
  17707. * @hidden
  17708. */
  17709. /**
  17710. * @hidden
  17711. */
  17712. material: Material;
  17713. /**
  17714. * @hidden
  17715. */
  17716. readonly checkCollisions: boolean;
  17717. /** @hidden */
  17718. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17719. /** @hidden */
  17720. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17721. /**
  17722. * Disposes of the line mesh
  17723. * @param doNotRecurse If children should be disposed
  17724. */
  17725. dispose(doNotRecurse?: boolean): void;
  17726. /**
  17727. * Returns a new LineMesh object cloned from the current one.
  17728. */
  17729. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17730. /**
  17731. * Creates a new InstancedLinesMesh object from the mesh model.
  17732. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17733. * @param name defines the name of the new instance
  17734. * @returns a new InstancedLinesMesh
  17735. */
  17736. createInstance(name: string): InstancedLinesMesh;
  17737. }
  17738. /**
  17739. * Creates an instance based on a source LinesMesh
  17740. */
  17741. export class InstancedLinesMesh extends InstancedMesh {
  17742. /**
  17743. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17744. * This margin is expressed in world space coordinates, so its value may vary.
  17745. * Initilized with the intersectionThreshold value of the source LinesMesh
  17746. */
  17747. intersectionThreshold: number;
  17748. constructor(name: string, source: LinesMesh);
  17749. /**
  17750. * Returns the string "InstancedLinesMesh".
  17751. */
  17752. getClassName(): string;
  17753. }
  17754. }
  17755. declare module "babylonjs/Shaders/line.fragment" {
  17756. /** @hidden */
  17757. export var linePixelShader: {
  17758. name: string;
  17759. shader: string;
  17760. };
  17761. }
  17762. declare module "babylonjs/Shaders/line.vertex" {
  17763. /** @hidden */
  17764. export var lineVertexShader: {
  17765. name: string;
  17766. shader: string;
  17767. };
  17768. }
  17769. declare module "babylonjs/Rendering/edgesRenderer" {
  17770. import { Nullable } from "babylonjs/types";
  17771. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17773. import { Vector3 } from "babylonjs/Maths/math";
  17774. import { IDisposable } from "babylonjs/scene";
  17775. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17776. import "babylonjs/Shaders/line.fragment";
  17777. import "babylonjs/Shaders/line.vertex";
  17778. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17779. module "babylonjs/Meshes/abstractMesh" {
  17780. interface AbstractMesh {
  17781. /**
  17782. * Disables the mesh edge rendering mode
  17783. * @returns the currentAbstractMesh
  17784. */
  17785. disableEdgesRendering(): AbstractMesh;
  17786. /**
  17787. * Enables the edge rendering mode on the mesh.
  17788. * This mode makes the mesh edges visible
  17789. * @param epsilon defines the maximal distance between two angles to detect a face
  17790. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17791. * @returns the currentAbstractMesh
  17792. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17793. */
  17794. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17795. /**
  17796. * Gets the edgesRenderer associated with the mesh
  17797. */
  17798. edgesRenderer: Nullable<EdgesRenderer>;
  17799. }
  17800. }
  17801. module "babylonjs/Meshes/linesMesh" {
  17802. interface LinesMesh {
  17803. /**
  17804. * Enables the edge rendering mode on the mesh.
  17805. * This mode makes the mesh edges visible
  17806. * @param epsilon defines the maximal distance between two angles to detect a face
  17807. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17808. * @returns the currentAbstractMesh
  17809. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17810. */
  17811. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17812. }
  17813. }
  17814. module "babylonjs/Meshes/linesMesh" {
  17815. interface InstancedLinesMesh {
  17816. /**
  17817. * Enables the edge rendering mode on the mesh.
  17818. * This mode makes the mesh edges visible
  17819. * @param epsilon defines the maximal distance between two angles to detect a face
  17820. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17821. * @returns the current InstancedLinesMesh
  17822. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17823. */
  17824. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17825. }
  17826. }
  17827. /**
  17828. * Defines the minimum contract an Edges renderer should follow.
  17829. */
  17830. export interface IEdgesRenderer extends IDisposable {
  17831. /**
  17832. * Gets or sets a boolean indicating if the edgesRenderer is active
  17833. */
  17834. isEnabled: boolean;
  17835. /**
  17836. * Renders the edges of the attached mesh,
  17837. */
  17838. render(): void;
  17839. /**
  17840. * Checks wether or not the edges renderer is ready to render.
  17841. * @return true if ready, otherwise false.
  17842. */
  17843. isReady(): boolean;
  17844. }
  17845. /**
  17846. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17847. */
  17848. export class EdgesRenderer implements IEdgesRenderer {
  17849. /**
  17850. * Define the size of the edges with an orthographic camera
  17851. */
  17852. edgesWidthScalerForOrthographic: number;
  17853. /**
  17854. * Define the size of the edges with a perspective camera
  17855. */
  17856. edgesWidthScalerForPerspective: number;
  17857. protected _source: AbstractMesh;
  17858. protected _linesPositions: number[];
  17859. protected _linesNormals: number[];
  17860. protected _linesIndices: number[];
  17861. protected _epsilon: number;
  17862. protected _indicesCount: number;
  17863. protected _lineShader: ShaderMaterial;
  17864. protected _ib: DataBuffer;
  17865. protected _buffers: {
  17866. [key: string]: Nullable<VertexBuffer>;
  17867. };
  17868. protected _checkVerticesInsteadOfIndices: boolean;
  17869. private _meshRebuildObserver;
  17870. private _meshDisposeObserver;
  17871. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17872. isEnabled: boolean;
  17873. /**
  17874. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17875. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17876. * @param source Mesh used to create edges
  17877. * @param epsilon sum of angles in adjacency to check for edge
  17878. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17879. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17880. */
  17881. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17882. protected _prepareRessources(): void;
  17883. /** @hidden */
  17884. _rebuild(): void;
  17885. /**
  17886. * Releases the required resources for the edges renderer
  17887. */
  17888. dispose(): void;
  17889. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17890. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17891. /**
  17892. * Checks if the pair of p0 and p1 is en edge
  17893. * @param faceIndex
  17894. * @param edge
  17895. * @param faceNormals
  17896. * @param p0
  17897. * @param p1
  17898. * @private
  17899. */
  17900. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17901. /**
  17902. * push line into the position, normal and index buffer
  17903. * @protected
  17904. */
  17905. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17906. /**
  17907. * Generates lines edges from adjacencjes
  17908. * @private
  17909. */
  17910. _generateEdgesLines(): void;
  17911. /**
  17912. * Checks wether or not the edges renderer is ready to render.
  17913. * @return true if ready, otherwise false.
  17914. */
  17915. isReady(): boolean;
  17916. /**
  17917. * Renders the edges of the attached mesh,
  17918. */
  17919. render(): void;
  17920. }
  17921. /**
  17922. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17923. */
  17924. export class LineEdgesRenderer extends EdgesRenderer {
  17925. /**
  17926. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17927. * @param source LineMesh used to generate edges
  17928. * @param epsilon not important (specified angle for edge detection)
  17929. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17930. */
  17931. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17932. /**
  17933. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17934. */
  17935. _generateEdgesLines(): void;
  17936. }
  17937. }
  17938. declare module "babylonjs/Rendering/renderingGroup" {
  17939. import { SmartArray } from "babylonjs/Misc/smartArray";
  17940. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17942. import { Nullable } from "babylonjs/types";
  17943. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17944. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17945. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17946. import { Material } from "babylonjs/Materials/material";
  17947. import { Scene } from "babylonjs/scene";
  17948. /**
  17949. * This represents the object necessary to create a rendering group.
  17950. * This is exclusively used and created by the rendering manager.
  17951. * To modify the behavior, you use the available helpers in your scene or meshes.
  17952. * @hidden
  17953. */
  17954. export class RenderingGroup {
  17955. index: number;
  17956. private _scene;
  17957. private _opaqueSubMeshes;
  17958. private _transparentSubMeshes;
  17959. private _alphaTestSubMeshes;
  17960. private _depthOnlySubMeshes;
  17961. private _particleSystems;
  17962. private _spriteManagers;
  17963. private _opaqueSortCompareFn;
  17964. private _alphaTestSortCompareFn;
  17965. private _transparentSortCompareFn;
  17966. private _renderOpaque;
  17967. private _renderAlphaTest;
  17968. private _renderTransparent;
  17969. /** @hidden */
  17970. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17971. onBeforeTransparentRendering: () => void;
  17972. /**
  17973. * Set the opaque sort comparison function.
  17974. * If null the sub meshes will be render in the order they were created
  17975. */
  17976. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17977. /**
  17978. * Set the alpha test sort comparison function.
  17979. * If null the sub meshes will be render in the order they were created
  17980. */
  17981. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17982. /**
  17983. * Set the transparent sort comparison function.
  17984. * If null the sub meshes will be render in the order they were created
  17985. */
  17986. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17987. /**
  17988. * Creates a new rendering group.
  17989. * @param index The rendering group index
  17990. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17991. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17992. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17993. */
  17994. 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>);
  17995. /**
  17996. * Render all the sub meshes contained in the group.
  17997. * @param customRenderFunction Used to override the default render behaviour of the group.
  17998. * @returns true if rendered some submeshes.
  17999. */
  18000. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  18001. /**
  18002. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  18003. * @param subMeshes The submeshes to render
  18004. */
  18005. private renderOpaqueSorted;
  18006. /**
  18007. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18008. * @param subMeshes The submeshes to render
  18009. */
  18010. private renderAlphaTestSorted;
  18011. /**
  18012. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18013. * @param subMeshes The submeshes to render
  18014. */
  18015. private renderTransparentSorted;
  18016. /**
  18017. * Renders the submeshes in a specified order.
  18018. * @param subMeshes The submeshes to sort before render
  18019. * @param sortCompareFn The comparison function use to sort
  18020. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18021. * @param transparent Specifies to activate blending if true
  18022. */
  18023. private static renderSorted;
  18024. /**
  18025. * Renders the submeshes in the order they were dispatched (no sort applied).
  18026. * @param subMeshes The submeshes to render
  18027. */
  18028. private static renderUnsorted;
  18029. /**
  18030. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18031. * are rendered back to front if in the same alpha index.
  18032. *
  18033. * @param a The first submesh
  18034. * @param b The second submesh
  18035. * @returns The result of the comparison
  18036. */
  18037. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18038. /**
  18039. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18040. * are rendered back to front.
  18041. *
  18042. * @param a The first submesh
  18043. * @param b The second submesh
  18044. * @returns The result of the comparison
  18045. */
  18046. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18047. /**
  18048. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18049. * are rendered front to back (prevent overdraw).
  18050. *
  18051. * @param a The first submesh
  18052. * @param b The second submesh
  18053. * @returns The result of the comparison
  18054. */
  18055. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18056. /**
  18057. * Resets the different lists of submeshes to prepare a new frame.
  18058. */
  18059. prepare(): void;
  18060. dispose(): void;
  18061. /**
  18062. * Inserts the submesh in its correct queue depending on its material.
  18063. * @param subMesh The submesh to dispatch
  18064. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18065. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18066. */
  18067. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18068. dispatchSprites(spriteManager: ISpriteManager): void;
  18069. dispatchParticles(particleSystem: IParticleSystem): void;
  18070. private _renderParticles;
  18071. private _renderSprites;
  18072. }
  18073. }
  18074. declare module "babylonjs/Rendering/renderingManager" {
  18075. import { Nullable } from "babylonjs/types";
  18076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18077. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18078. import { SmartArray } from "babylonjs/Misc/smartArray";
  18079. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18080. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18081. import { Material } from "babylonjs/Materials/material";
  18082. import { Scene } from "babylonjs/scene";
  18083. import { Camera } from "babylonjs/Cameras/camera";
  18084. /**
  18085. * Interface describing the different options available in the rendering manager
  18086. * regarding Auto Clear between groups.
  18087. */
  18088. export interface IRenderingManagerAutoClearSetup {
  18089. /**
  18090. * Defines whether or not autoclear is enable.
  18091. */
  18092. autoClear: boolean;
  18093. /**
  18094. * Defines whether or not to autoclear the depth buffer.
  18095. */
  18096. depth: boolean;
  18097. /**
  18098. * Defines whether or not to autoclear the stencil buffer.
  18099. */
  18100. stencil: boolean;
  18101. }
  18102. /**
  18103. * This class is used by the onRenderingGroupObservable
  18104. */
  18105. export class RenderingGroupInfo {
  18106. /**
  18107. * The Scene that being rendered
  18108. */
  18109. scene: Scene;
  18110. /**
  18111. * The camera currently used for the rendering pass
  18112. */
  18113. camera: Nullable<Camera>;
  18114. /**
  18115. * The ID of the renderingGroup being processed
  18116. */
  18117. renderingGroupId: number;
  18118. }
  18119. /**
  18120. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18121. * It is enable to manage the different groups as well as the different necessary sort functions.
  18122. * This should not be used directly aside of the few static configurations
  18123. */
  18124. export class RenderingManager {
  18125. /**
  18126. * The max id used for rendering groups (not included)
  18127. */
  18128. static MAX_RENDERINGGROUPS: number;
  18129. /**
  18130. * The min id used for rendering groups (included)
  18131. */
  18132. static MIN_RENDERINGGROUPS: number;
  18133. /**
  18134. * Used to globally prevent autoclearing scenes.
  18135. */
  18136. static AUTOCLEAR: boolean;
  18137. /**
  18138. * @hidden
  18139. */
  18140. _useSceneAutoClearSetup: boolean;
  18141. private _scene;
  18142. private _renderingGroups;
  18143. private _depthStencilBufferAlreadyCleaned;
  18144. private _autoClearDepthStencil;
  18145. private _customOpaqueSortCompareFn;
  18146. private _customAlphaTestSortCompareFn;
  18147. private _customTransparentSortCompareFn;
  18148. private _renderingGroupInfo;
  18149. /**
  18150. * Instantiates a new rendering group for a particular scene
  18151. * @param scene Defines the scene the groups belongs to
  18152. */
  18153. constructor(scene: Scene);
  18154. private _clearDepthStencilBuffer;
  18155. /**
  18156. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18157. * @hidden
  18158. */
  18159. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18160. /**
  18161. * Resets the different information of the group to prepare a new frame
  18162. * @hidden
  18163. */
  18164. reset(): void;
  18165. /**
  18166. * Dispose and release the group and its associated resources.
  18167. * @hidden
  18168. */
  18169. dispose(): void;
  18170. /**
  18171. * Clear the info related to rendering groups preventing retention points during dispose.
  18172. */
  18173. freeRenderingGroups(): void;
  18174. private _prepareRenderingGroup;
  18175. /**
  18176. * Add a sprite manager to the rendering manager in order to render it this frame.
  18177. * @param spriteManager Define the sprite manager to render
  18178. */
  18179. dispatchSprites(spriteManager: ISpriteManager): void;
  18180. /**
  18181. * Add a particle system to the rendering manager in order to render it this frame.
  18182. * @param particleSystem Define the particle system to render
  18183. */
  18184. dispatchParticles(particleSystem: IParticleSystem): void;
  18185. /**
  18186. * Add a submesh to the manager in order to render it this frame
  18187. * @param subMesh The submesh to dispatch
  18188. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18189. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18190. */
  18191. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18192. /**
  18193. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18194. * This allowed control for front to back rendering or reversly depending of the special needs.
  18195. *
  18196. * @param renderingGroupId The rendering group id corresponding to its index
  18197. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18198. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18199. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18200. */
  18201. 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;
  18202. /**
  18203. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18204. *
  18205. * @param renderingGroupId The rendering group id corresponding to its index
  18206. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18207. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18208. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18209. */
  18210. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18211. /**
  18212. * Gets the current auto clear configuration for one rendering group of the rendering
  18213. * manager.
  18214. * @param index the rendering group index to get the information for
  18215. * @returns The auto clear setup for the requested rendering group
  18216. */
  18217. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18218. }
  18219. }
  18220. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18221. import { Observable } from "babylonjs/Misc/observable";
  18222. import { SmartArray } from "babylonjs/Misc/smartArray";
  18223. import { Nullable } from "babylonjs/types";
  18224. import { Camera } from "babylonjs/Cameras/camera";
  18225. import { Scene } from "babylonjs/scene";
  18226. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18227. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18229. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18230. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18231. import { Texture } from "babylonjs/Materials/Textures/texture";
  18232. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18233. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18234. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18235. import { Engine } from "babylonjs/Engines/engine";
  18236. /**
  18237. * This Helps creating a texture that will be created from a camera in your scene.
  18238. * It is basically a dynamic texture that could be used to create special effects for instance.
  18239. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18240. */
  18241. export class RenderTargetTexture extends Texture {
  18242. isCube: boolean;
  18243. /**
  18244. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18245. */
  18246. static readonly REFRESHRATE_RENDER_ONCE: number;
  18247. /**
  18248. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18249. */
  18250. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18251. /**
  18252. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18253. * the central point of your effect and can save a lot of performances.
  18254. */
  18255. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18256. /**
  18257. * Use this predicate to dynamically define the list of mesh you want to render.
  18258. * If set, the renderList property will be overwritten.
  18259. */
  18260. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18261. private _renderList;
  18262. /**
  18263. * Use this list to define the list of mesh you want to render.
  18264. */
  18265. renderList: Nullable<Array<AbstractMesh>>;
  18266. private _hookArray;
  18267. /**
  18268. * Define if particles should be rendered in your texture.
  18269. */
  18270. renderParticles: boolean;
  18271. /**
  18272. * Define if sprites should be rendered in your texture.
  18273. */
  18274. renderSprites: boolean;
  18275. /**
  18276. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18277. */
  18278. coordinatesMode: number;
  18279. /**
  18280. * Define the camera used to render the texture.
  18281. */
  18282. activeCamera: Nullable<Camera>;
  18283. /**
  18284. * Override the render function of the texture with your own one.
  18285. */
  18286. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18287. /**
  18288. * Define if camera post processes should be use while rendering the texture.
  18289. */
  18290. useCameraPostProcesses: boolean;
  18291. /**
  18292. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18293. */
  18294. ignoreCameraViewport: boolean;
  18295. private _postProcessManager;
  18296. private _postProcesses;
  18297. private _resizeObserver;
  18298. /**
  18299. * An event triggered when the texture is unbind.
  18300. */
  18301. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18302. /**
  18303. * An event triggered when the texture is unbind.
  18304. */
  18305. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18306. private _onAfterUnbindObserver;
  18307. /**
  18308. * Set a after unbind callback in the texture.
  18309. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18310. */
  18311. onAfterUnbind: () => void;
  18312. /**
  18313. * An event triggered before rendering the texture
  18314. */
  18315. onBeforeRenderObservable: Observable<number>;
  18316. private _onBeforeRenderObserver;
  18317. /**
  18318. * Set a before render callback in the texture.
  18319. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18320. */
  18321. onBeforeRender: (faceIndex: number) => void;
  18322. /**
  18323. * An event triggered after rendering the texture
  18324. */
  18325. onAfterRenderObservable: Observable<number>;
  18326. private _onAfterRenderObserver;
  18327. /**
  18328. * Set a after render callback in the texture.
  18329. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18330. */
  18331. onAfterRender: (faceIndex: number) => void;
  18332. /**
  18333. * An event triggered after the texture clear
  18334. */
  18335. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18336. private _onClearObserver;
  18337. /**
  18338. * Set a clear callback in the texture.
  18339. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18340. */
  18341. onClear: (Engine: Engine) => void;
  18342. /**
  18343. * Define the clear color of the Render Target if it should be different from the scene.
  18344. */
  18345. clearColor: Color4;
  18346. protected _size: number | {
  18347. width: number;
  18348. height: number;
  18349. };
  18350. protected _initialSizeParameter: number | {
  18351. width: number;
  18352. height: number;
  18353. } | {
  18354. ratio: number;
  18355. };
  18356. protected _sizeRatio: Nullable<number>;
  18357. /** @hidden */
  18358. _generateMipMaps: boolean;
  18359. protected _renderingManager: RenderingManager;
  18360. /** @hidden */
  18361. _waitingRenderList: string[];
  18362. protected _doNotChangeAspectRatio: boolean;
  18363. protected _currentRefreshId: number;
  18364. protected _refreshRate: number;
  18365. protected _textureMatrix: Matrix;
  18366. protected _samples: number;
  18367. protected _renderTargetOptions: RenderTargetCreationOptions;
  18368. /**
  18369. * Gets render target creation options that were used.
  18370. */
  18371. readonly renderTargetOptions: RenderTargetCreationOptions;
  18372. protected _engine: Engine;
  18373. protected _onRatioRescale(): void;
  18374. /**
  18375. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18376. * It must define where the camera used to render the texture is set
  18377. */
  18378. boundingBoxPosition: Vector3;
  18379. private _boundingBoxSize;
  18380. /**
  18381. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18382. * When defined, the cubemap will switch to local mode
  18383. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18384. * @example https://www.babylonjs-playground.com/#RNASML
  18385. */
  18386. boundingBoxSize: Vector3;
  18387. /**
  18388. * In case the RTT has been created with a depth texture, get the associated
  18389. * depth texture.
  18390. * Otherwise, return null.
  18391. */
  18392. depthStencilTexture: Nullable<InternalTexture>;
  18393. /**
  18394. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18395. * or used a shadow, depth texture...
  18396. * @param name The friendly name of the texture
  18397. * @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)
  18398. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18399. * @param generateMipMaps True if mip maps need to be generated after render.
  18400. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18401. * @param type The type of the buffer in the RTT (int, half float, float...)
  18402. * @param isCube True if a cube texture needs to be created
  18403. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18404. * @param generateDepthBuffer True to generate a depth buffer
  18405. * @param generateStencilBuffer True to generate a stencil buffer
  18406. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18407. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18408. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18409. */
  18410. constructor(name: string, size: number | {
  18411. width: number;
  18412. height: number;
  18413. } | {
  18414. ratio: number;
  18415. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18416. /**
  18417. * Creates a depth stencil texture.
  18418. * This is only available in WebGL 2 or with the depth texture extension available.
  18419. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18420. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18421. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18422. */
  18423. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18424. private _processSizeParameter;
  18425. /**
  18426. * Define the number of samples to use in case of MSAA.
  18427. * It defaults to one meaning no MSAA has been enabled.
  18428. */
  18429. samples: number;
  18430. /**
  18431. * Resets the refresh counter of the texture and start bak from scratch.
  18432. * Could be useful to regenerate the texture if it is setup to render only once.
  18433. */
  18434. resetRefreshCounter(): void;
  18435. /**
  18436. * Define the refresh rate of the texture or the rendering frequency.
  18437. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18438. */
  18439. refreshRate: number;
  18440. /**
  18441. * Adds a post process to the render target rendering passes.
  18442. * @param postProcess define the post process to add
  18443. */
  18444. addPostProcess(postProcess: PostProcess): void;
  18445. /**
  18446. * Clear all the post processes attached to the render target
  18447. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18448. */
  18449. clearPostProcesses(dispose?: boolean): void;
  18450. /**
  18451. * Remove one of the post process from the list of attached post processes to the texture
  18452. * @param postProcess define the post process to remove from the list
  18453. */
  18454. removePostProcess(postProcess: PostProcess): void;
  18455. /** @hidden */
  18456. _shouldRender(): boolean;
  18457. /**
  18458. * Gets the actual render size of the texture.
  18459. * @returns the width of the render size
  18460. */
  18461. getRenderSize(): number;
  18462. /**
  18463. * Gets the actual render width of the texture.
  18464. * @returns the width of the render size
  18465. */
  18466. getRenderWidth(): number;
  18467. /**
  18468. * Gets the actual render height of the texture.
  18469. * @returns the height of the render size
  18470. */
  18471. getRenderHeight(): number;
  18472. /**
  18473. * Get if the texture can be rescaled or not.
  18474. */
  18475. readonly canRescale: boolean;
  18476. /**
  18477. * Resize the texture using a ratio.
  18478. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18479. */
  18480. scale(ratio: number): void;
  18481. /**
  18482. * Get the texture reflection matrix used to rotate/transform the reflection.
  18483. * @returns the reflection matrix
  18484. */
  18485. getReflectionTextureMatrix(): Matrix;
  18486. /**
  18487. * Resize the texture to a new desired size.
  18488. * Be carrefull as it will recreate all the data in the new texture.
  18489. * @param size Define the new size. It can be:
  18490. * - a number for squared texture,
  18491. * - an object containing { width: number, height: number }
  18492. * - or an object containing a ratio { ratio: number }
  18493. */
  18494. resize(size: number | {
  18495. width: number;
  18496. height: number;
  18497. } | {
  18498. ratio: number;
  18499. }): void;
  18500. /**
  18501. * Renders all the objects from the render list into the texture.
  18502. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18503. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18504. */
  18505. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18506. private _bestReflectionRenderTargetDimension;
  18507. /**
  18508. * @hidden
  18509. * @param faceIndex face index to bind to if this is a cubetexture
  18510. */
  18511. _bindFrameBuffer(faceIndex?: number): void;
  18512. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18513. private renderToTarget;
  18514. /**
  18515. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18516. * This allowed control for front to back rendering or reversly depending of the special needs.
  18517. *
  18518. * @param renderingGroupId The rendering group id corresponding to its index
  18519. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18520. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18521. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18522. */
  18523. 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;
  18524. /**
  18525. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18526. *
  18527. * @param renderingGroupId The rendering group id corresponding to its index
  18528. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18529. */
  18530. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18531. /**
  18532. * Clones the texture.
  18533. * @returns the cloned texture
  18534. */
  18535. clone(): RenderTargetTexture;
  18536. /**
  18537. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18538. * @returns The JSON representation of the texture
  18539. */
  18540. serialize(): any;
  18541. /**
  18542. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18543. */
  18544. disposeFramebufferObjects(): void;
  18545. /**
  18546. * Dispose the texture and release its associated resources.
  18547. */
  18548. dispose(): void;
  18549. /** @hidden */
  18550. _rebuild(): void;
  18551. /**
  18552. * Clear the info related to rendering groups preventing retention point in material dispose.
  18553. */
  18554. freeRenderingGroups(): void;
  18555. /**
  18556. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18557. * @returns the view count
  18558. */
  18559. getViewCount(): number;
  18560. }
  18561. }
  18562. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18563. import { Scene } from "babylonjs/scene";
  18564. import { Plane } from "babylonjs/Maths/math";
  18565. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18566. /**
  18567. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18568. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18569. * You can then easily use it as a reflectionTexture on a flat surface.
  18570. * In case the surface is not a plane, please consider relying on reflection probes.
  18571. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18572. */
  18573. export class MirrorTexture extends RenderTargetTexture {
  18574. private scene;
  18575. /**
  18576. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18577. * 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.
  18578. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18579. */
  18580. mirrorPlane: Plane;
  18581. /**
  18582. * Define the blur ratio used to blur the reflection if needed.
  18583. */
  18584. blurRatio: number;
  18585. /**
  18586. * Define the adaptive blur kernel used to blur the reflection if needed.
  18587. * This will autocompute the closest best match for the `blurKernel`
  18588. */
  18589. adaptiveBlurKernel: number;
  18590. /**
  18591. * Define the blur kernel used to blur the reflection if needed.
  18592. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18593. */
  18594. blurKernel: number;
  18595. /**
  18596. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18597. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18598. */
  18599. blurKernelX: number;
  18600. /**
  18601. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18602. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18603. */
  18604. blurKernelY: number;
  18605. private _autoComputeBlurKernel;
  18606. protected _onRatioRescale(): void;
  18607. private _updateGammaSpace;
  18608. private _imageProcessingConfigChangeObserver;
  18609. private _transformMatrix;
  18610. private _mirrorMatrix;
  18611. private _savedViewMatrix;
  18612. private _blurX;
  18613. private _blurY;
  18614. private _adaptiveBlurKernel;
  18615. private _blurKernelX;
  18616. private _blurKernelY;
  18617. private _blurRatio;
  18618. /**
  18619. * Instantiates a Mirror Texture.
  18620. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18621. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18622. * You can then easily use it as a reflectionTexture on a flat surface.
  18623. * In case the surface is not a plane, please consider relying on reflection probes.
  18624. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18625. * @param name
  18626. * @param size
  18627. * @param scene
  18628. * @param generateMipMaps
  18629. * @param type
  18630. * @param samplingMode
  18631. * @param generateDepthBuffer
  18632. */
  18633. constructor(name: string, size: number | {
  18634. width: number;
  18635. height: number;
  18636. } | {
  18637. ratio: number;
  18638. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18639. private _preparePostProcesses;
  18640. /**
  18641. * Clone the mirror texture.
  18642. * @returns the cloned texture
  18643. */
  18644. clone(): MirrorTexture;
  18645. /**
  18646. * Serialize the texture to a JSON representation you could use in Parse later on
  18647. * @returns the serialized JSON representation
  18648. */
  18649. serialize(): any;
  18650. /**
  18651. * Dispose the texture and release its associated resources.
  18652. */
  18653. dispose(): void;
  18654. }
  18655. }
  18656. declare module "babylonjs/Materials/Textures/texture" {
  18657. import { Observable } from "babylonjs/Misc/observable";
  18658. import { Nullable } from "babylonjs/types";
  18659. import { Scene } from "babylonjs/scene";
  18660. import { Matrix } from "babylonjs/Maths/math";
  18661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18662. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18663. /**
  18664. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18665. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18666. */
  18667. export class Texture extends BaseTexture {
  18668. /** @hidden */
  18669. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18670. /** @hidden */
  18671. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18672. /** @hidden */
  18673. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18674. /** nearest is mag = nearest and min = nearest and mip = linear */
  18675. static readonly NEAREST_SAMPLINGMODE: number;
  18676. /** nearest is mag = nearest and min = nearest and mip = linear */
  18677. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18678. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18679. static readonly BILINEAR_SAMPLINGMODE: number;
  18680. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18681. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18682. /** Trilinear is mag = linear and min = linear and mip = linear */
  18683. static readonly TRILINEAR_SAMPLINGMODE: number;
  18684. /** Trilinear is mag = linear and min = linear and mip = linear */
  18685. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18686. /** mag = nearest and min = nearest and mip = nearest */
  18687. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18688. /** mag = nearest and min = linear and mip = nearest */
  18689. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18690. /** mag = nearest and min = linear and mip = linear */
  18691. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18692. /** mag = nearest and min = linear and mip = none */
  18693. static readonly NEAREST_LINEAR: number;
  18694. /** mag = nearest and min = nearest and mip = none */
  18695. static readonly NEAREST_NEAREST: number;
  18696. /** mag = linear and min = nearest and mip = nearest */
  18697. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18698. /** mag = linear and min = nearest and mip = linear */
  18699. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18700. /** mag = linear and min = linear and mip = none */
  18701. static readonly LINEAR_LINEAR: number;
  18702. /** mag = linear and min = nearest and mip = none */
  18703. static readonly LINEAR_NEAREST: number;
  18704. /** Explicit coordinates mode */
  18705. static readonly EXPLICIT_MODE: number;
  18706. /** Spherical coordinates mode */
  18707. static readonly SPHERICAL_MODE: number;
  18708. /** Planar coordinates mode */
  18709. static readonly PLANAR_MODE: number;
  18710. /** Cubic coordinates mode */
  18711. static readonly CUBIC_MODE: number;
  18712. /** Projection coordinates mode */
  18713. static readonly PROJECTION_MODE: number;
  18714. /** Inverse Cubic coordinates mode */
  18715. static readonly SKYBOX_MODE: number;
  18716. /** Inverse Cubic coordinates mode */
  18717. static readonly INVCUBIC_MODE: number;
  18718. /** Equirectangular coordinates mode */
  18719. static readonly EQUIRECTANGULAR_MODE: number;
  18720. /** Equirectangular Fixed coordinates mode */
  18721. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18722. /** Equirectangular Fixed Mirrored coordinates mode */
  18723. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18724. /** Texture is not repeating outside of 0..1 UVs */
  18725. static readonly CLAMP_ADDRESSMODE: number;
  18726. /** Texture is repeating outside of 0..1 UVs */
  18727. static readonly WRAP_ADDRESSMODE: number;
  18728. /** Texture is repeating and mirrored */
  18729. static readonly MIRROR_ADDRESSMODE: number;
  18730. /**
  18731. * 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
  18732. */
  18733. static UseSerializedUrlIfAny: boolean;
  18734. /**
  18735. * Define the url of the texture.
  18736. */
  18737. url: Nullable<string>;
  18738. /**
  18739. * Define an offset on the texture to offset the u coordinates of the UVs
  18740. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18741. */
  18742. uOffset: number;
  18743. /**
  18744. * Define an offset on the texture to offset the v coordinates of the UVs
  18745. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18746. */
  18747. vOffset: number;
  18748. /**
  18749. * Define an offset on the texture to scale the u coordinates of the UVs
  18750. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18751. */
  18752. uScale: number;
  18753. /**
  18754. * Define an offset on the texture to scale the v coordinates of the UVs
  18755. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18756. */
  18757. vScale: number;
  18758. /**
  18759. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18760. * @see http://doc.babylonjs.com/how_to/more_materials
  18761. */
  18762. uAng: number;
  18763. /**
  18764. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18765. * @see http://doc.babylonjs.com/how_to/more_materials
  18766. */
  18767. vAng: number;
  18768. /**
  18769. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18770. * @see http://doc.babylonjs.com/how_to/more_materials
  18771. */
  18772. wAng: number;
  18773. /**
  18774. * Defines the center of rotation (U)
  18775. */
  18776. uRotationCenter: number;
  18777. /**
  18778. * Defines the center of rotation (V)
  18779. */
  18780. vRotationCenter: number;
  18781. /**
  18782. * Defines the center of rotation (W)
  18783. */
  18784. wRotationCenter: number;
  18785. /**
  18786. * Are mip maps generated for this texture or not.
  18787. */
  18788. readonly noMipmap: boolean;
  18789. /**
  18790. * List of inspectable custom properties (used by the Inspector)
  18791. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18792. */
  18793. inspectableCustomProperties: Nullable<IInspectable[]>;
  18794. private _noMipmap;
  18795. /** @hidden */
  18796. _invertY: boolean;
  18797. private _rowGenerationMatrix;
  18798. private _cachedTextureMatrix;
  18799. private _projectionModeMatrix;
  18800. private _t0;
  18801. private _t1;
  18802. private _t2;
  18803. private _cachedUOffset;
  18804. private _cachedVOffset;
  18805. private _cachedUScale;
  18806. private _cachedVScale;
  18807. private _cachedUAng;
  18808. private _cachedVAng;
  18809. private _cachedWAng;
  18810. private _cachedProjectionMatrixId;
  18811. private _cachedCoordinatesMode;
  18812. /** @hidden */
  18813. protected _initialSamplingMode: number;
  18814. /** @hidden */
  18815. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18816. private _deleteBuffer;
  18817. protected _format: Nullable<number>;
  18818. private _delayedOnLoad;
  18819. private _delayedOnError;
  18820. /**
  18821. * Observable triggered once the texture has been loaded.
  18822. */
  18823. onLoadObservable: Observable<Texture>;
  18824. protected _isBlocking: boolean;
  18825. /**
  18826. * Is the texture preventing material to render while loading.
  18827. * If false, a default texture will be used instead of the loading one during the preparation step.
  18828. */
  18829. isBlocking: boolean;
  18830. /**
  18831. * Get the current sampling mode associated with the texture.
  18832. */
  18833. readonly samplingMode: number;
  18834. /**
  18835. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18836. */
  18837. readonly invertY: boolean;
  18838. /**
  18839. * Instantiates a new texture.
  18840. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18841. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18842. * @param url define the url of the picture to load as a texture
  18843. * @param scene define the scene the texture will belong to
  18844. * @param noMipmap define if the texture will require mip maps or not
  18845. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18846. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18847. * @param onLoad define a callback triggered when the texture has been loaded
  18848. * @param onError define a callback triggered when an error occurred during the loading session
  18849. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18850. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18851. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18852. */
  18853. 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);
  18854. /**
  18855. * Update the url (and optional buffer) of this texture if url was null during construction.
  18856. * @param url the url of the texture
  18857. * @param buffer the buffer of the texture (defaults to null)
  18858. * @param onLoad callback called when the texture is loaded (defaults to null)
  18859. */
  18860. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18861. /**
  18862. * Finish the loading sequence of a texture flagged as delayed load.
  18863. * @hidden
  18864. */
  18865. delayLoad(): void;
  18866. private _prepareRowForTextureGeneration;
  18867. /**
  18868. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18869. * @returns the transform matrix of the texture.
  18870. */
  18871. getTextureMatrix(): Matrix;
  18872. /**
  18873. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18874. * @returns The reflection texture transform
  18875. */
  18876. getReflectionTextureMatrix(): Matrix;
  18877. /**
  18878. * Clones the texture.
  18879. * @returns the cloned texture
  18880. */
  18881. clone(): Texture;
  18882. /**
  18883. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18884. * @returns The JSON representation of the texture
  18885. */
  18886. serialize(): any;
  18887. /**
  18888. * Get the current class name of the texture useful for serialization or dynamic coding.
  18889. * @returns "Texture"
  18890. */
  18891. getClassName(): string;
  18892. /**
  18893. * Dispose the texture and release its associated resources.
  18894. */
  18895. dispose(): void;
  18896. /**
  18897. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18898. * @param parsedTexture Define the JSON representation of the texture
  18899. * @param scene Define the scene the parsed texture should be instantiated in
  18900. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18901. * @returns The parsed texture if successful
  18902. */
  18903. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18904. /**
  18905. * Creates a texture from its base 64 representation.
  18906. * @param data Define the base64 payload without the data: prefix
  18907. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18908. * @param scene Define the scene the texture should belong to
  18909. * @param noMipmap Forces the texture to not create mip map information if true
  18910. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18911. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18912. * @param onLoad define a callback triggered when the texture has been loaded
  18913. * @param onError define a callback triggered when an error occurred during the loading session
  18914. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18915. * @returns the created texture
  18916. */
  18917. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18918. /**
  18919. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18920. * @param data Define the base64 payload without the data: prefix
  18921. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18922. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18923. * @param scene Define the scene the texture should belong to
  18924. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18925. * @param noMipmap Forces the texture to not create mip map information if true
  18926. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18927. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18928. * @param onLoad define a callback triggered when the texture has been loaded
  18929. * @param onError define a callback triggered when an error occurred during the loading session
  18930. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18931. * @returns the created texture
  18932. */
  18933. 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;
  18934. }
  18935. }
  18936. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18937. import { Nullable } from "babylonjs/types";
  18938. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18939. import { Scene } from "babylonjs/scene";
  18940. module "babylonjs/Engines/engine" {
  18941. interface Engine {
  18942. /**
  18943. * Creates a raw texture
  18944. * @param data defines the data to store in the texture
  18945. * @param width defines the width of the texture
  18946. * @param height defines the height of the texture
  18947. * @param format defines the format of the data
  18948. * @param generateMipMaps defines if the engine should generate the mip levels
  18949. * @param invertY defines if data must be stored with Y axis inverted
  18950. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18951. * @param compression defines the compression used (null by default)
  18952. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18953. * @returns the raw texture inside an InternalTexture
  18954. */
  18955. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18956. /**
  18957. * Update a raw texture
  18958. * @param texture defines the texture to update
  18959. * @param data defines the data to store in the texture
  18960. * @param format defines the format of the data
  18961. * @param invertY defines if data must be stored with Y axis inverted
  18962. */
  18963. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18964. /**
  18965. * Update a raw texture
  18966. * @param texture defines the texture to update
  18967. * @param data defines the data to store in the texture
  18968. * @param format defines the format of the data
  18969. * @param invertY defines if data must be stored with Y axis inverted
  18970. * @param compression defines the compression used (null by default)
  18971. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18972. */
  18973. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18974. /**
  18975. * Creates a new raw cube texture
  18976. * @param data defines the array of data to use to create each face
  18977. * @param size defines the size of the textures
  18978. * @param format defines the format of the data
  18979. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18980. * @param generateMipMaps defines if the engine should generate the mip levels
  18981. * @param invertY defines if data must be stored with Y axis inverted
  18982. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18983. * @param compression defines the compression used (null by default)
  18984. * @returns the cube texture as an InternalTexture
  18985. */
  18986. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18987. /**
  18988. * Update a raw cube texture
  18989. * @param texture defines the texture to udpdate
  18990. * @param data defines the data to store
  18991. * @param format defines the data format
  18992. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18993. * @param invertY defines if data must be stored with Y axis inverted
  18994. */
  18995. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18996. /**
  18997. * Update a raw cube texture
  18998. * @param texture defines the texture to udpdate
  18999. * @param data defines the data to store
  19000. * @param format defines the data format
  19001. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19002. * @param invertY defines if data must be stored with Y axis inverted
  19003. * @param compression defines the compression used (null by default)
  19004. */
  19005. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  19006. /**
  19007. * Update a raw cube texture
  19008. * @param texture defines the texture to udpdate
  19009. * @param data defines the data to store
  19010. * @param format defines the data format
  19011. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19012. * @param invertY defines if data must be stored with Y axis inverted
  19013. * @param compression defines the compression used (null by default)
  19014. * @param level defines which level of the texture to update
  19015. */
  19016. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19017. /**
  19018. * Creates a new raw cube texture from a specified url
  19019. * @param url defines the url where the data is located
  19020. * @param scene defines the current scene
  19021. * @param size defines the size of the textures
  19022. * @param format defines the format of the data
  19023. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19024. * @param noMipmap defines if the engine should avoid generating the mip levels
  19025. * @param callback defines a callback used to extract texture data from loaded data
  19026. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19027. * @param onLoad defines a callback called when texture is loaded
  19028. * @param onError defines a callback called if there is an error
  19029. * @returns the cube texture as an InternalTexture
  19030. */
  19031. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  19032. /**
  19033. * Creates a new raw cube texture from a specified url
  19034. * @param url defines the url where the data is located
  19035. * @param scene defines the current scene
  19036. * @param size defines the size of the textures
  19037. * @param format defines the format of the data
  19038. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19039. * @param noMipmap defines if the engine should avoid generating the mip levels
  19040. * @param callback defines a callback used to extract texture data from loaded data
  19041. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19042. * @param onLoad defines a callback called when texture is loaded
  19043. * @param onError defines a callback called if there is an error
  19044. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19045. * @param invertY defines if data must be stored with Y axis inverted
  19046. * @returns the cube texture as an InternalTexture
  19047. */
  19048. 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;
  19049. /**
  19050. * Creates a new raw 3D texture
  19051. * @param data defines the data used to create the texture
  19052. * @param width defines the width of the texture
  19053. * @param height defines the height of the texture
  19054. * @param depth defines the depth of the texture
  19055. * @param format defines the format of the texture
  19056. * @param generateMipMaps defines if the engine must generate mip levels
  19057. * @param invertY defines if data must be stored with Y axis inverted
  19058. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19059. * @param compression defines the compressed used (can be null)
  19060. * @param textureType defines the compressed used (can be null)
  19061. * @returns a new raw 3D texture (stored in an InternalTexture)
  19062. */
  19063. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19064. /**
  19065. * Update a raw 3D texture
  19066. * @param texture defines the texture to update
  19067. * @param data defines the data to store
  19068. * @param format defines the data format
  19069. * @param invertY defines if data must be stored with Y axis inverted
  19070. */
  19071. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19072. /**
  19073. * Update a raw 3D texture
  19074. * @param texture defines the texture to update
  19075. * @param data defines the data to store
  19076. * @param format defines the data format
  19077. * @param invertY defines if data must be stored with Y axis inverted
  19078. * @param compression defines the used compression (can be null)
  19079. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19080. */
  19081. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19082. }
  19083. }
  19084. }
  19085. declare module "babylonjs/Materials/Textures/rawTexture" {
  19086. import { Scene } from "babylonjs/scene";
  19087. import { Texture } from "babylonjs/Materials/Textures/texture";
  19088. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19089. /**
  19090. * Raw texture can help creating a texture directly from an array of data.
  19091. * This can be super useful if you either get the data from an uncompressed source or
  19092. * if you wish to create your texture pixel by pixel.
  19093. */
  19094. export class RawTexture extends Texture {
  19095. /**
  19096. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19097. */
  19098. format: number;
  19099. private _engine;
  19100. /**
  19101. * Instantiates a new RawTexture.
  19102. * Raw texture can help creating a texture directly from an array of data.
  19103. * This can be super useful if you either get the data from an uncompressed source or
  19104. * if you wish to create your texture pixel by pixel.
  19105. * @param data define the array of data to use to create the texture
  19106. * @param width define the width of the texture
  19107. * @param height define the height of the texture
  19108. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19109. * @param scene define the scene the texture belongs to
  19110. * @param generateMipMaps define whether mip maps should be generated or not
  19111. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19112. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19113. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19114. */
  19115. constructor(data: ArrayBufferView, width: number, height: number,
  19116. /**
  19117. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19118. */
  19119. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19120. /**
  19121. * Updates the texture underlying data.
  19122. * @param data Define the new data of the texture
  19123. */
  19124. update(data: ArrayBufferView): void;
  19125. /**
  19126. * Creates a luminance texture from some data.
  19127. * @param data Define the texture data
  19128. * @param width Define the width of the texture
  19129. * @param height Define the height of the texture
  19130. * @param scene Define the scene the texture belongs to
  19131. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19132. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19133. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19134. * @returns the luminance texture
  19135. */
  19136. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19137. /**
  19138. * Creates a luminance alpha texture from some data.
  19139. * @param data Define the texture data
  19140. * @param width Define the width of the texture
  19141. * @param height Define the height of the texture
  19142. * @param scene Define the scene the texture belongs to
  19143. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19144. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19145. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19146. * @returns the luminance alpha texture
  19147. */
  19148. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19149. /**
  19150. * Creates an alpha texture from some data.
  19151. * @param data Define the texture data
  19152. * @param width Define the width of the texture
  19153. * @param height Define the height of the texture
  19154. * @param scene Define the scene the texture belongs to
  19155. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19156. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19157. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19158. * @returns the alpha texture
  19159. */
  19160. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19161. /**
  19162. * Creates a RGB texture from some data.
  19163. * @param data Define the texture data
  19164. * @param width Define the width of the texture
  19165. * @param height Define the height of the texture
  19166. * @param scene Define the scene the texture belongs to
  19167. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19168. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19169. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19170. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19171. * @returns the RGB alpha texture
  19172. */
  19173. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19174. /**
  19175. * Creates a RGBA texture from some data.
  19176. * @param data Define the texture data
  19177. * @param width Define the width of the texture
  19178. * @param height Define the height of the texture
  19179. * @param scene Define the scene the texture belongs to
  19180. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19181. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19182. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19183. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19184. * @returns the RGBA texture
  19185. */
  19186. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19187. /**
  19188. * Creates a R texture from some data.
  19189. * @param data Define the texture data
  19190. * @param width Define the width of the texture
  19191. * @param height Define the height of the texture
  19192. * @param scene Define the scene the texture belongs to
  19193. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19194. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19195. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19196. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19197. * @returns the R texture
  19198. */
  19199. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19200. }
  19201. }
  19202. declare module "babylonjs/Animations/runtimeAnimation" {
  19203. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19204. import { Animatable } from "babylonjs/Animations/animatable";
  19205. import { Scene } from "babylonjs/scene";
  19206. /**
  19207. * Defines a runtime animation
  19208. */
  19209. export class RuntimeAnimation {
  19210. private _events;
  19211. /**
  19212. * The current frame of the runtime animation
  19213. */
  19214. private _currentFrame;
  19215. /**
  19216. * The animation used by the runtime animation
  19217. */
  19218. private _animation;
  19219. /**
  19220. * The target of the runtime animation
  19221. */
  19222. private _target;
  19223. /**
  19224. * The initiating animatable
  19225. */
  19226. private _host;
  19227. /**
  19228. * The original value of the runtime animation
  19229. */
  19230. private _originalValue;
  19231. /**
  19232. * The original blend value of the runtime animation
  19233. */
  19234. private _originalBlendValue;
  19235. /**
  19236. * The offsets cache of the runtime animation
  19237. */
  19238. private _offsetsCache;
  19239. /**
  19240. * The high limits cache of the runtime animation
  19241. */
  19242. private _highLimitsCache;
  19243. /**
  19244. * Specifies if the runtime animation has been stopped
  19245. */
  19246. private _stopped;
  19247. /**
  19248. * The blending factor of the runtime animation
  19249. */
  19250. private _blendingFactor;
  19251. /**
  19252. * The BabylonJS scene
  19253. */
  19254. private _scene;
  19255. /**
  19256. * The current value of the runtime animation
  19257. */
  19258. private _currentValue;
  19259. /** @hidden */
  19260. _animationState: _IAnimationState;
  19261. /**
  19262. * The active target of the runtime animation
  19263. */
  19264. private _activeTargets;
  19265. private _currentActiveTarget;
  19266. private _directTarget;
  19267. /**
  19268. * The target path of the runtime animation
  19269. */
  19270. private _targetPath;
  19271. /**
  19272. * The weight of the runtime animation
  19273. */
  19274. private _weight;
  19275. /**
  19276. * The ratio offset of the runtime animation
  19277. */
  19278. private _ratioOffset;
  19279. /**
  19280. * The previous delay of the runtime animation
  19281. */
  19282. private _previousDelay;
  19283. /**
  19284. * The previous ratio of the runtime animation
  19285. */
  19286. private _previousRatio;
  19287. private _enableBlending;
  19288. private _keys;
  19289. private _minFrame;
  19290. private _maxFrame;
  19291. private _minValue;
  19292. private _maxValue;
  19293. private _targetIsArray;
  19294. /**
  19295. * Gets the current frame of the runtime animation
  19296. */
  19297. readonly currentFrame: number;
  19298. /**
  19299. * Gets the weight of the runtime animation
  19300. */
  19301. readonly weight: number;
  19302. /**
  19303. * Gets the current value of the runtime animation
  19304. */
  19305. readonly currentValue: any;
  19306. /**
  19307. * Gets the target path of the runtime animation
  19308. */
  19309. readonly targetPath: string;
  19310. /**
  19311. * Gets the actual target of the runtime animation
  19312. */
  19313. readonly target: any;
  19314. /** @hidden */
  19315. _onLoop: () => void;
  19316. /**
  19317. * Create a new RuntimeAnimation object
  19318. * @param target defines the target of the animation
  19319. * @param animation defines the source animation object
  19320. * @param scene defines the hosting scene
  19321. * @param host defines the initiating Animatable
  19322. */
  19323. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19324. private _preparePath;
  19325. /**
  19326. * Gets the animation from the runtime animation
  19327. */
  19328. readonly animation: Animation;
  19329. /**
  19330. * Resets the runtime animation to the beginning
  19331. * @param restoreOriginal defines whether to restore the target property to the original value
  19332. */
  19333. reset(restoreOriginal?: boolean): void;
  19334. /**
  19335. * Specifies if the runtime animation is stopped
  19336. * @returns Boolean specifying if the runtime animation is stopped
  19337. */
  19338. isStopped(): boolean;
  19339. /**
  19340. * Disposes of the runtime animation
  19341. */
  19342. dispose(): void;
  19343. /**
  19344. * Apply the interpolated value to the target
  19345. * @param currentValue defines the value computed by the animation
  19346. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19347. */
  19348. setValue(currentValue: any, weight: number): void;
  19349. private _getOriginalValues;
  19350. private _setValue;
  19351. /**
  19352. * Gets the loop pmode of the runtime animation
  19353. * @returns Loop Mode
  19354. */
  19355. private _getCorrectLoopMode;
  19356. /**
  19357. * Move the current animation to a given frame
  19358. * @param frame defines the frame to move to
  19359. */
  19360. goToFrame(frame: number): void;
  19361. /**
  19362. * @hidden Internal use only
  19363. */
  19364. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19365. /**
  19366. * Execute the current animation
  19367. * @param delay defines the delay to add to the current frame
  19368. * @param from defines the lower bound of the animation range
  19369. * @param to defines the upper bound of the animation range
  19370. * @param loop defines if the current animation must loop
  19371. * @param speedRatio defines the current speed ratio
  19372. * @param weight defines the weight of the animation (default is -1 so no weight)
  19373. * @param onLoop optional callback called when animation loops
  19374. * @returns a boolean indicating if the animation is running
  19375. */
  19376. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19377. }
  19378. }
  19379. declare module "babylonjs/Animations/animatable" {
  19380. import { Animation } from "babylonjs/Animations/animation";
  19381. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19382. import { Nullable } from "babylonjs/types";
  19383. import { Observable } from "babylonjs/Misc/observable";
  19384. import { Scene } from "babylonjs/scene";
  19385. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19386. import { Node } from "babylonjs/node";
  19387. /**
  19388. * Class used to store an actual running animation
  19389. */
  19390. export class Animatable {
  19391. /** defines the target object */
  19392. target: any;
  19393. /** defines the starting frame number (default is 0) */
  19394. fromFrame: number;
  19395. /** defines the ending frame number (default is 100) */
  19396. toFrame: number;
  19397. /** defines if the animation must loop (default is false) */
  19398. loopAnimation: boolean;
  19399. /** defines a callback to call when animation ends if it is not looping */
  19400. onAnimationEnd?: (() => void) | null | undefined;
  19401. /** defines a callback to call when animation loops */
  19402. onAnimationLoop?: (() => void) | null | undefined;
  19403. private _localDelayOffset;
  19404. private _pausedDelay;
  19405. private _runtimeAnimations;
  19406. private _paused;
  19407. private _scene;
  19408. private _speedRatio;
  19409. private _weight;
  19410. private _syncRoot;
  19411. /**
  19412. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19413. * This will only apply for non looping animation (default is true)
  19414. */
  19415. disposeOnEnd: boolean;
  19416. /**
  19417. * Gets a boolean indicating if the animation has started
  19418. */
  19419. animationStarted: boolean;
  19420. /**
  19421. * Observer raised when the animation ends
  19422. */
  19423. onAnimationEndObservable: Observable<Animatable>;
  19424. /**
  19425. * Observer raised when the animation loops
  19426. */
  19427. onAnimationLoopObservable: Observable<Animatable>;
  19428. /**
  19429. * Gets the root Animatable used to synchronize and normalize animations
  19430. */
  19431. readonly syncRoot: Nullable<Animatable>;
  19432. /**
  19433. * Gets the current frame of the first RuntimeAnimation
  19434. * Used to synchronize Animatables
  19435. */
  19436. readonly masterFrame: number;
  19437. /**
  19438. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19439. */
  19440. weight: number;
  19441. /**
  19442. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19443. */
  19444. speedRatio: number;
  19445. /**
  19446. * Creates a new Animatable
  19447. * @param scene defines the hosting scene
  19448. * @param target defines the target object
  19449. * @param fromFrame defines the starting frame number (default is 0)
  19450. * @param toFrame defines the ending frame number (default is 100)
  19451. * @param loopAnimation defines if the animation must loop (default is false)
  19452. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19453. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19454. * @param animations defines a group of animation to add to the new Animatable
  19455. * @param onAnimationLoop defines a callback to call when animation loops
  19456. */
  19457. constructor(scene: Scene,
  19458. /** defines the target object */
  19459. target: any,
  19460. /** defines the starting frame number (default is 0) */
  19461. fromFrame?: number,
  19462. /** defines the ending frame number (default is 100) */
  19463. toFrame?: number,
  19464. /** defines if the animation must loop (default is false) */
  19465. loopAnimation?: boolean, speedRatio?: number,
  19466. /** defines a callback to call when animation ends if it is not looping */
  19467. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19468. /** defines a callback to call when animation loops */
  19469. onAnimationLoop?: (() => void) | null | undefined);
  19470. /**
  19471. * Synchronize and normalize current Animatable with a source Animatable
  19472. * This is useful when using animation weights and when animations are not of the same length
  19473. * @param root defines the root Animatable to synchronize with
  19474. * @returns the current Animatable
  19475. */
  19476. syncWith(root: Animatable): Animatable;
  19477. /**
  19478. * Gets the list of runtime animations
  19479. * @returns an array of RuntimeAnimation
  19480. */
  19481. getAnimations(): RuntimeAnimation[];
  19482. /**
  19483. * Adds more animations to the current animatable
  19484. * @param target defines the target of the animations
  19485. * @param animations defines the new animations to add
  19486. */
  19487. appendAnimations(target: any, animations: Animation[]): void;
  19488. /**
  19489. * Gets the source animation for a specific property
  19490. * @param property defines the propertyu to look for
  19491. * @returns null or the source animation for the given property
  19492. */
  19493. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19494. /**
  19495. * Gets the runtime animation for a specific property
  19496. * @param property defines the propertyu to look for
  19497. * @returns null or the runtime animation for the given property
  19498. */
  19499. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19500. /**
  19501. * Resets the animatable to its original state
  19502. */
  19503. reset(): void;
  19504. /**
  19505. * Allows the animatable to blend with current running animations
  19506. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19507. * @param blendingSpeed defines the blending speed to use
  19508. */
  19509. enableBlending(blendingSpeed: number): void;
  19510. /**
  19511. * Disable animation blending
  19512. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19513. */
  19514. disableBlending(): void;
  19515. /**
  19516. * Jump directly to a given frame
  19517. * @param frame defines the frame to jump to
  19518. */
  19519. goToFrame(frame: number): void;
  19520. /**
  19521. * Pause the animation
  19522. */
  19523. pause(): void;
  19524. /**
  19525. * Restart the animation
  19526. */
  19527. restart(): void;
  19528. private _raiseOnAnimationEnd;
  19529. /**
  19530. * Stop and delete the current animation
  19531. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19532. * @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)
  19533. */
  19534. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19535. /**
  19536. * Wait asynchronously for the animation to end
  19537. * @returns a promise which will be fullfilled when the animation ends
  19538. */
  19539. waitAsync(): Promise<Animatable>;
  19540. /** @hidden */
  19541. _animate(delay: number): boolean;
  19542. }
  19543. module "babylonjs/scene" {
  19544. interface Scene {
  19545. /** @hidden */
  19546. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19547. /** @hidden */
  19548. _processLateAnimationBindingsForMatrices(holder: {
  19549. totalWeight: number;
  19550. animations: RuntimeAnimation[];
  19551. originalValue: Matrix;
  19552. }): any;
  19553. /** @hidden */
  19554. _processLateAnimationBindingsForQuaternions(holder: {
  19555. totalWeight: number;
  19556. animations: RuntimeAnimation[];
  19557. originalValue: Quaternion;
  19558. }, refQuaternion: Quaternion): Quaternion;
  19559. /** @hidden */
  19560. _processLateAnimationBindings(): void;
  19561. /**
  19562. * Will start the animation sequence of a given target
  19563. * @param target defines the target
  19564. * @param from defines from which frame should animation start
  19565. * @param to defines until which frame should animation run.
  19566. * @param weight defines the weight to apply to the animation (1.0 by default)
  19567. * @param loop defines if the animation loops
  19568. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19569. * @param onAnimationEnd defines the function to be executed when the animation ends
  19570. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19571. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19572. * @param onAnimationLoop defines the callback to call when an animation loops
  19573. * @returns the animatable object created for this animation
  19574. */
  19575. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19576. /**
  19577. * Will start the animation sequence of a given target
  19578. * @param target defines the target
  19579. * @param from defines from which frame should animation start
  19580. * @param to defines until which frame should animation run.
  19581. * @param loop defines if the animation loops
  19582. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19583. * @param onAnimationEnd defines the function to be executed when the animation ends
  19584. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19585. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19586. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19587. * @param onAnimationLoop defines the callback to call when an animation loops
  19588. * @returns the animatable object created for this animation
  19589. */
  19590. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19591. /**
  19592. * Will start the animation sequence of a given target and its hierarchy
  19593. * @param target defines the target
  19594. * @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.
  19595. * @param from defines from which frame should animation start
  19596. * @param to defines until which frame should animation run.
  19597. * @param loop defines if the animation loops
  19598. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19599. * @param onAnimationEnd defines the function to be executed when the animation ends
  19600. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19601. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19602. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19603. * @param onAnimationLoop defines the callback to call when an animation loops
  19604. * @returns the list of created animatables
  19605. */
  19606. 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[];
  19607. /**
  19608. * Begin a new animation on a given node
  19609. * @param target defines the target where the animation will take place
  19610. * @param animations defines the list of animations to start
  19611. * @param from defines the initial value
  19612. * @param to defines the final value
  19613. * @param loop defines if you want animation to loop (off by default)
  19614. * @param speedRatio defines the speed ratio to apply to all animations
  19615. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19616. * @param onAnimationLoop defines the callback to call when an animation loops
  19617. * @returns the list of created animatables
  19618. */
  19619. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19620. /**
  19621. * Begin a new animation on a given node and its hierarchy
  19622. * @param target defines the root node where the animation will take place
  19623. * @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.
  19624. * @param animations defines the list of animations to start
  19625. * @param from defines the initial value
  19626. * @param to defines the final value
  19627. * @param loop defines if you want animation to loop (off by default)
  19628. * @param speedRatio defines the speed ratio to apply to all animations
  19629. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19630. * @param onAnimationLoop defines the callback to call when an animation loops
  19631. * @returns the list of animatables created for all nodes
  19632. */
  19633. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19634. /**
  19635. * Gets the animatable associated with a specific target
  19636. * @param target defines the target of the animatable
  19637. * @returns the required animatable if found
  19638. */
  19639. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19640. /**
  19641. * Gets all animatables associated with a given target
  19642. * @param target defines the target to look animatables for
  19643. * @returns an array of Animatables
  19644. */
  19645. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19646. /**
  19647. * Stops and removes all animations that have been applied to the scene
  19648. */
  19649. stopAllAnimations(): void;
  19650. }
  19651. }
  19652. module "babylonjs/Bones/bone" {
  19653. interface Bone {
  19654. /**
  19655. * Copy an animation range from another bone
  19656. * @param source defines the source bone
  19657. * @param rangeName defines the range name to copy
  19658. * @param frameOffset defines the frame offset
  19659. * @param rescaleAsRequired defines if rescaling must be applied if required
  19660. * @param skelDimensionsRatio defines the scaling ratio
  19661. * @returns true if operation was successful
  19662. */
  19663. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19664. }
  19665. }
  19666. }
  19667. declare module "babylonjs/Bones/skeleton" {
  19668. import { Bone } from "babylonjs/Bones/bone";
  19669. import { IAnimatable } from "babylonjs/Misc/tools";
  19670. import { Observable } from "babylonjs/Misc/observable";
  19671. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19672. import { Scene } from "babylonjs/scene";
  19673. import { Nullable } from "babylonjs/types";
  19674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19675. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19676. import { Animatable } from "babylonjs/Animations/animatable";
  19677. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19678. import { Animation } from "babylonjs/Animations/animation";
  19679. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19680. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19681. /**
  19682. * Class used to handle skinning animations
  19683. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19684. */
  19685. export class Skeleton implements IAnimatable {
  19686. /** defines the skeleton name */
  19687. name: string;
  19688. /** defines the skeleton Id */
  19689. id: string;
  19690. /**
  19691. * Defines the list of child bones
  19692. */
  19693. bones: Bone[];
  19694. /**
  19695. * Defines an estimate of the dimension of the skeleton at rest
  19696. */
  19697. dimensionsAtRest: Vector3;
  19698. /**
  19699. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19700. */
  19701. needInitialSkinMatrix: boolean;
  19702. /**
  19703. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19704. */
  19705. overrideMesh: Nullable<AbstractMesh>;
  19706. /**
  19707. * Gets the list of animations attached to this skeleton
  19708. */
  19709. animations: Array<Animation>;
  19710. private _scene;
  19711. private _isDirty;
  19712. private _transformMatrices;
  19713. private _transformMatrixTexture;
  19714. private _meshesWithPoseMatrix;
  19715. private _animatables;
  19716. private _identity;
  19717. private _synchronizedWithMesh;
  19718. private _ranges;
  19719. private _lastAbsoluteTransformsUpdateId;
  19720. private _canUseTextureForBones;
  19721. private _uniqueId;
  19722. /** @hidden */
  19723. _numBonesWithLinkedTransformNode: number;
  19724. /** @hidden */
  19725. _hasWaitingData: Nullable<boolean>;
  19726. /**
  19727. * Specifies if the skeleton should be serialized
  19728. */
  19729. doNotSerialize: boolean;
  19730. private _useTextureToStoreBoneMatrices;
  19731. /**
  19732. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19733. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19734. */
  19735. useTextureToStoreBoneMatrices: boolean;
  19736. private _animationPropertiesOverride;
  19737. /**
  19738. * Gets or sets the animation properties override
  19739. */
  19740. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19741. /**
  19742. * List of inspectable custom properties (used by the Inspector)
  19743. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19744. */
  19745. inspectableCustomProperties: IInspectable[];
  19746. /**
  19747. * An observable triggered before computing the skeleton's matrices
  19748. */
  19749. onBeforeComputeObservable: Observable<Skeleton>;
  19750. /**
  19751. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19752. */
  19753. readonly isUsingTextureForMatrices: boolean;
  19754. /**
  19755. * Gets the unique ID of this skeleton
  19756. */
  19757. readonly uniqueId: number;
  19758. /**
  19759. * Creates a new skeleton
  19760. * @param name defines the skeleton name
  19761. * @param id defines the skeleton Id
  19762. * @param scene defines the hosting scene
  19763. */
  19764. constructor(
  19765. /** defines the skeleton name */
  19766. name: string,
  19767. /** defines the skeleton Id */
  19768. id: string, scene: Scene);
  19769. /**
  19770. * Gets the current object class name.
  19771. * @return the class name
  19772. */
  19773. getClassName(): string;
  19774. /**
  19775. * Returns an array containing the root bones
  19776. * @returns an array containing the root bones
  19777. */
  19778. getChildren(): Array<Bone>;
  19779. /**
  19780. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19781. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19782. * @returns a Float32Array containing matrices data
  19783. */
  19784. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19785. /**
  19786. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19787. * @returns a raw texture containing the data
  19788. */
  19789. getTransformMatrixTexture(): Nullable<RawTexture>;
  19790. /**
  19791. * Gets the current hosting scene
  19792. * @returns a scene object
  19793. */
  19794. getScene(): Scene;
  19795. /**
  19796. * Gets a string representing the current skeleton data
  19797. * @param fullDetails defines a boolean indicating if we want a verbose version
  19798. * @returns a string representing the current skeleton data
  19799. */
  19800. toString(fullDetails?: boolean): string;
  19801. /**
  19802. * Get bone's index searching by name
  19803. * @param name defines bone's name to search for
  19804. * @return the indice of the bone. Returns -1 if not found
  19805. */
  19806. getBoneIndexByName(name: string): number;
  19807. /**
  19808. * Creater a new animation range
  19809. * @param name defines the name of the range
  19810. * @param from defines the start key
  19811. * @param to defines the end key
  19812. */
  19813. createAnimationRange(name: string, from: number, to: number): void;
  19814. /**
  19815. * Delete a specific animation range
  19816. * @param name defines the name of the range
  19817. * @param deleteFrames defines if frames must be removed as well
  19818. */
  19819. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19820. /**
  19821. * Gets a specific animation range
  19822. * @param name defines the name of the range to look for
  19823. * @returns the requested animation range or null if not found
  19824. */
  19825. getAnimationRange(name: string): Nullable<AnimationRange>;
  19826. /**
  19827. * Gets the list of all animation ranges defined on this skeleton
  19828. * @returns an array
  19829. */
  19830. getAnimationRanges(): Nullable<AnimationRange>[];
  19831. /**
  19832. * Copy animation range from a source skeleton.
  19833. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19834. * @param source defines the source skeleton
  19835. * @param name defines the name of the range to copy
  19836. * @param rescaleAsRequired defines if rescaling must be applied if required
  19837. * @returns true if operation was successful
  19838. */
  19839. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19840. /**
  19841. * Forces the skeleton to go to rest pose
  19842. */
  19843. returnToRest(): void;
  19844. private _getHighestAnimationFrame;
  19845. /**
  19846. * Begin a specific animation range
  19847. * @param name defines the name of the range to start
  19848. * @param loop defines if looping must be turned on (false by default)
  19849. * @param speedRatio defines the speed ratio to apply (1 by default)
  19850. * @param onAnimationEnd defines a callback which will be called when animation will end
  19851. * @returns a new animatable
  19852. */
  19853. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19854. /** @hidden */
  19855. _markAsDirty(): void;
  19856. /** @hidden */
  19857. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19858. /** @hidden */
  19859. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19860. private _computeTransformMatrices;
  19861. /**
  19862. * Build all resources required to render a skeleton
  19863. */
  19864. prepare(): void;
  19865. /**
  19866. * Gets the list of animatables currently running for this skeleton
  19867. * @returns an array of animatables
  19868. */
  19869. getAnimatables(): IAnimatable[];
  19870. /**
  19871. * Clone the current skeleton
  19872. * @param name defines the name of the new skeleton
  19873. * @param id defines the id of the new skeleton
  19874. * @returns the new skeleton
  19875. */
  19876. clone(name: string, id: string): Skeleton;
  19877. /**
  19878. * Enable animation blending for this skeleton
  19879. * @param blendingSpeed defines the blending speed to apply
  19880. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19881. */
  19882. enableBlending(blendingSpeed?: number): void;
  19883. /**
  19884. * Releases all resources associated with the current skeleton
  19885. */
  19886. dispose(): void;
  19887. /**
  19888. * Serialize the skeleton in a JSON object
  19889. * @returns a JSON object
  19890. */
  19891. serialize(): any;
  19892. /**
  19893. * Creates a new skeleton from serialized data
  19894. * @param parsedSkeleton defines the serialized data
  19895. * @param scene defines the hosting scene
  19896. * @returns a new skeleton
  19897. */
  19898. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19899. /**
  19900. * Compute all node absolute transforms
  19901. * @param forceUpdate defines if computation must be done even if cache is up to date
  19902. */
  19903. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19904. /**
  19905. * Gets the root pose matrix
  19906. * @returns a matrix
  19907. */
  19908. getPoseMatrix(): Nullable<Matrix>;
  19909. /**
  19910. * Sorts bones per internal index
  19911. */
  19912. sortBones(): void;
  19913. private _sortBones;
  19914. }
  19915. }
  19916. declare module "babylonjs/Morph/morphTarget" {
  19917. import { IAnimatable } from "babylonjs/Misc/tools";
  19918. import { Observable } from "babylonjs/Misc/observable";
  19919. import { Nullable, FloatArray } from "babylonjs/types";
  19920. import { Scene } from "babylonjs/scene";
  19921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19922. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19923. /**
  19924. * Defines a target to use with MorphTargetManager
  19925. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19926. */
  19927. export class MorphTarget implements IAnimatable {
  19928. /** defines the name of the target */
  19929. name: string;
  19930. /**
  19931. * Gets or sets the list of animations
  19932. */
  19933. animations: import("babylonjs/Animations/animation").Animation[];
  19934. private _scene;
  19935. private _positions;
  19936. private _normals;
  19937. private _tangents;
  19938. private _influence;
  19939. /**
  19940. * Observable raised when the influence changes
  19941. */
  19942. onInfluenceChanged: Observable<boolean>;
  19943. /** @hidden */
  19944. _onDataLayoutChanged: Observable<void>;
  19945. /**
  19946. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19947. */
  19948. influence: number;
  19949. /**
  19950. * Gets or sets the id of the morph Target
  19951. */
  19952. id: string;
  19953. private _animationPropertiesOverride;
  19954. /**
  19955. * Gets or sets the animation properties override
  19956. */
  19957. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19958. /**
  19959. * Creates a new MorphTarget
  19960. * @param name defines the name of the target
  19961. * @param influence defines the influence to use
  19962. * @param scene defines the scene the morphtarget belongs to
  19963. */
  19964. constructor(
  19965. /** defines the name of the target */
  19966. name: string, influence?: number, scene?: Nullable<Scene>);
  19967. /**
  19968. * Gets a boolean defining if the target contains position data
  19969. */
  19970. readonly hasPositions: boolean;
  19971. /**
  19972. * Gets a boolean defining if the target contains normal data
  19973. */
  19974. readonly hasNormals: boolean;
  19975. /**
  19976. * Gets a boolean defining if the target contains tangent data
  19977. */
  19978. readonly hasTangents: boolean;
  19979. /**
  19980. * Affects position data to this target
  19981. * @param data defines the position data to use
  19982. */
  19983. setPositions(data: Nullable<FloatArray>): void;
  19984. /**
  19985. * Gets the position data stored in this target
  19986. * @returns a FloatArray containing the position data (or null if not present)
  19987. */
  19988. getPositions(): Nullable<FloatArray>;
  19989. /**
  19990. * Affects normal data to this target
  19991. * @param data defines the normal data to use
  19992. */
  19993. setNormals(data: Nullable<FloatArray>): void;
  19994. /**
  19995. * Gets the normal data stored in this target
  19996. * @returns a FloatArray containing the normal data (or null if not present)
  19997. */
  19998. getNormals(): Nullable<FloatArray>;
  19999. /**
  20000. * Affects tangent data to this target
  20001. * @param data defines the tangent data to use
  20002. */
  20003. setTangents(data: Nullable<FloatArray>): void;
  20004. /**
  20005. * Gets the tangent data stored in this target
  20006. * @returns a FloatArray containing the tangent data (or null if not present)
  20007. */
  20008. getTangents(): Nullable<FloatArray>;
  20009. /**
  20010. * Serializes the current target into a Serialization object
  20011. * @returns the serialized object
  20012. */
  20013. serialize(): any;
  20014. /**
  20015. * Returns the string "MorphTarget"
  20016. * @returns "MorphTarget"
  20017. */
  20018. getClassName(): string;
  20019. /**
  20020. * Creates a new target from serialized data
  20021. * @param serializationObject defines the serialized data to use
  20022. * @returns a new MorphTarget
  20023. */
  20024. static Parse(serializationObject: any): MorphTarget;
  20025. /**
  20026. * Creates a MorphTarget from mesh data
  20027. * @param mesh defines the source mesh
  20028. * @param name defines the name to use for the new target
  20029. * @param influence defines the influence to attach to the target
  20030. * @returns a new MorphTarget
  20031. */
  20032. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20033. }
  20034. }
  20035. declare module "babylonjs/Morph/morphTargetManager" {
  20036. import { Nullable } from "babylonjs/types";
  20037. import { Scene } from "babylonjs/scene";
  20038. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20039. /**
  20040. * This class is used to deform meshes using morphing between different targets
  20041. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20042. */
  20043. export class MorphTargetManager {
  20044. private _targets;
  20045. private _targetInfluenceChangedObservers;
  20046. private _targetDataLayoutChangedObservers;
  20047. private _activeTargets;
  20048. private _scene;
  20049. private _influences;
  20050. private _supportsNormals;
  20051. private _supportsTangents;
  20052. private _vertexCount;
  20053. private _uniqueId;
  20054. private _tempInfluences;
  20055. /**
  20056. * Creates a new MorphTargetManager
  20057. * @param scene defines the current scene
  20058. */
  20059. constructor(scene?: Nullable<Scene>);
  20060. /**
  20061. * Gets the unique ID of this manager
  20062. */
  20063. readonly uniqueId: number;
  20064. /**
  20065. * Gets the number of vertices handled by this manager
  20066. */
  20067. readonly vertexCount: number;
  20068. /**
  20069. * Gets a boolean indicating if this manager supports morphing of normals
  20070. */
  20071. readonly supportsNormals: boolean;
  20072. /**
  20073. * Gets a boolean indicating if this manager supports morphing of tangents
  20074. */
  20075. readonly supportsTangents: boolean;
  20076. /**
  20077. * Gets the number of targets stored in this manager
  20078. */
  20079. readonly numTargets: number;
  20080. /**
  20081. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20082. */
  20083. readonly numInfluencers: number;
  20084. /**
  20085. * Gets the list of influences (one per target)
  20086. */
  20087. readonly influences: Float32Array;
  20088. /**
  20089. * Gets the active target at specified index. An active target is a target with an influence > 0
  20090. * @param index defines the index to check
  20091. * @returns the requested target
  20092. */
  20093. getActiveTarget(index: number): MorphTarget;
  20094. /**
  20095. * Gets the target at specified index
  20096. * @param index defines the index to check
  20097. * @returns the requested target
  20098. */
  20099. getTarget(index: number): MorphTarget;
  20100. /**
  20101. * Add a new target to this manager
  20102. * @param target defines the target to add
  20103. */
  20104. addTarget(target: MorphTarget): void;
  20105. /**
  20106. * Removes a target from the manager
  20107. * @param target defines the target to remove
  20108. */
  20109. removeTarget(target: MorphTarget): void;
  20110. /**
  20111. * Serializes the current manager into a Serialization object
  20112. * @returns the serialized object
  20113. */
  20114. serialize(): any;
  20115. private _syncActiveTargets;
  20116. /**
  20117. * Syncrhonize the targets with all the meshes using this morph target manager
  20118. */
  20119. synchronize(): void;
  20120. /**
  20121. * Creates a new MorphTargetManager from serialized data
  20122. * @param serializationObject defines the serialized data
  20123. * @param scene defines the hosting scene
  20124. * @returns the new MorphTargetManager
  20125. */
  20126. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20127. }
  20128. }
  20129. declare module "babylonjs/Meshes/meshLODLevel" {
  20130. import { Mesh } from "babylonjs/Meshes/mesh";
  20131. import { Nullable } from "babylonjs/types";
  20132. /**
  20133. * Class used to represent a specific level of detail of a mesh
  20134. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20135. */
  20136. export class MeshLODLevel {
  20137. /** Defines the distance where this level should star being displayed */
  20138. distance: number;
  20139. /** Defines the mesh to use to render this level */
  20140. mesh: Nullable<Mesh>;
  20141. /**
  20142. * Creates a new LOD level
  20143. * @param distance defines the distance where this level should star being displayed
  20144. * @param mesh defines the mesh to use to render this level
  20145. */
  20146. constructor(
  20147. /** Defines the distance where this level should star being displayed */
  20148. distance: number,
  20149. /** Defines the mesh to use to render this level */
  20150. mesh: Nullable<Mesh>);
  20151. }
  20152. }
  20153. declare module "babylonjs/Meshes/groundMesh" {
  20154. import { Scene } from "babylonjs/scene";
  20155. import { Vector3 } from "babylonjs/Maths/math";
  20156. import { Mesh } from "babylonjs/Meshes/mesh";
  20157. /**
  20158. * Mesh representing the gorund
  20159. */
  20160. export class GroundMesh extends Mesh {
  20161. /** If octree should be generated */
  20162. generateOctree: boolean;
  20163. private _heightQuads;
  20164. /** @hidden */
  20165. _subdivisionsX: number;
  20166. /** @hidden */
  20167. _subdivisionsY: number;
  20168. /** @hidden */
  20169. _width: number;
  20170. /** @hidden */
  20171. _height: number;
  20172. /** @hidden */
  20173. _minX: number;
  20174. /** @hidden */
  20175. _maxX: number;
  20176. /** @hidden */
  20177. _minZ: number;
  20178. /** @hidden */
  20179. _maxZ: number;
  20180. constructor(name: string, scene: Scene);
  20181. /**
  20182. * "GroundMesh"
  20183. * @returns "GroundMesh"
  20184. */
  20185. getClassName(): string;
  20186. /**
  20187. * The minimum of x and y subdivisions
  20188. */
  20189. readonly subdivisions: number;
  20190. /**
  20191. * X subdivisions
  20192. */
  20193. readonly subdivisionsX: number;
  20194. /**
  20195. * Y subdivisions
  20196. */
  20197. readonly subdivisionsY: number;
  20198. /**
  20199. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20200. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20201. * @param chunksCount the number of subdivisions for x and y
  20202. * @param octreeBlocksSize (Default: 32)
  20203. */
  20204. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20205. /**
  20206. * Returns a height (y) value in the Worl system :
  20207. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20208. * @param x x coordinate
  20209. * @param z z coordinate
  20210. * @returns the ground y position if (x, z) are outside the ground surface.
  20211. */
  20212. getHeightAtCoordinates(x: number, z: number): number;
  20213. /**
  20214. * Returns a normalized vector (Vector3) orthogonal to the ground
  20215. * at the ground coordinates (x, z) expressed in the World system.
  20216. * @param x x coordinate
  20217. * @param z z coordinate
  20218. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20219. */
  20220. getNormalAtCoordinates(x: number, z: number): Vector3;
  20221. /**
  20222. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20223. * at the ground coordinates (x, z) expressed in the World system.
  20224. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20225. * @param x x coordinate
  20226. * @param z z coordinate
  20227. * @param ref vector to store the result
  20228. * @returns the GroundMesh.
  20229. */
  20230. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20231. /**
  20232. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20233. * if the ground has been updated.
  20234. * This can be used in the render loop.
  20235. * @returns the GroundMesh.
  20236. */
  20237. updateCoordinateHeights(): GroundMesh;
  20238. private _getFacetAt;
  20239. private _initHeightQuads;
  20240. private _computeHeightQuads;
  20241. /**
  20242. * Serializes this ground mesh
  20243. * @param serializationObject object to write serialization to
  20244. */
  20245. serialize(serializationObject: any): void;
  20246. /**
  20247. * Parses a serialized ground mesh
  20248. * @param parsedMesh the serialized mesh
  20249. * @param scene the scene to create the ground mesh in
  20250. * @returns the created ground mesh
  20251. */
  20252. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20253. }
  20254. }
  20255. declare module "babylonjs/Physics/physicsJoint" {
  20256. import { Vector3 } from "babylonjs/Maths/math";
  20257. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20258. /**
  20259. * Interface for Physics-Joint data
  20260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20261. */
  20262. export interface PhysicsJointData {
  20263. /**
  20264. * The main pivot of the joint
  20265. */
  20266. mainPivot?: Vector3;
  20267. /**
  20268. * The connected pivot of the joint
  20269. */
  20270. connectedPivot?: Vector3;
  20271. /**
  20272. * The main axis of the joint
  20273. */
  20274. mainAxis?: Vector3;
  20275. /**
  20276. * The connected axis of the joint
  20277. */
  20278. connectedAxis?: Vector3;
  20279. /**
  20280. * The collision of the joint
  20281. */
  20282. collision?: boolean;
  20283. /**
  20284. * Native Oimo/Cannon/Energy data
  20285. */
  20286. nativeParams?: any;
  20287. }
  20288. /**
  20289. * This is a holder class for the physics joint created by the physics plugin
  20290. * It holds a set of functions to control the underlying joint
  20291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20292. */
  20293. export class PhysicsJoint {
  20294. /**
  20295. * The type of the physics joint
  20296. */
  20297. type: number;
  20298. /**
  20299. * The data for the physics joint
  20300. */
  20301. jointData: PhysicsJointData;
  20302. private _physicsJoint;
  20303. protected _physicsPlugin: IPhysicsEnginePlugin;
  20304. /**
  20305. * Initializes the physics joint
  20306. * @param type The type of the physics joint
  20307. * @param jointData The data for the physics joint
  20308. */
  20309. constructor(
  20310. /**
  20311. * The type of the physics joint
  20312. */
  20313. type: number,
  20314. /**
  20315. * The data for the physics joint
  20316. */
  20317. jointData: PhysicsJointData);
  20318. /**
  20319. * Gets the physics joint
  20320. */
  20321. /**
  20322. * Sets the physics joint
  20323. */
  20324. physicsJoint: any;
  20325. /**
  20326. * Sets the physics plugin
  20327. */
  20328. physicsPlugin: IPhysicsEnginePlugin;
  20329. /**
  20330. * Execute a function that is physics-plugin specific.
  20331. * @param {Function} func the function that will be executed.
  20332. * It accepts two parameters: the physics world and the physics joint
  20333. */
  20334. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20335. /**
  20336. * Distance-Joint type
  20337. */
  20338. static DistanceJoint: number;
  20339. /**
  20340. * Hinge-Joint type
  20341. */
  20342. static HingeJoint: number;
  20343. /**
  20344. * Ball-and-Socket joint type
  20345. */
  20346. static BallAndSocketJoint: number;
  20347. /**
  20348. * Wheel-Joint type
  20349. */
  20350. static WheelJoint: number;
  20351. /**
  20352. * Slider-Joint type
  20353. */
  20354. static SliderJoint: number;
  20355. /**
  20356. * Prismatic-Joint type
  20357. */
  20358. static PrismaticJoint: number;
  20359. /**
  20360. * Universal-Joint type
  20361. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20362. */
  20363. static UniversalJoint: number;
  20364. /**
  20365. * Hinge-Joint 2 type
  20366. */
  20367. static Hinge2Joint: number;
  20368. /**
  20369. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20370. */
  20371. static PointToPointJoint: number;
  20372. /**
  20373. * Spring-Joint type
  20374. */
  20375. static SpringJoint: number;
  20376. /**
  20377. * Lock-Joint type
  20378. */
  20379. static LockJoint: number;
  20380. }
  20381. /**
  20382. * A class representing a physics distance joint
  20383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20384. */
  20385. export class DistanceJoint extends PhysicsJoint {
  20386. /**
  20387. *
  20388. * @param jointData The data for the Distance-Joint
  20389. */
  20390. constructor(jointData: DistanceJointData);
  20391. /**
  20392. * Update the predefined distance.
  20393. * @param maxDistance The maximum preferred distance
  20394. * @param minDistance The minimum preferred distance
  20395. */
  20396. updateDistance(maxDistance: number, minDistance?: number): void;
  20397. }
  20398. /**
  20399. * Represents a Motor-Enabled Joint
  20400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20401. */
  20402. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20403. /**
  20404. * Initializes the Motor-Enabled Joint
  20405. * @param type The type of the joint
  20406. * @param jointData The physica joint data for the joint
  20407. */
  20408. constructor(type: number, jointData: PhysicsJointData);
  20409. /**
  20410. * Set the motor values.
  20411. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20412. * @param force the force to apply
  20413. * @param maxForce max force for this motor.
  20414. */
  20415. setMotor(force?: number, maxForce?: number): void;
  20416. /**
  20417. * Set the motor's limits.
  20418. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20419. * @param upperLimit The upper limit of the motor
  20420. * @param lowerLimit The lower limit of the motor
  20421. */
  20422. setLimit(upperLimit: number, lowerLimit?: number): void;
  20423. }
  20424. /**
  20425. * This class represents a single physics Hinge-Joint
  20426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20427. */
  20428. export class HingeJoint extends MotorEnabledJoint {
  20429. /**
  20430. * Initializes the Hinge-Joint
  20431. * @param jointData The joint data for the Hinge-Joint
  20432. */
  20433. constructor(jointData: PhysicsJointData);
  20434. /**
  20435. * Set the motor values.
  20436. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20437. * @param {number} force the force to apply
  20438. * @param {number} maxForce max force for this motor.
  20439. */
  20440. setMotor(force?: number, maxForce?: number): void;
  20441. /**
  20442. * Set the motor's limits.
  20443. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20444. * @param upperLimit The upper limit of the motor
  20445. * @param lowerLimit The lower limit of the motor
  20446. */
  20447. setLimit(upperLimit: number, lowerLimit?: number): void;
  20448. }
  20449. /**
  20450. * This class represents a dual hinge physics joint (same as wheel joint)
  20451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20452. */
  20453. export class Hinge2Joint extends MotorEnabledJoint {
  20454. /**
  20455. * Initializes the Hinge2-Joint
  20456. * @param jointData The joint data for the Hinge2-Joint
  20457. */
  20458. constructor(jointData: PhysicsJointData);
  20459. /**
  20460. * Set the motor values.
  20461. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20462. * @param {number} targetSpeed the speed the motor is to reach
  20463. * @param {number} maxForce max force for this motor.
  20464. * @param {motorIndex} the motor's index, 0 or 1.
  20465. */
  20466. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20467. /**
  20468. * Set the motor limits.
  20469. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20470. * @param {number} upperLimit the upper limit
  20471. * @param {number} lowerLimit lower limit
  20472. * @param {motorIndex} the motor's index, 0 or 1.
  20473. */
  20474. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20475. }
  20476. /**
  20477. * Interface for a motor enabled joint
  20478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20479. */
  20480. export interface IMotorEnabledJoint {
  20481. /**
  20482. * Physics joint
  20483. */
  20484. physicsJoint: any;
  20485. /**
  20486. * Sets the motor of the motor-enabled joint
  20487. * @param force The force of the motor
  20488. * @param maxForce The maximum force of the motor
  20489. * @param motorIndex The index of the motor
  20490. */
  20491. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20492. /**
  20493. * Sets the limit of the motor
  20494. * @param upperLimit The upper limit of the motor
  20495. * @param lowerLimit The lower limit of the motor
  20496. * @param motorIndex The index of the motor
  20497. */
  20498. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20499. }
  20500. /**
  20501. * Joint data for a Distance-Joint
  20502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20503. */
  20504. export interface DistanceJointData extends PhysicsJointData {
  20505. /**
  20506. * Max distance the 2 joint objects can be apart
  20507. */
  20508. maxDistance: number;
  20509. }
  20510. /**
  20511. * Joint data from a spring joint
  20512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20513. */
  20514. export interface SpringJointData extends PhysicsJointData {
  20515. /**
  20516. * Length of the spring
  20517. */
  20518. length: number;
  20519. /**
  20520. * Stiffness of the spring
  20521. */
  20522. stiffness: number;
  20523. /**
  20524. * Damping of the spring
  20525. */
  20526. damping: number;
  20527. /** this callback will be called when applying the force to the impostors. */
  20528. forceApplicationCallback: () => void;
  20529. }
  20530. }
  20531. declare module "babylonjs/Physics/physicsRaycastResult" {
  20532. import { Vector3 } from "babylonjs/Maths/math";
  20533. /**
  20534. * Holds the data for the raycast result
  20535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20536. */
  20537. export class PhysicsRaycastResult {
  20538. private _hasHit;
  20539. private _hitDistance;
  20540. private _hitNormalWorld;
  20541. private _hitPointWorld;
  20542. private _rayFromWorld;
  20543. private _rayToWorld;
  20544. /**
  20545. * Gets if there was a hit
  20546. */
  20547. readonly hasHit: boolean;
  20548. /**
  20549. * Gets the distance from the hit
  20550. */
  20551. readonly hitDistance: number;
  20552. /**
  20553. * Gets the hit normal/direction in the world
  20554. */
  20555. readonly hitNormalWorld: Vector3;
  20556. /**
  20557. * Gets the hit point in the world
  20558. */
  20559. readonly hitPointWorld: Vector3;
  20560. /**
  20561. * Gets the ray "start point" of the ray in the world
  20562. */
  20563. readonly rayFromWorld: Vector3;
  20564. /**
  20565. * Gets the ray "end point" of the ray in the world
  20566. */
  20567. readonly rayToWorld: Vector3;
  20568. /**
  20569. * Sets the hit data (normal & point in world space)
  20570. * @param hitNormalWorld defines the normal in world space
  20571. * @param hitPointWorld defines the point in world space
  20572. */
  20573. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20574. /**
  20575. * Sets the distance from the start point to the hit point
  20576. * @param distance
  20577. */
  20578. setHitDistance(distance: number): void;
  20579. /**
  20580. * Calculates the distance manually
  20581. */
  20582. calculateHitDistance(): void;
  20583. /**
  20584. * Resets all the values to default
  20585. * @param from The from point on world space
  20586. * @param to The to point on world space
  20587. */
  20588. reset(from?: Vector3, to?: Vector3): void;
  20589. }
  20590. /**
  20591. * Interface for the size containing width and height
  20592. */
  20593. interface IXYZ {
  20594. /**
  20595. * X
  20596. */
  20597. x: number;
  20598. /**
  20599. * Y
  20600. */
  20601. y: number;
  20602. /**
  20603. * Z
  20604. */
  20605. z: number;
  20606. }
  20607. }
  20608. declare module "babylonjs/Physics/IPhysicsEngine" {
  20609. import { Nullable } from "babylonjs/types";
  20610. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20611. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20612. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20613. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20614. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20615. /**
  20616. * Interface used to describe a physics joint
  20617. */
  20618. export interface PhysicsImpostorJoint {
  20619. /** Defines the main impostor to which the joint is linked */
  20620. mainImpostor: PhysicsImpostor;
  20621. /** Defines the impostor that is connected to the main impostor using this joint */
  20622. connectedImpostor: PhysicsImpostor;
  20623. /** Defines the joint itself */
  20624. joint: PhysicsJoint;
  20625. }
  20626. /** @hidden */
  20627. export interface IPhysicsEnginePlugin {
  20628. world: any;
  20629. name: string;
  20630. setGravity(gravity: Vector3): void;
  20631. setTimeStep(timeStep: number): void;
  20632. getTimeStep(): number;
  20633. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20634. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20635. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20636. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20637. removePhysicsBody(impostor: PhysicsImpostor): void;
  20638. generateJoint(joint: PhysicsImpostorJoint): void;
  20639. removeJoint(joint: PhysicsImpostorJoint): void;
  20640. isSupported(): boolean;
  20641. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20642. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20643. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20644. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20645. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20646. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20647. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20648. getBodyMass(impostor: PhysicsImpostor): number;
  20649. getBodyFriction(impostor: PhysicsImpostor): number;
  20650. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20651. getBodyRestitution(impostor: PhysicsImpostor): number;
  20652. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20653. getBodyPressure?(impostor: PhysicsImpostor): number;
  20654. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20655. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20656. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20657. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20658. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20659. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20660. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20661. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20662. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20663. sleepBody(impostor: PhysicsImpostor): void;
  20664. wakeUpBody(impostor: PhysicsImpostor): void;
  20665. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20666. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20667. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20668. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20669. getRadius(impostor: PhysicsImpostor): number;
  20670. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20671. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20672. dispose(): void;
  20673. }
  20674. /**
  20675. * Interface used to define a physics engine
  20676. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20677. */
  20678. export interface IPhysicsEngine {
  20679. /**
  20680. * Gets the gravity vector used by the simulation
  20681. */
  20682. gravity: Vector3;
  20683. /**
  20684. * Sets the gravity vector used by the simulation
  20685. * @param gravity defines the gravity vector to use
  20686. */
  20687. setGravity(gravity: Vector3): void;
  20688. /**
  20689. * Set the time step of the physics engine.
  20690. * Default is 1/60.
  20691. * To slow it down, enter 1/600 for example.
  20692. * To speed it up, 1/30
  20693. * @param newTimeStep the new timestep to apply to this world.
  20694. */
  20695. setTimeStep(newTimeStep: number): void;
  20696. /**
  20697. * Get the time step of the physics engine.
  20698. * @returns the current time step
  20699. */
  20700. getTimeStep(): number;
  20701. /**
  20702. * Release all resources
  20703. */
  20704. dispose(): void;
  20705. /**
  20706. * Gets the name of the current physics plugin
  20707. * @returns the name of the plugin
  20708. */
  20709. getPhysicsPluginName(): string;
  20710. /**
  20711. * Adding a new impostor for the impostor tracking.
  20712. * This will be done by the impostor itself.
  20713. * @param impostor the impostor to add
  20714. */
  20715. addImpostor(impostor: PhysicsImpostor): void;
  20716. /**
  20717. * Remove an impostor from the engine.
  20718. * This impostor and its mesh will not longer be updated by the physics engine.
  20719. * @param impostor the impostor to remove
  20720. */
  20721. removeImpostor(impostor: PhysicsImpostor): void;
  20722. /**
  20723. * Add a joint to the physics engine
  20724. * @param mainImpostor defines the main impostor to which the joint is added.
  20725. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20726. * @param joint defines the joint that will connect both impostors.
  20727. */
  20728. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20729. /**
  20730. * Removes a joint from the simulation
  20731. * @param mainImpostor defines the impostor used with the joint
  20732. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20733. * @param joint defines the joint to remove
  20734. */
  20735. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20736. /**
  20737. * Gets the current plugin used to run the simulation
  20738. * @returns current plugin
  20739. */
  20740. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20741. /**
  20742. * Gets the list of physic impostors
  20743. * @returns an array of PhysicsImpostor
  20744. */
  20745. getImpostors(): Array<PhysicsImpostor>;
  20746. /**
  20747. * Gets the impostor for a physics enabled object
  20748. * @param object defines the object impersonated by the impostor
  20749. * @returns the PhysicsImpostor or null if not found
  20750. */
  20751. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20752. /**
  20753. * Gets the impostor for a physics body object
  20754. * @param body defines physics body used by the impostor
  20755. * @returns the PhysicsImpostor or null if not found
  20756. */
  20757. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20758. /**
  20759. * Does a raycast in the physics world
  20760. * @param from when should the ray start?
  20761. * @param to when should the ray end?
  20762. * @returns PhysicsRaycastResult
  20763. */
  20764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20765. /**
  20766. * Called by the scene. No need to call it.
  20767. * @param delta defines the timespam between frames
  20768. */
  20769. _step(delta: number): void;
  20770. }
  20771. }
  20772. declare module "babylonjs/Physics/physicsImpostor" {
  20773. import { Nullable, IndicesArray } from "babylonjs/types";
  20774. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20775. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20777. import { Scene } from "babylonjs/scene";
  20778. import { Bone } from "babylonjs/Bones/bone";
  20779. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20780. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20781. /**
  20782. * The interface for the physics imposter parameters
  20783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20784. */
  20785. export interface PhysicsImpostorParameters {
  20786. /**
  20787. * The mass of the physics imposter
  20788. */
  20789. mass: number;
  20790. /**
  20791. * The friction of the physics imposter
  20792. */
  20793. friction?: number;
  20794. /**
  20795. * The coefficient of restitution of the physics imposter
  20796. */
  20797. restitution?: number;
  20798. /**
  20799. * The native options of the physics imposter
  20800. */
  20801. nativeOptions?: any;
  20802. /**
  20803. * Specifies if the parent should be ignored
  20804. */
  20805. ignoreParent?: boolean;
  20806. /**
  20807. * Specifies if bi-directional transformations should be disabled
  20808. */
  20809. disableBidirectionalTransformation?: boolean;
  20810. /**
  20811. * The pressure inside the physics imposter, soft object only
  20812. */
  20813. pressure?: number;
  20814. /**
  20815. * The stiffness the physics imposter, soft object only
  20816. */
  20817. stiffness?: number;
  20818. /**
  20819. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20820. */
  20821. velocityIterations?: number;
  20822. /**
  20823. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20824. */
  20825. positionIterations?: number;
  20826. /**
  20827. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20828. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20829. * Add to fix multiple points
  20830. */
  20831. fixedPoints?: number;
  20832. /**
  20833. * The collision margin around a soft object
  20834. */
  20835. margin?: number;
  20836. /**
  20837. * The collision margin around a soft object
  20838. */
  20839. damping?: number;
  20840. /**
  20841. * The path for a rope based on an extrusion
  20842. */
  20843. path?: any;
  20844. /**
  20845. * The shape of an extrusion used for a rope based on an extrusion
  20846. */
  20847. shape?: any;
  20848. }
  20849. /**
  20850. * Interface for a physics-enabled object
  20851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20852. */
  20853. export interface IPhysicsEnabledObject {
  20854. /**
  20855. * The position of the physics-enabled object
  20856. */
  20857. position: Vector3;
  20858. /**
  20859. * The rotation of the physics-enabled object
  20860. */
  20861. rotationQuaternion: Nullable<Quaternion>;
  20862. /**
  20863. * The scale of the physics-enabled object
  20864. */
  20865. scaling: Vector3;
  20866. /**
  20867. * The rotation of the physics-enabled object
  20868. */
  20869. rotation?: Vector3;
  20870. /**
  20871. * The parent of the physics-enabled object
  20872. */
  20873. parent?: any;
  20874. /**
  20875. * The bounding info of the physics-enabled object
  20876. * @returns The bounding info of the physics-enabled object
  20877. */
  20878. getBoundingInfo(): BoundingInfo;
  20879. /**
  20880. * Computes the world matrix
  20881. * @param force Specifies if the world matrix should be computed by force
  20882. * @returns A world matrix
  20883. */
  20884. computeWorldMatrix(force: boolean): Matrix;
  20885. /**
  20886. * Gets the world matrix
  20887. * @returns A world matrix
  20888. */
  20889. getWorldMatrix?(): Matrix;
  20890. /**
  20891. * Gets the child meshes
  20892. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20893. * @returns An array of abstract meshes
  20894. */
  20895. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20896. /**
  20897. * Gets the vertex data
  20898. * @param kind The type of vertex data
  20899. * @returns A nullable array of numbers, or a float32 array
  20900. */
  20901. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20902. /**
  20903. * Gets the indices from the mesh
  20904. * @returns A nullable array of index arrays
  20905. */
  20906. getIndices?(): Nullable<IndicesArray>;
  20907. /**
  20908. * Gets the scene from the mesh
  20909. * @returns the indices array or null
  20910. */
  20911. getScene?(): Scene;
  20912. /**
  20913. * Gets the absolute position from the mesh
  20914. * @returns the absolute position
  20915. */
  20916. getAbsolutePosition(): Vector3;
  20917. /**
  20918. * Gets the absolute pivot point from the mesh
  20919. * @returns the absolute pivot point
  20920. */
  20921. getAbsolutePivotPoint(): Vector3;
  20922. /**
  20923. * Rotates the mesh
  20924. * @param axis The axis of rotation
  20925. * @param amount The amount of rotation
  20926. * @param space The space of the rotation
  20927. * @returns The rotation transform node
  20928. */
  20929. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20930. /**
  20931. * Translates the mesh
  20932. * @param axis The axis of translation
  20933. * @param distance The distance of translation
  20934. * @param space The space of the translation
  20935. * @returns The transform node
  20936. */
  20937. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20938. /**
  20939. * Sets the absolute position of the mesh
  20940. * @param absolutePosition The absolute position of the mesh
  20941. * @returns The transform node
  20942. */
  20943. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20944. /**
  20945. * Gets the class name of the mesh
  20946. * @returns The class name
  20947. */
  20948. getClassName(): string;
  20949. }
  20950. /**
  20951. * Represents a physics imposter
  20952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20953. */
  20954. export class PhysicsImpostor {
  20955. /**
  20956. * The physics-enabled object used as the physics imposter
  20957. */
  20958. object: IPhysicsEnabledObject;
  20959. /**
  20960. * The type of the physics imposter
  20961. */
  20962. type: number;
  20963. private _options;
  20964. private _scene?;
  20965. /**
  20966. * The default object size of the imposter
  20967. */
  20968. static DEFAULT_OBJECT_SIZE: Vector3;
  20969. /**
  20970. * The identity quaternion of the imposter
  20971. */
  20972. static IDENTITY_QUATERNION: Quaternion;
  20973. /** @hidden */
  20974. _pluginData: any;
  20975. private _physicsEngine;
  20976. private _physicsBody;
  20977. private _bodyUpdateRequired;
  20978. private _onBeforePhysicsStepCallbacks;
  20979. private _onAfterPhysicsStepCallbacks;
  20980. /** @hidden */
  20981. _onPhysicsCollideCallbacks: Array<{
  20982. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20983. otherImpostors: Array<PhysicsImpostor>;
  20984. }>;
  20985. private _deltaPosition;
  20986. private _deltaRotation;
  20987. private _deltaRotationConjugated;
  20988. /** hidden */
  20989. _isFromLine: boolean;
  20990. private _parent;
  20991. private _isDisposed;
  20992. private static _tmpVecs;
  20993. private static _tmpQuat;
  20994. /**
  20995. * Specifies if the physics imposter is disposed
  20996. */
  20997. readonly isDisposed: boolean;
  20998. /**
  20999. * Gets the mass of the physics imposter
  21000. */
  21001. mass: number;
  21002. /**
  21003. * Gets the coefficient of friction
  21004. */
  21005. /**
  21006. * Sets the coefficient of friction
  21007. */
  21008. friction: number;
  21009. /**
  21010. * Gets the coefficient of restitution
  21011. */
  21012. /**
  21013. * Sets the coefficient of restitution
  21014. */
  21015. restitution: number;
  21016. /**
  21017. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21018. */
  21019. /**
  21020. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21021. */
  21022. pressure: number;
  21023. /**
  21024. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21025. */
  21026. /**
  21027. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21028. */
  21029. stiffness: number;
  21030. /**
  21031. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21032. */
  21033. /**
  21034. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21035. */
  21036. velocityIterations: number;
  21037. /**
  21038. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21039. */
  21040. /**
  21041. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21042. */
  21043. positionIterations: number;
  21044. /**
  21045. * The unique id of the physics imposter
  21046. * set by the physics engine when adding this impostor to the array
  21047. */
  21048. uniqueId: number;
  21049. /**
  21050. * @hidden
  21051. */
  21052. soft: boolean;
  21053. /**
  21054. * @hidden
  21055. */
  21056. segments: number;
  21057. private _joints;
  21058. /**
  21059. * Initializes the physics imposter
  21060. * @param object The physics-enabled object used as the physics imposter
  21061. * @param type The type of the physics imposter
  21062. * @param _options The options for the physics imposter
  21063. * @param _scene The Babylon scene
  21064. */
  21065. constructor(
  21066. /**
  21067. * The physics-enabled object used as the physics imposter
  21068. */
  21069. object: IPhysicsEnabledObject,
  21070. /**
  21071. * The type of the physics imposter
  21072. */
  21073. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21074. /**
  21075. * This function will completly initialize this impostor.
  21076. * It will create a new body - but only if this mesh has no parent.
  21077. * If it has, this impostor will not be used other than to define the impostor
  21078. * of the child mesh.
  21079. * @hidden
  21080. */
  21081. _init(): void;
  21082. private _getPhysicsParent;
  21083. /**
  21084. * Should a new body be generated.
  21085. * @returns boolean specifying if body initialization is required
  21086. */
  21087. isBodyInitRequired(): boolean;
  21088. /**
  21089. * Sets the updated scaling
  21090. * @param updated Specifies if the scaling is updated
  21091. */
  21092. setScalingUpdated(): void;
  21093. /**
  21094. * Force a regeneration of this or the parent's impostor's body.
  21095. * Use under cautious - This will remove all joints already implemented.
  21096. */
  21097. forceUpdate(): void;
  21098. /**
  21099. * Gets the body that holds this impostor. Either its own, or its parent.
  21100. */
  21101. /**
  21102. * Set the physics body. Used mainly by the physics engine/plugin
  21103. */
  21104. physicsBody: any;
  21105. /**
  21106. * Get the parent of the physics imposter
  21107. * @returns Physics imposter or null
  21108. */
  21109. /**
  21110. * Sets the parent of the physics imposter
  21111. */
  21112. parent: Nullable<PhysicsImpostor>;
  21113. /**
  21114. * Resets the update flags
  21115. */
  21116. resetUpdateFlags(): void;
  21117. /**
  21118. * Gets the object extend size
  21119. * @returns the object extend size
  21120. */
  21121. getObjectExtendSize(): Vector3;
  21122. /**
  21123. * Gets the object center
  21124. * @returns The object center
  21125. */
  21126. getObjectCenter(): Vector3;
  21127. /**
  21128. * Get a specific parametes from the options parameter
  21129. * @param paramName The object parameter name
  21130. * @returns The object parameter
  21131. */
  21132. getParam(paramName: string): any;
  21133. /**
  21134. * Sets a specific parameter in the options given to the physics plugin
  21135. * @param paramName The parameter name
  21136. * @param value The value of the parameter
  21137. */
  21138. setParam(paramName: string, value: number): void;
  21139. /**
  21140. * Specifically change the body's mass option. Won't recreate the physics body object
  21141. * @param mass The mass of the physics imposter
  21142. */
  21143. setMass(mass: number): void;
  21144. /**
  21145. * Gets the linear velocity
  21146. * @returns linear velocity or null
  21147. */
  21148. getLinearVelocity(): Nullable<Vector3>;
  21149. /**
  21150. * Sets the linear velocity
  21151. * @param velocity linear velocity or null
  21152. */
  21153. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21154. /**
  21155. * Gets the angular velocity
  21156. * @returns angular velocity or null
  21157. */
  21158. getAngularVelocity(): Nullable<Vector3>;
  21159. /**
  21160. * Sets the angular velocity
  21161. * @param velocity The velocity or null
  21162. */
  21163. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21164. /**
  21165. * Execute a function with the physics plugin native code
  21166. * Provide a function the will have two variables - the world object and the physics body object
  21167. * @param func The function to execute with the physics plugin native code
  21168. */
  21169. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21170. /**
  21171. * Register a function that will be executed before the physics world is stepping forward
  21172. * @param func The function to execute before the physics world is stepped forward
  21173. */
  21174. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21175. /**
  21176. * Unregister a function that will be executed before the physics world is stepping forward
  21177. * @param func The function to execute before the physics world is stepped forward
  21178. */
  21179. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21180. /**
  21181. * Register a function that will be executed after the physics step
  21182. * @param func The function to execute after physics step
  21183. */
  21184. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21185. /**
  21186. * Unregisters a function that will be executed after the physics step
  21187. * @param func The function to execute after physics step
  21188. */
  21189. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21190. /**
  21191. * register a function that will be executed when this impostor collides against a different body
  21192. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21193. * @param func Callback that is executed on collision
  21194. */
  21195. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21196. /**
  21197. * Unregisters the physics imposter on contact
  21198. * @param collideAgainst The physics object to collide against
  21199. * @param func Callback to execute on collision
  21200. */
  21201. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21202. private _tmpQuat;
  21203. private _tmpQuat2;
  21204. /**
  21205. * Get the parent rotation
  21206. * @returns The parent rotation
  21207. */
  21208. getParentsRotation(): Quaternion;
  21209. /**
  21210. * this function is executed by the physics engine.
  21211. */
  21212. beforeStep: () => void;
  21213. /**
  21214. * this function is executed by the physics engine
  21215. */
  21216. afterStep: () => void;
  21217. /**
  21218. * Legacy collision detection event support
  21219. */
  21220. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21221. /**
  21222. * event and body object due to cannon's event-based architecture.
  21223. */
  21224. onCollide: (e: {
  21225. body: any;
  21226. }) => void;
  21227. /**
  21228. * Apply a force
  21229. * @param force The force to apply
  21230. * @param contactPoint The contact point for the force
  21231. * @returns The physics imposter
  21232. */
  21233. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21234. /**
  21235. * Apply an impulse
  21236. * @param force The impulse force
  21237. * @param contactPoint The contact point for the impulse force
  21238. * @returns The physics imposter
  21239. */
  21240. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21241. /**
  21242. * A help function to create a joint
  21243. * @param otherImpostor A physics imposter used to create a joint
  21244. * @param jointType The type of joint
  21245. * @param jointData The data for the joint
  21246. * @returns The physics imposter
  21247. */
  21248. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21249. /**
  21250. * Add a joint to this impostor with a different impostor
  21251. * @param otherImpostor A physics imposter used to add a joint
  21252. * @param joint The joint to add
  21253. * @returns The physics imposter
  21254. */
  21255. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21256. /**
  21257. * Add an anchor to a cloth impostor
  21258. * @param otherImpostor rigid impostor to anchor to
  21259. * @param width ratio across width from 0 to 1
  21260. * @param height ratio up height from 0 to 1
  21261. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21262. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21263. * @returns impostor the soft imposter
  21264. */
  21265. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21266. /**
  21267. * Add a hook to a rope impostor
  21268. * @param otherImpostor rigid impostor to anchor to
  21269. * @param length ratio across rope from 0 to 1
  21270. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21271. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21272. * @returns impostor the rope imposter
  21273. */
  21274. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21275. /**
  21276. * Will keep this body still, in a sleep mode.
  21277. * @returns the physics imposter
  21278. */
  21279. sleep(): PhysicsImpostor;
  21280. /**
  21281. * Wake the body up.
  21282. * @returns The physics imposter
  21283. */
  21284. wakeUp(): PhysicsImpostor;
  21285. /**
  21286. * Clones the physics imposter
  21287. * @param newObject The physics imposter clones to this physics-enabled object
  21288. * @returns A nullable physics imposter
  21289. */
  21290. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21291. /**
  21292. * Disposes the physics imposter
  21293. */
  21294. dispose(): void;
  21295. /**
  21296. * Sets the delta position
  21297. * @param position The delta position amount
  21298. */
  21299. setDeltaPosition(position: Vector3): void;
  21300. /**
  21301. * Sets the delta rotation
  21302. * @param rotation The delta rotation amount
  21303. */
  21304. setDeltaRotation(rotation: Quaternion): void;
  21305. /**
  21306. * Gets the box size of the physics imposter and stores the result in the input parameter
  21307. * @param result Stores the box size
  21308. * @returns The physics imposter
  21309. */
  21310. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21311. /**
  21312. * Gets the radius of the physics imposter
  21313. * @returns Radius of the physics imposter
  21314. */
  21315. getRadius(): number;
  21316. /**
  21317. * Sync a bone with this impostor
  21318. * @param bone The bone to sync to the impostor.
  21319. * @param boneMesh The mesh that the bone is influencing.
  21320. * @param jointPivot The pivot of the joint / bone in local space.
  21321. * @param distToJoint Optional distance from the impostor to the joint.
  21322. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21323. */
  21324. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21325. /**
  21326. * Sync impostor to a bone
  21327. * @param bone The bone that the impostor will be synced to.
  21328. * @param boneMesh The mesh that the bone is influencing.
  21329. * @param jointPivot The pivot of the joint / bone in local space.
  21330. * @param distToJoint Optional distance from the impostor to the joint.
  21331. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21332. * @param boneAxis Optional vector3 axis the bone is aligned with
  21333. */
  21334. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21335. /**
  21336. * No-Imposter type
  21337. */
  21338. static NoImpostor: number;
  21339. /**
  21340. * Sphere-Imposter type
  21341. */
  21342. static SphereImpostor: number;
  21343. /**
  21344. * Box-Imposter type
  21345. */
  21346. static BoxImpostor: number;
  21347. /**
  21348. * Plane-Imposter type
  21349. */
  21350. static PlaneImpostor: number;
  21351. /**
  21352. * Mesh-imposter type
  21353. */
  21354. static MeshImpostor: number;
  21355. /**
  21356. * Cylinder-Imposter type
  21357. */
  21358. static CylinderImpostor: number;
  21359. /**
  21360. * Particle-Imposter type
  21361. */
  21362. static ParticleImpostor: number;
  21363. /**
  21364. * Heightmap-Imposter type
  21365. */
  21366. static HeightmapImpostor: number;
  21367. /**
  21368. * ConvexHull-Impostor type (Ammo.js plugin only)
  21369. */
  21370. static ConvexHullImpostor: number;
  21371. /**
  21372. * Rope-Imposter type
  21373. */
  21374. static RopeImpostor: number;
  21375. /**
  21376. * Cloth-Imposter type
  21377. */
  21378. static ClothImpostor: number;
  21379. /**
  21380. * Softbody-Imposter type
  21381. */
  21382. static SoftbodyImpostor: number;
  21383. }
  21384. }
  21385. declare module "babylonjs/Meshes/mesh" {
  21386. import { Observable } from "babylonjs/Misc/observable";
  21387. import { IAnimatable } from "babylonjs/Misc/tools";
  21388. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21389. import { Camera } from "babylonjs/Cameras/camera";
  21390. import { Scene } from "babylonjs/scene";
  21391. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21392. import { Engine } from "babylonjs/Engines/engine";
  21393. import { Node } from "babylonjs/node";
  21394. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21395. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21396. import { Buffer } from "babylonjs/Meshes/buffer";
  21397. import { Geometry } from "babylonjs/Meshes/geometry";
  21398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21400. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21401. import { Effect } from "babylonjs/Materials/effect";
  21402. import { Material } from "babylonjs/Materials/material";
  21403. import { Skeleton } from "babylonjs/Bones/skeleton";
  21404. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21405. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21406. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21407. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21408. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21409. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21410. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21411. /**
  21412. * @hidden
  21413. **/
  21414. export class _CreationDataStorage {
  21415. closePath?: boolean;
  21416. closeArray?: boolean;
  21417. idx: number[];
  21418. dashSize: number;
  21419. gapSize: number;
  21420. path3D: Path3D;
  21421. pathArray: Vector3[][];
  21422. arc: number;
  21423. radius: number;
  21424. cap: number;
  21425. tessellation: number;
  21426. }
  21427. /**
  21428. * @hidden
  21429. **/
  21430. class _InstanceDataStorage {
  21431. visibleInstances: any;
  21432. batchCache: _InstancesBatch;
  21433. instancesBufferSize: number;
  21434. instancesBuffer: Nullable<Buffer>;
  21435. instancesData: Float32Array;
  21436. overridenInstanceCount: number;
  21437. isFrozen: boolean;
  21438. previousBatch: _InstancesBatch;
  21439. hardwareInstancedRendering: boolean;
  21440. sideOrientation: number;
  21441. }
  21442. /**
  21443. * @hidden
  21444. **/
  21445. export class _InstancesBatch {
  21446. mustReturn: boolean;
  21447. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21448. renderSelf: boolean[];
  21449. hardwareInstancedRendering: boolean[];
  21450. }
  21451. /**
  21452. * Class used to represent renderable models
  21453. */
  21454. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21455. /**
  21456. * Mesh side orientation : usually the external or front surface
  21457. */
  21458. static readonly FRONTSIDE: number;
  21459. /**
  21460. * Mesh side orientation : usually the internal or back surface
  21461. */
  21462. static readonly BACKSIDE: number;
  21463. /**
  21464. * Mesh side orientation : both internal and external or front and back surfaces
  21465. */
  21466. static readonly DOUBLESIDE: number;
  21467. /**
  21468. * Mesh side orientation : by default, `FRONTSIDE`
  21469. */
  21470. static readonly DEFAULTSIDE: number;
  21471. /**
  21472. * Mesh cap setting : no cap
  21473. */
  21474. static readonly NO_CAP: number;
  21475. /**
  21476. * Mesh cap setting : one cap at the beginning of the mesh
  21477. */
  21478. static readonly CAP_START: number;
  21479. /**
  21480. * Mesh cap setting : one cap at the end of the mesh
  21481. */
  21482. static readonly CAP_END: number;
  21483. /**
  21484. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21485. */
  21486. static readonly CAP_ALL: number;
  21487. /**
  21488. * Gets the default side orientation.
  21489. * @param orientation the orientation to value to attempt to get
  21490. * @returns the default orientation
  21491. * @hidden
  21492. */
  21493. static _GetDefaultSideOrientation(orientation?: number): number;
  21494. private _internalMeshDataInfo;
  21495. /**
  21496. * An event triggered before rendering the mesh
  21497. */
  21498. readonly onBeforeRenderObservable: Observable<Mesh>;
  21499. /**
  21500. * An event triggered before binding the mesh
  21501. */
  21502. readonly onBeforeBindObservable: Observable<Mesh>;
  21503. /**
  21504. * An event triggered after rendering the mesh
  21505. */
  21506. readonly onAfterRenderObservable: Observable<Mesh>;
  21507. /**
  21508. * An event triggered before drawing the mesh
  21509. */
  21510. readonly onBeforeDrawObservable: Observable<Mesh>;
  21511. private _onBeforeDrawObserver;
  21512. /**
  21513. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21514. */
  21515. onBeforeDraw: () => void;
  21516. /**
  21517. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21518. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21519. */
  21520. delayLoadState: number;
  21521. /**
  21522. * Gets the list of instances created from this mesh
  21523. * it is not supposed to be modified manually.
  21524. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21525. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21526. */
  21527. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21528. /**
  21529. * Gets the file containing delay loading data for this mesh
  21530. */
  21531. delayLoadingFile: string;
  21532. /** @hidden */
  21533. _binaryInfo: any;
  21534. /**
  21535. * User defined function used to change how LOD level selection is done
  21536. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21537. */
  21538. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21539. /**
  21540. * Gets or sets the morph target manager
  21541. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21542. */
  21543. morphTargetManager: Nullable<MorphTargetManager>;
  21544. /** @hidden */
  21545. _creationDataStorage: Nullable<_CreationDataStorage>;
  21546. /** @hidden */
  21547. _geometry: Nullable<Geometry>;
  21548. /** @hidden */
  21549. _delayInfo: Array<string>;
  21550. /** @hidden */
  21551. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21552. /** @hidden */
  21553. _instanceDataStorage: _InstanceDataStorage;
  21554. private _effectiveMaterial;
  21555. /** @hidden */
  21556. _shouldGenerateFlatShading: boolean;
  21557. /** @hidden */
  21558. _originalBuilderSideOrientation: number;
  21559. /**
  21560. * Use this property to change the original side orientation defined at construction time
  21561. */
  21562. overrideMaterialSideOrientation: Nullable<number>;
  21563. /**
  21564. * Gets the source mesh (the one used to clone this one from)
  21565. */
  21566. readonly source: Nullable<Mesh>;
  21567. /**
  21568. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21569. */
  21570. isUnIndexed: boolean;
  21571. /**
  21572. * @constructor
  21573. * @param name The value used by scene.getMeshByName() to do a lookup.
  21574. * @param scene The scene to add this mesh to.
  21575. * @param parent The parent of this mesh, if it has one
  21576. * @param source An optional Mesh from which geometry is shared, cloned.
  21577. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21578. * When false, achieved by calling a clone(), also passing False.
  21579. * This will make creation of children, recursive.
  21580. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21581. */
  21582. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21583. /**
  21584. * Gets the class name
  21585. * @returns the string "Mesh".
  21586. */
  21587. getClassName(): string;
  21588. /** @hidden */
  21589. readonly _isMesh: boolean;
  21590. /**
  21591. * Returns a description of this mesh
  21592. * @param fullDetails define if full details about this mesh must be used
  21593. * @returns a descriptive string representing this mesh
  21594. */
  21595. toString(fullDetails?: boolean): string;
  21596. /** @hidden */
  21597. _unBindEffect(): void;
  21598. /**
  21599. * Gets a boolean indicating if this mesh has LOD
  21600. */
  21601. readonly hasLODLevels: boolean;
  21602. /**
  21603. * Gets the list of MeshLODLevel associated with the current mesh
  21604. * @returns an array of MeshLODLevel
  21605. */
  21606. getLODLevels(): MeshLODLevel[];
  21607. private _sortLODLevels;
  21608. /**
  21609. * Add a mesh as LOD level triggered at the given distance.
  21610. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21611. * @param distance The distance from the center of the object to show this level
  21612. * @param mesh The mesh to be added as LOD level (can be null)
  21613. * @return This mesh (for chaining)
  21614. */
  21615. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21616. /**
  21617. * Returns the LOD level mesh at the passed distance or null if not found.
  21618. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21619. * @param distance The distance from the center of the object to show this level
  21620. * @returns a Mesh or `null`
  21621. */
  21622. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21623. /**
  21624. * Remove a mesh from the LOD array
  21625. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21626. * @param mesh defines the mesh to be removed
  21627. * @return This mesh (for chaining)
  21628. */
  21629. removeLODLevel(mesh: Mesh): Mesh;
  21630. /**
  21631. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21632. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21633. * @param camera defines the camera to use to compute distance
  21634. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21635. * @return This mesh (for chaining)
  21636. */
  21637. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21638. /**
  21639. * Gets the mesh internal Geometry object
  21640. */
  21641. readonly geometry: Nullable<Geometry>;
  21642. /**
  21643. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21644. * @returns the total number of vertices
  21645. */
  21646. getTotalVertices(): number;
  21647. /**
  21648. * Returns the content of an associated vertex buffer
  21649. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21650. * - VertexBuffer.PositionKind
  21651. * - VertexBuffer.UVKind
  21652. * - VertexBuffer.UV2Kind
  21653. * - VertexBuffer.UV3Kind
  21654. * - VertexBuffer.UV4Kind
  21655. * - VertexBuffer.UV5Kind
  21656. * - VertexBuffer.UV6Kind
  21657. * - VertexBuffer.ColorKind
  21658. * - VertexBuffer.MatricesIndicesKind
  21659. * - VertexBuffer.MatricesIndicesExtraKind
  21660. * - VertexBuffer.MatricesWeightsKind
  21661. * - VertexBuffer.MatricesWeightsExtraKind
  21662. * @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
  21663. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21664. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21665. */
  21666. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21667. /**
  21668. * Returns the mesh VertexBuffer object from the requested `kind`
  21669. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21670. * - VertexBuffer.PositionKind
  21671. * - VertexBuffer.UVKind
  21672. * - VertexBuffer.UV2Kind
  21673. * - VertexBuffer.UV3Kind
  21674. * - VertexBuffer.UV4Kind
  21675. * - VertexBuffer.UV5Kind
  21676. * - VertexBuffer.UV6Kind
  21677. * - VertexBuffer.ColorKind
  21678. * - VertexBuffer.MatricesIndicesKind
  21679. * - VertexBuffer.MatricesIndicesExtraKind
  21680. * - VertexBuffer.MatricesWeightsKind
  21681. * - VertexBuffer.MatricesWeightsExtraKind
  21682. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21683. */
  21684. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21685. /**
  21686. * Tests if a specific vertex buffer is associated with this mesh
  21687. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21688. * - VertexBuffer.PositionKind
  21689. * - VertexBuffer.UVKind
  21690. * - VertexBuffer.UV2Kind
  21691. * - VertexBuffer.UV3Kind
  21692. * - VertexBuffer.UV4Kind
  21693. * - VertexBuffer.UV5Kind
  21694. * - VertexBuffer.UV6Kind
  21695. * - VertexBuffer.ColorKind
  21696. * - VertexBuffer.MatricesIndicesKind
  21697. * - VertexBuffer.MatricesIndicesExtraKind
  21698. * - VertexBuffer.MatricesWeightsKind
  21699. * - VertexBuffer.MatricesWeightsExtraKind
  21700. * @returns a boolean
  21701. */
  21702. isVerticesDataPresent(kind: string): boolean;
  21703. /**
  21704. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21705. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21706. * - VertexBuffer.PositionKind
  21707. * - VertexBuffer.UVKind
  21708. * - VertexBuffer.UV2Kind
  21709. * - VertexBuffer.UV3Kind
  21710. * - VertexBuffer.UV4Kind
  21711. * - VertexBuffer.UV5Kind
  21712. * - VertexBuffer.UV6Kind
  21713. * - VertexBuffer.ColorKind
  21714. * - VertexBuffer.MatricesIndicesKind
  21715. * - VertexBuffer.MatricesIndicesExtraKind
  21716. * - VertexBuffer.MatricesWeightsKind
  21717. * - VertexBuffer.MatricesWeightsExtraKind
  21718. * @returns a boolean
  21719. */
  21720. isVertexBufferUpdatable(kind: string): boolean;
  21721. /**
  21722. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21723. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21724. * - VertexBuffer.PositionKind
  21725. * - VertexBuffer.UVKind
  21726. * - VertexBuffer.UV2Kind
  21727. * - VertexBuffer.UV3Kind
  21728. * - VertexBuffer.UV4Kind
  21729. * - VertexBuffer.UV5Kind
  21730. * - VertexBuffer.UV6Kind
  21731. * - VertexBuffer.ColorKind
  21732. * - VertexBuffer.MatricesIndicesKind
  21733. * - VertexBuffer.MatricesIndicesExtraKind
  21734. * - VertexBuffer.MatricesWeightsKind
  21735. * - VertexBuffer.MatricesWeightsExtraKind
  21736. * @returns an array of strings
  21737. */
  21738. getVerticesDataKinds(): string[];
  21739. /**
  21740. * Returns a positive integer : the total number of indices in this mesh geometry.
  21741. * @returns the numner of indices or zero if the mesh has no geometry.
  21742. */
  21743. getTotalIndices(): number;
  21744. /**
  21745. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21746. * @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.
  21747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21748. * @returns the indices array or an empty array if the mesh has no geometry
  21749. */
  21750. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21751. readonly isBlocked: boolean;
  21752. /**
  21753. * Determine if the current mesh is ready to be rendered
  21754. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21755. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21756. * @returns true if all associated assets are ready (material, textures, shaders)
  21757. */
  21758. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21759. /**
  21760. * 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.
  21761. */
  21762. readonly areNormalsFrozen: boolean;
  21763. /**
  21764. * 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.
  21765. * @returns the current mesh
  21766. */
  21767. freezeNormals(): Mesh;
  21768. /**
  21769. * 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
  21770. * @returns the current mesh
  21771. */
  21772. unfreezeNormals(): Mesh;
  21773. /**
  21774. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21775. */
  21776. overridenInstanceCount: number;
  21777. /** @hidden */
  21778. _preActivate(): Mesh;
  21779. /** @hidden */
  21780. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21781. /** @hidden */
  21782. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21783. /**
  21784. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21785. * This means the mesh underlying bounding box and sphere are recomputed.
  21786. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21787. * @returns the current mesh
  21788. */
  21789. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21790. /** @hidden */
  21791. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21792. /**
  21793. * This function will subdivide the mesh into multiple submeshes
  21794. * @param count defines the expected number of submeshes
  21795. */
  21796. subdivide(count: number): void;
  21797. /**
  21798. * Copy a FloatArray into a specific associated vertex buffer
  21799. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21800. * - VertexBuffer.PositionKind
  21801. * - VertexBuffer.UVKind
  21802. * - VertexBuffer.UV2Kind
  21803. * - VertexBuffer.UV3Kind
  21804. * - VertexBuffer.UV4Kind
  21805. * - VertexBuffer.UV5Kind
  21806. * - VertexBuffer.UV6Kind
  21807. * - VertexBuffer.ColorKind
  21808. * - VertexBuffer.MatricesIndicesKind
  21809. * - VertexBuffer.MatricesIndicesExtraKind
  21810. * - VertexBuffer.MatricesWeightsKind
  21811. * - VertexBuffer.MatricesWeightsExtraKind
  21812. * @param data defines the data source
  21813. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21814. * @param stride defines the data stride size (can be null)
  21815. * @returns the current mesh
  21816. */
  21817. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21818. /**
  21819. * Flags an associated vertex buffer as updatable
  21820. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21821. * - VertexBuffer.PositionKind
  21822. * - VertexBuffer.UVKind
  21823. * - VertexBuffer.UV2Kind
  21824. * - VertexBuffer.UV3Kind
  21825. * - VertexBuffer.UV4Kind
  21826. * - VertexBuffer.UV5Kind
  21827. * - VertexBuffer.UV6Kind
  21828. * - VertexBuffer.ColorKind
  21829. * - VertexBuffer.MatricesIndicesKind
  21830. * - VertexBuffer.MatricesIndicesExtraKind
  21831. * - VertexBuffer.MatricesWeightsKind
  21832. * - VertexBuffer.MatricesWeightsExtraKind
  21833. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21834. */
  21835. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21836. /**
  21837. * Sets the mesh global Vertex Buffer
  21838. * @param buffer defines the buffer to use
  21839. * @returns the current mesh
  21840. */
  21841. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21842. /**
  21843. * Update a specific associated vertex buffer
  21844. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21845. * - VertexBuffer.PositionKind
  21846. * - VertexBuffer.UVKind
  21847. * - VertexBuffer.UV2Kind
  21848. * - VertexBuffer.UV3Kind
  21849. * - VertexBuffer.UV4Kind
  21850. * - VertexBuffer.UV5Kind
  21851. * - VertexBuffer.UV6Kind
  21852. * - VertexBuffer.ColorKind
  21853. * - VertexBuffer.MatricesIndicesKind
  21854. * - VertexBuffer.MatricesIndicesExtraKind
  21855. * - VertexBuffer.MatricesWeightsKind
  21856. * - VertexBuffer.MatricesWeightsExtraKind
  21857. * @param data defines the data source
  21858. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21859. * @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)
  21860. * @returns the current mesh
  21861. */
  21862. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21863. /**
  21864. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21865. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21866. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21867. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21868. * @returns the current mesh
  21869. */
  21870. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21871. /**
  21872. * Creates a un-shared specific occurence of the geometry for the mesh.
  21873. * @returns the current mesh
  21874. */
  21875. makeGeometryUnique(): Mesh;
  21876. /**
  21877. * Set the index buffer of this mesh
  21878. * @param indices defines the source data
  21879. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21880. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21881. * @returns the current mesh
  21882. */
  21883. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21884. /**
  21885. * Update the current index buffer
  21886. * @param indices defines the source data
  21887. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21888. * @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)
  21889. * @returns the current mesh
  21890. */
  21891. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21892. /**
  21893. * Invert the geometry to move from a right handed system to a left handed one.
  21894. * @returns the current mesh
  21895. */
  21896. toLeftHanded(): Mesh;
  21897. /** @hidden */
  21898. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21899. /** @hidden */
  21900. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21901. /**
  21902. * Registers for this mesh a javascript function called just before the rendering process
  21903. * @param func defines the function to call before rendering this mesh
  21904. * @returns the current mesh
  21905. */
  21906. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21907. /**
  21908. * Disposes a previously registered javascript function called before the rendering
  21909. * @param func defines the function to remove
  21910. * @returns the current mesh
  21911. */
  21912. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21913. /**
  21914. * Registers for this mesh a javascript function called just after the rendering is complete
  21915. * @param func defines the function to call after rendering this mesh
  21916. * @returns the current mesh
  21917. */
  21918. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21919. /**
  21920. * Disposes a previously registered javascript function called after the rendering.
  21921. * @param func defines the function to remove
  21922. * @returns the current mesh
  21923. */
  21924. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21925. /** @hidden */
  21926. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21927. /** @hidden */
  21928. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21929. /** @hidden */
  21930. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21931. /** @hidden */
  21932. _freeze(): void;
  21933. /** @hidden */
  21934. _unFreeze(): void;
  21935. /**
  21936. * 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
  21937. * @param subMesh defines the subMesh to render
  21938. * @param enableAlphaMode defines if alpha mode can be changed
  21939. * @returns the current mesh
  21940. */
  21941. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21942. private _onBeforeDraw;
  21943. /**
  21944. * Renormalize the mesh and patch it up if there are no weights
  21945. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21946. * However in the case of zero weights then we set just a single influence to 1.
  21947. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21948. */
  21949. cleanMatrixWeights(): void;
  21950. private normalizeSkinFourWeights;
  21951. private normalizeSkinWeightsAndExtra;
  21952. /**
  21953. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21954. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21955. * the user know there was an issue with importing the mesh
  21956. * @returns a validation object with skinned, valid and report string
  21957. */
  21958. validateSkinning(): {
  21959. skinned: boolean;
  21960. valid: boolean;
  21961. report: string;
  21962. };
  21963. /** @hidden */
  21964. _checkDelayState(): Mesh;
  21965. private _queueLoad;
  21966. /**
  21967. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21968. * A mesh is in the frustum if its bounding box intersects the frustum
  21969. * @param frustumPlanes defines the frustum to test
  21970. * @returns true if the mesh is in the frustum planes
  21971. */
  21972. isInFrustum(frustumPlanes: Plane[]): boolean;
  21973. /**
  21974. * Sets the mesh material by the material or multiMaterial `id` property
  21975. * @param id is a string identifying the material or the multiMaterial
  21976. * @returns the current mesh
  21977. */
  21978. setMaterialByID(id: string): Mesh;
  21979. /**
  21980. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21981. * @returns an array of IAnimatable
  21982. */
  21983. getAnimatables(): IAnimatable[];
  21984. /**
  21985. * Modifies the mesh geometry according to the passed transformation matrix.
  21986. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21987. * The mesh normals are modified using the same transformation.
  21988. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21989. * @param transform defines the transform matrix to use
  21990. * @see http://doc.babylonjs.com/resources/baking_transformations
  21991. * @returns the current mesh
  21992. */
  21993. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21994. /**
  21995. * Modifies the mesh geometry according to its own current World Matrix.
  21996. * The mesh World Matrix is then reset.
  21997. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21998. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21999. * @see http://doc.babylonjs.com/resources/baking_transformations
  22000. * @returns the current mesh
  22001. */
  22002. bakeCurrentTransformIntoVertices(): Mesh;
  22003. /** @hidden */
  22004. readonly _positions: Nullable<Vector3[]>;
  22005. /** @hidden */
  22006. _resetPointsArrayCache(): Mesh;
  22007. /** @hidden */
  22008. _generatePointsArray(): boolean;
  22009. /**
  22010. * Returns a new Mesh object generated from the current mesh properties.
  22011. * This method must not get confused with createInstance()
  22012. * @param name is a string, the name given to the new mesh
  22013. * @param newParent can be any Node object (default `null`)
  22014. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22015. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22016. * @returns a new mesh
  22017. */
  22018. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22019. /**
  22020. * Releases resources associated with this mesh.
  22021. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22022. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22023. */
  22024. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22025. /**
  22026. * Modifies the mesh geometry according to a displacement map.
  22027. * 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.
  22028. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22029. * @param url is a string, the URL from the image file is to be downloaded.
  22030. * @param minHeight is the lower limit of the displacement.
  22031. * @param maxHeight is the upper limit of the displacement.
  22032. * @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.
  22033. * @param uvOffset is an optional vector2 used to offset UV.
  22034. * @param uvScale is an optional vector2 used to scale UV.
  22035. * @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.
  22036. * @returns the Mesh.
  22037. */
  22038. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22039. /**
  22040. * Modifies the mesh geometry according to a displacementMap buffer.
  22041. * 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.
  22042. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22043. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22044. * @param heightMapWidth is the width of the buffer image.
  22045. * @param heightMapHeight is the height of the buffer image.
  22046. * @param minHeight is the lower limit of the displacement.
  22047. * @param maxHeight is the upper limit of the displacement.
  22048. * @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.
  22049. * @param uvOffset is an optional vector2 used to offset UV.
  22050. * @param uvScale is an optional vector2 used to scale UV.
  22051. * @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.
  22052. * @returns the Mesh.
  22053. */
  22054. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22055. /**
  22056. * Modify the mesh to get a flat shading rendering.
  22057. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22058. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22059. * @returns current mesh
  22060. */
  22061. convertToFlatShadedMesh(): Mesh;
  22062. /**
  22063. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22064. * In other words, more vertices, no more indices and a single bigger VBO.
  22065. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22066. * @returns current mesh
  22067. */
  22068. convertToUnIndexedMesh(): Mesh;
  22069. /**
  22070. * Inverses facet orientations.
  22071. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22072. * @param flipNormals will also inverts the normals
  22073. * @returns current mesh
  22074. */
  22075. flipFaces(flipNormals?: boolean): Mesh;
  22076. /**
  22077. * Increase the number of facets and hence vertices in a mesh
  22078. * Vertex normals are interpolated from existing vertex normals
  22079. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22080. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22081. */
  22082. increaseVertices(numberPerEdge: number): void;
  22083. /**
  22084. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22085. * This will undo any application of covertToFlatShadedMesh
  22086. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22087. */
  22088. forceSharedVertices(): void;
  22089. /** @hidden */
  22090. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22091. /** @hidden */
  22092. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22093. /**
  22094. * Creates a new InstancedMesh object from the mesh model.
  22095. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22096. * @param name defines the name of the new instance
  22097. * @returns a new InstancedMesh
  22098. */
  22099. createInstance(name: string): InstancedMesh;
  22100. /**
  22101. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22102. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22103. * @returns the current mesh
  22104. */
  22105. synchronizeInstances(): Mesh;
  22106. /**
  22107. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22108. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22109. * This should be used together with the simplification to avoid disappearing triangles.
  22110. * @param successCallback an optional success callback to be called after the optimization finished.
  22111. * @returns the current mesh
  22112. */
  22113. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22114. /**
  22115. * Serialize current mesh
  22116. * @param serializationObject defines the object which will receive the serialization data
  22117. */
  22118. serialize(serializationObject: any): void;
  22119. /** @hidden */
  22120. _syncGeometryWithMorphTargetManager(): void;
  22121. /** @hidden */
  22122. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22123. /**
  22124. * Returns a new Mesh object parsed from the source provided.
  22125. * @param parsedMesh is the source
  22126. * @param scene defines the hosting scene
  22127. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22128. * @returns a new Mesh
  22129. */
  22130. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22131. /**
  22132. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22133. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22134. * @param name defines the name of the mesh to create
  22135. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22136. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22137. * @param closePath creates a seam between the first and the last points of each path of the path array
  22138. * @param offset is taken in account only if the `pathArray` is containing a single path
  22139. * @param scene defines the hosting scene
  22140. * @param updatable defines if the mesh must be flagged as updatable
  22141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22142. * @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)
  22143. * @returns a new Mesh
  22144. */
  22145. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22146. /**
  22147. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22148. * @param name defines the name of the mesh to create
  22149. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22150. * @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
  22151. * @param scene defines the hosting scene
  22152. * @param updatable defines if the mesh must be flagged as updatable
  22153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22154. * @returns a new Mesh
  22155. */
  22156. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22157. /**
  22158. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22159. * @param name defines the name of the mesh to create
  22160. * @param size sets the size (float) of each box side (default 1)
  22161. * @param scene defines the hosting scene
  22162. * @param updatable defines if the mesh must be flagged as updatable
  22163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22164. * @returns a new Mesh
  22165. */
  22166. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22167. /**
  22168. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22169. * @param name defines the name of the mesh to create
  22170. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22171. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22172. * @param scene defines the hosting scene
  22173. * @param updatable defines if the mesh must be flagged as updatable
  22174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22175. * @returns a new Mesh
  22176. */
  22177. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22178. /**
  22179. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22180. * @param name defines the name of the mesh to create
  22181. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22182. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22183. * @param scene defines the hosting scene
  22184. * @returns a new Mesh
  22185. */
  22186. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22187. /**
  22188. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22189. * @param name defines the name of the mesh to create
  22190. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22191. * @param diameterTop set the top cap diameter (floats, default 1)
  22192. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22193. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22194. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22195. * @param scene defines the hosting scene
  22196. * @param updatable defines if the mesh must be flagged as updatable
  22197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22198. * @returns a new Mesh
  22199. */
  22200. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22201. /**
  22202. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22203. * @param name defines the name of the mesh to create
  22204. * @param diameter sets the diameter size (float) of the torus (default 1)
  22205. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22206. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22207. * @param scene defines the hosting scene
  22208. * @param updatable defines if the mesh must be flagged as updatable
  22209. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22210. * @returns a new Mesh
  22211. */
  22212. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22213. /**
  22214. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22215. * @param name defines the name of the mesh to create
  22216. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22217. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22218. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22219. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22220. * @param p the number of windings on X axis (positive integers, default 2)
  22221. * @param q the number of windings on Y axis (positive integers, default 3)
  22222. * @param scene defines the hosting scene
  22223. * @param updatable defines if the mesh must be flagged as updatable
  22224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22225. * @returns a new Mesh
  22226. */
  22227. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22228. /**
  22229. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22230. * @param name defines the name of the mesh to create
  22231. * @param points is an array successive Vector3
  22232. * @param scene defines the hosting scene
  22233. * @param updatable defines if the mesh must be flagged as updatable
  22234. * @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).
  22235. * @returns a new Mesh
  22236. */
  22237. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22238. /**
  22239. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22240. * @param name defines the name of the mesh to create
  22241. * @param points is an array successive Vector3
  22242. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22243. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22244. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22245. * @param scene defines the hosting scene
  22246. * @param updatable defines if the mesh must be flagged as updatable
  22247. * @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)
  22248. * @returns a new Mesh
  22249. */
  22250. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22251. /**
  22252. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22253. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22254. * 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.
  22255. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22256. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22257. * Remember you can only change the shape positions, not their number when updating a polygon.
  22258. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22259. * @param name defines the name of the mesh to create
  22260. * @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
  22261. * @param scene defines the hosting scene
  22262. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22263. * @param updatable defines if the mesh must be flagged as updatable
  22264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22265. * @param earcutInjection can be used to inject your own earcut reference
  22266. * @returns a new Mesh
  22267. */
  22268. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22269. /**
  22270. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22271. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22272. * @param name defines the name of the mesh to create
  22273. * @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
  22274. * @param depth defines the height of extrusion
  22275. * @param scene defines the hosting scene
  22276. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22277. * @param updatable defines if the mesh must be flagged as updatable
  22278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22279. * @param earcutInjection can be used to inject your own earcut reference
  22280. * @returns a new Mesh
  22281. */
  22282. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22283. /**
  22284. * Creates an extruded shape mesh.
  22285. * 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
  22286. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22287. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22288. * @param name defines the name of the mesh to create
  22289. * @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
  22290. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22291. * @param scale is the value to scale the shape
  22292. * @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
  22293. * @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
  22294. * @param scene defines the hosting scene
  22295. * @param updatable defines if the mesh must be flagged as updatable
  22296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22297. * @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)
  22298. * @returns a new Mesh
  22299. */
  22300. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22301. /**
  22302. * Creates an custom extruded shape mesh.
  22303. * The custom extrusion is a parametric shape.
  22304. * It has no predefined shape. Its final shape will depend on the input parameters.
  22305. * Please consider using the same method from the MeshBuilder class instead
  22306. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22307. * @param name defines the name of the mesh to create
  22308. * @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
  22309. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22310. * @param scaleFunction is a custom Javascript function called on each path point
  22311. * @param rotationFunction is a custom Javascript function called on each path point
  22312. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22313. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22314. * @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
  22315. * @param scene defines the hosting scene
  22316. * @param updatable defines if the mesh must be flagged as updatable
  22317. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22318. * @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)
  22319. * @returns a new Mesh
  22320. */
  22321. 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;
  22322. /**
  22323. * Creates lathe mesh.
  22324. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22325. * Please consider using the same method from the MeshBuilder class instead
  22326. * @param name defines the name of the mesh to create
  22327. * @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
  22328. * @param radius is the radius value of the lathe
  22329. * @param tessellation is the side number of the lathe.
  22330. * @param scene defines the hosting scene
  22331. * @param updatable defines if the mesh must be flagged as updatable
  22332. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22333. * @returns a new Mesh
  22334. */
  22335. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22336. /**
  22337. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22338. * @param name defines the name of the mesh to create
  22339. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22340. * @param scene defines the hosting scene
  22341. * @param updatable defines if the mesh must be flagged as updatable
  22342. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22343. * @returns a new Mesh
  22344. */
  22345. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22346. /**
  22347. * Creates a ground mesh.
  22348. * Please consider using the same method from the MeshBuilder class instead
  22349. * @param name defines the name of the mesh to create
  22350. * @param width set the width of the ground
  22351. * @param height set the height of the ground
  22352. * @param subdivisions sets the number of subdivisions per side
  22353. * @param scene defines the hosting scene
  22354. * @param updatable defines if the mesh must be flagged as updatable
  22355. * @returns a new Mesh
  22356. */
  22357. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22358. /**
  22359. * Creates a tiled ground mesh.
  22360. * Please consider using the same method from the MeshBuilder class instead
  22361. * @param name defines the name of the mesh to create
  22362. * @param xmin set the ground minimum X coordinate
  22363. * @param zmin set the ground minimum Y coordinate
  22364. * @param xmax set the ground maximum X coordinate
  22365. * @param zmax set the ground maximum Z coordinate
  22366. * @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
  22367. * @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
  22368. * @param scene defines the hosting scene
  22369. * @param updatable defines if the mesh must be flagged as updatable
  22370. * @returns a new Mesh
  22371. */
  22372. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22373. w: number;
  22374. h: number;
  22375. }, precision: {
  22376. w: number;
  22377. h: number;
  22378. }, scene: Scene, updatable?: boolean): Mesh;
  22379. /**
  22380. * Creates a ground mesh from a height map.
  22381. * Please consider using the same method from the MeshBuilder class instead
  22382. * @see http://doc.babylonjs.com/babylon101/height_map
  22383. * @param name defines the name of the mesh to create
  22384. * @param url sets the URL of the height map image resource
  22385. * @param width set the ground width size
  22386. * @param height set the ground height size
  22387. * @param subdivisions sets the number of subdivision per side
  22388. * @param minHeight is the minimum altitude on the ground
  22389. * @param maxHeight is the maximum altitude on the ground
  22390. * @param scene defines the hosting scene
  22391. * @param updatable defines if the mesh must be flagged as updatable
  22392. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22393. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22394. * @returns a new Mesh
  22395. */
  22396. 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;
  22397. /**
  22398. * Creates a tube mesh.
  22399. * The tube is a parametric shape.
  22400. * It has no predefined shape. Its final shape will depend on the input parameters.
  22401. * Please consider using the same method from the MeshBuilder class instead
  22402. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22403. * @param name defines the name of the mesh to create
  22404. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22405. * @param radius sets the tube radius size
  22406. * @param tessellation is the number of sides on the tubular surface
  22407. * @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
  22408. * @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
  22409. * @param scene defines the hosting scene
  22410. * @param updatable defines if the mesh must be flagged as updatable
  22411. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22412. * @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)
  22413. * @returns a new Mesh
  22414. */
  22415. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22416. (i: number, distance: number): number;
  22417. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22418. /**
  22419. * Creates a polyhedron mesh.
  22420. * Please consider using the same method from the MeshBuilder class instead.
  22421. * * 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
  22422. * * The parameter `size` (positive float, default 1) sets the polygon size
  22423. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22424. * * 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`
  22425. * * 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
  22426. * * 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)`)
  22427. * * 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
  22428. * * 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
  22429. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22430. * * If you create a double-sided mesh, you can choose what parts of 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
  22431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22432. * @param name defines the name of the mesh to create
  22433. * @param options defines the options used to create the mesh
  22434. * @param scene defines the hosting scene
  22435. * @returns a new Mesh
  22436. */
  22437. static CreatePolyhedron(name: string, options: {
  22438. type?: number;
  22439. size?: number;
  22440. sizeX?: number;
  22441. sizeY?: number;
  22442. sizeZ?: number;
  22443. custom?: any;
  22444. faceUV?: Vector4[];
  22445. faceColors?: Color4[];
  22446. updatable?: boolean;
  22447. sideOrientation?: number;
  22448. }, scene: Scene): Mesh;
  22449. /**
  22450. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22451. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22452. * * 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`)
  22453. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22454. * * 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
  22455. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22456. * * If you create a double-sided mesh, you can choose what parts of 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
  22457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22458. * @param name defines the name of the mesh
  22459. * @param options defines the options used to create the mesh
  22460. * @param scene defines the hosting scene
  22461. * @returns a new Mesh
  22462. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22463. */
  22464. static CreateIcoSphere(name: string, options: {
  22465. radius?: number;
  22466. flat?: boolean;
  22467. subdivisions?: number;
  22468. sideOrientation?: number;
  22469. updatable?: boolean;
  22470. }, scene: Scene): Mesh;
  22471. /**
  22472. * Creates a decal mesh.
  22473. * Please consider using the same method from the MeshBuilder class instead.
  22474. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22475. * @param name defines the name of the mesh
  22476. * @param sourceMesh defines the mesh receiving the decal
  22477. * @param position sets the position of the decal in world coordinates
  22478. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22479. * @param size sets the decal scaling
  22480. * @param angle sets the angle to rotate the decal
  22481. * @returns a new Mesh
  22482. */
  22483. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22484. /**
  22485. * Prepare internal position array for software CPU skinning
  22486. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22487. */
  22488. setPositionsForCPUSkinning(): Float32Array;
  22489. /**
  22490. * Prepare internal normal array for software CPU skinning
  22491. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22492. */
  22493. setNormalsForCPUSkinning(): Float32Array;
  22494. /**
  22495. * Updates the vertex buffer by applying transformation from the bones
  22496. * @param skeleton defines the skeleton to apply to current mesh
  22497. * @returns the current mesh
  22498. */
  22499. applySkeleton(skeleton: Skeleton): Mesh;
  22500. /**
  22501. * 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
  22502. * @param meshes defines the list of meshes to scan
  22503. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22504. */
  22505. static MinMax(meshes: AbstractMesh[]): {
  22506. min: Vector3;
  22507. max: Vector3;
  22508. };
  22509. /**
  22510. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22511. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22512. * @returns a vector3
  22513. */
  22514. static Center(meshesOrMinMaxVector: {
  22515. min: Vector3;
  22516. max: Vector3;
  22517. } | AbstractMesh[]): Vector3;
  22518. /**
  22519. * Merge the array of meshes into a single mesh for performance reasons.
  22520. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22521. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22522. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22523. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22524. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22525. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22526. * @returns a new mesh
  22527. */
  22528. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22529. /** @hidden */
  22530. addInstance(instance: InstancedMesh): void;
  22531. /** @hidden */
  22532. removeInstance(instance: InstancedMesh): void;
  22533. }
  22534. }
  22535. declare module "babylonjs/Materials/material" {
  22536. import { IAnimatable } from "babylonjs/Misc/tools";
  22537. import { SmartArray } from "babylonjs/Misc/smartArray";
  22538. import { Observable } from "babylonjs/Misc/observable";
  22539. import { Nullable } from "babylonjs/types";
  22540. import { Scene } from "babylonjs/scene";
  22541. import { Matrix } from "babylonjs/Maths/math";
  22542. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22544. import { Mesh } from "babylonjs/Meshes/mesh";
  22545. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22546. import { Effect } from "babylonjs/Materials/effect";
  22547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22548. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22549. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22550. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22551. import { Animation } from "babylonjs/Animations/animation";
  22552. /**
  22553. * Base class for the main features of a material in Babylon.js
  22554. */
  22555. export class Material implements IAnimatable {
  22556. /**
  22557. * Returns the triangle fill mode
  22558. */
  22559. static readonly TriangleFillMode: number;
  22560. /**
  22561. * Returns the wireframe mode
  22562. */
  22563. static readonly WireFrameFillMode: number;
  22564. /**
  22565. * Returns the point fill mode
  22566. */
  22567. static readonly PointFillMode: number;
  22568. /**
  22569. * Returns the point list draw mode
  22570. */
  22571. static readonly PointListDrawMode: number;
  22572. /**
  22573. * Returns the line list draw mode
  22574. */
  22575. static readonly LineListDrawMode: number;
  22576. /**
  22577. * Returns the line loop draw mode
  22578. */
  22579. static readonly LineLoopDrawMode: number;
  22580. /**
  22581. * Returns the line strip draw mode
  22582. */
  22583. static readonly LineStripDrawMode: number;
  22584. /**
  22585. * Returns the triangle strip draw mode
  22586. */
  22587. static readonly TriangleStripDrawMode: number;
  22588. /**
  22589. * Returns the triangle fan draw mode
  22590. */
  22591. static readonly TriangleFanDrawMode: number;
  22592. /**
  22593. * Stores the clock-wise side orientation
  22594. */
  22595. static readonly ClockWiseSideOrientation: number;
  22596. /**
  22597. * Stores the counter clock-wise side orientation
  22598. */
  22599. static readonly CounterClockWiseSideOrientation: number;
  22600. /**
  22601. * The dirty texture flag value
  22602. */
  22603. static readonly TextureDirtyFlag: number;
  22604. /**
  22605. * The dirty light flag value
  22606. */
  22607. static readonly LightDirtyFlag: number;
  22608. /**
  22609. * The dirty fresnel flag value
  22610. */
  22611. static readonly FresnelDirtyFlag: number;
  22612. /**
  22613. * The dirty attribute flag value
  22614. */
  22615. static readonly AttributesDirtyFlag: number;
  22616. /**
  22617. * The dirty misc flag value
  22618. */
  22619. static readonly MiscDirtyFlag: number;
  22620. /**
  22621. * The all dirty flag value
  22622. */
  22623. static readonly AllDirtyFlag: number;
  22624. /**
  22625. * The ID of the material
  22626. */
  22627. id: string;
  22628. /**
  22629. * Gets or sets the unique id of the material
  22630. */
  22631. uniqueId: number;
  22632. /**
  22633. * The name of the material
  22634. */
  22635. name: string;
  22636. /**
  22637. * Gets or sets user defined metadata
  22638. */
  22639. metadata: any;
  22640. /**
  22641. * For internal use only. Please do not use.
  22642. */
  22643. reservedDataStore: any;
  22644. /**
  22645. * Specifies if the ready state should be checked on each call
  22646. */
  22647. checkReadyOnEveryCall: boolean;
  22648. /**
  22649. * Specifies if the ready state should be checked once
  22650. */
  22651. checkReadyOnlyOnce: boolean;
  22652. /**
  22653. * The state of the material
  22654. */
  22655. state: string;
  22656. /**
  22657. * The alpha value of the material
  22658. */
  22659. protected _alpha: number;
  22660. /**
  22661. * List of inspectable custom properties (used by the Inspector)
  22662. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22663. */
  22664. inspectableCustomProperties: IInspectable[];
  22665. /**
  22666. * Sets the alpha value of the material
  22667. */
  22668. /**
  22669. * Gets the alpha value of the material
  22670. */
  22671. alpha: number;
  22672. /**
  22673. * Specifies if back face culling is enabled
  22674. */
  22675. protected _backFaceCulling: boolean;
  22676. /**
  22677. * Sets the back-face culling state
  22678. */
  22679. /**
  22680. * Gets the back-face culling state
  22681. */
  22682. backFaceCulling: boolean;
  22683. /**
  22684. * Stores the value for side orientation
  22685. */
  22686. sideOrientation: number;
  22687. /**
  22688. * Callback triggered when the material is compiled
  22689. */
  22690. onCompiled: Nullable<(effect: Effect) => void>;
  22691. /**
  22692. * Callback triggered when an error occurs
  22693. */
  22694. onError: Nullable<(effect: Effect, errors: string) => void>;
  22695. /**
  22696. * Callback triggered to get the render target textures
  22697. */
  22698. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22699. /**
  22700. * Gets a boolean indicating that current material needs to register RTT
  22701. */
  22702. readonly hasRenderTargetTextures: boolean;
  22703. /**
  22704. * Specifies if the material should be serialized
  22705. */
  22706. doNotSerialize: boolean;
  22707. /**
  22708. * @hidden
  22709. */
  22710. _storeEffectOnSubMeshes: boolean;
  22711. /**
  22712. * Stores the animations for the material
  22713. */
  22714. animations: Nullable<Array<Animation>>;
  22715. /**
  22716. * An event triggered when the material is disposed
  22717. */
  22718. onDisposeObservable: Observable<Material>;
  22719. /**
  22720. * An observer which watches for dispose events
  22721. */
  22722. private _onDisposeObserver;
  22723. private _onUnBindObservable;
  22724. /**
  22725. * Called during a dispose event
  22726. */
  22727. onDispose: () => void;
  22728. private _onBindObservable;
  22729. /**
  22730. * An event triggered when the material is bound
  22731. */
  22732. readonly onBindObservable: Observable<AbstractMesh>;
  22733. /**
  22734. * An observer which watches for bind events
  22735. */
  22736. private _onBindObserver;
  22737. /**
  22738. * Called during a bind event
  22739. */
  22740. onBind: (Mesh: AbstractMesh) => void;
  22741. /**
  22742. * An event triggered when the material is unbound
  22743. */
  22744. readonly onUnBindObservable: Observable<Material>;
  22745. /**
  22746. * Stores the value of the alpha mode
  22747. */
  22748. private _alphaMode;
  22749. /**
  22750. * Sets the value of the alpha mode.
  22751. *
  22752. * | Value | Type | Description |
  22753. * | --- | --- | --- |
  22754. * | 0 | ALPHA_DISABLE | |
  22755. * | 1 | ALPHA_ADD | |
  22756. * | 2 | ALPHA_COMBINE | |
  22757. * | 3 | ALPHA_SUBTRACT | |
  22758. * | 4 | ALPHA_MULTIPLY | |
  22759. * | 5 | ALPHA_MAXIMIZED | |
  22760. * | 6 | ALPHA_ONEONE | |
  22761. * | 7 | ALPHA_PREMULTIPLIED | |
  22762. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22763. * | 9 | ALPHA_INTERPOLATE | |
  22764. * | 10 | ALPHA_SCREENMODE | |
  22765. *
  22766. */
  22767. /**
  22768. * Gets the value of the alpha mode
  22769. */
  22770. alphaMode: number;
  22771. /**
  22772. * Stores the state of the need depth pre-pass value
  22773. */
  22774. private _needDepthPrePass;
  22775. /**
  22776. * Sets the need depth pre-pass value
  22777. */
  22778. /**
  22779. * Gets the depth pre-pass value
  22780. */
  22781. needDepthPrePass: boolean;
  22782. /**
  22783. * Specifies if depth writing should be disabled
  22784. */
  22785. disableDepthWrite: boolean;
  22786. /**
  22787. * Specifies if depth writing should be forced
  22788. */
  22789. forceDepthWrite: boolean;
  22790. /**
  22791. * Specifies if there should be a separate pass for culling
  22792. */
  22793. separateCullingPass: boolean;
  22794. /**
  22795. * Stores the state specifing if fog should be enabled
  22796. */
  22797. private _fogEnabled;
  22798. /**
  22799. * Sets the state for enabling fog
  22800. */
  22801. /**
  22802. * Gets the value of the fog enabled state
  22803. */
  22804. fogEnabled: boolean;
  22805. /**
  22806. * Stores the size of points
  22807. */
  22808. pointSize: number;
  22809. /**
  22810. * Stores the z offset value
  22811. */
  22812. zOffset: number;
  22813. /**
  22814. * Gets a value specifying if wireframe mode is enabled
  22815. */
  22816. /**
  22817. * Sets the state of wireframe mode
  22818. */
  22819. wireframe: boolean;
  22820. /**
  22821. * Gets the value specifying if point clouds are enabled
  22822. */
  22823. /**
  22824. * Sets the state of point cloud mode
  22825. */
  22826. pointsCloud: boolean;
  22827. /**
  22828. * Gets the material fill mode
  22829. */
  22830. /**
  22831. * Sets the material fill mode
  22832. */
  22833. fillMode: number;
  22834. /**
  22835. * @hidden
  22836. * Stores the effects for the material
  22837. */
  22838. _effect: Nullable<Effect>;
  22839. /**
  22840. * @hidden
  22841. * Specifies if the material was previously ready
  22842. */
  22843. _wasPreviouslyReady: boolean;
  22844. /**
  22845. * Specifies if uniform buffers should be used
  22846. */
  22847. private _useUBO;
  22848. /**
  22849. * Stores a reference to the scene
  22850. */
  22851. private _scene;
  22852. /**
  22853. * Stores the fill mode state
  22854. */
  22855. private _fillMode;
  22856. /**
  22857. * Specifies if the depth write state should be cached
  22858. */
  22859. private _cachedDepthWriteState;
  22860. /**
  22861. * Stores the uniform buffer
  22862. */
  22863. protected _uniformBuffer: UniformBuffer;
  22864. /** @hidden */
  22865. _indexInSceneMaterialArray: number;
  22866. /** @hidden */
  22867. meshMap: Nullable<{
  22868. [id: string]: AbstractMesh | undefined;
  22869. }>;
  22870. /**
  22871. * Creates a material instance
  22872. * @param name defines the name of the material
  22873. * @param scene defines the scene to reference
  22874. * @param doNotAdd specifies if the material should be added to the scene
  22875. */
  22876. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22877. /**
  22878. * Returns a string representation of the current material
  22879. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22880. * @returns a string with material information
  22881. */
  22882. toString(fullDetails?: boolean): string;
  22883. /**
  22884. * Gets the class name of the material
  22885. * @returns a string with the class name of the material
  22886. */
  22887. getClassName(): string;
  22888. /**
  22889. * Specifies if updates for the material been locked
  22890. */
  22891. readonly isFrozen: boolean;
  22892. /**
  22893. * Locks updates for the material
  22894. */
  22895. freeze(): void;
  22896. /**
  22897. * Unlocks updates for the material
  22898. */
  22899. unfreeze(): void;
  22900. /**
  22901. * Specifies if the material is ready to be used
  22902. * @param mesh defines the mesh to check
  22903. * @param useInstances specifies if instances should be used
  22904. * @returns a boolean indicating if the material is ready to be used
  22905. */
  22906. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22907. /**
  22908. * Specifies that the submesh is ready to be used
  22909. * @param mesh defines the mesh to check
  22910. * @param subMesh defines which submesh to check
  22911. * @param useInstances specifies that instances should be used
  22912. * @returns a boolean indicating that the submesh is ready or not
  22913. */
  22914. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22915. /**
  22916. * Returns the material effect
  22917. * @returns the effect associated with the material
  22918. */
  22919. getEffect(): Nullable<Effect>;
  22920. /**
  22921. * Returns the current scene
  22922. * @returns a Scene
  22923. */
  22924. getScene(): Scene;
  22925. /**
  22926. * Specifies if the material will require alpha blending
  22927. * @returns a boolean specifying if alpha blending is needed
  22928. */
  22929. needAlphaBlending(): boolean;
  22930. /**
  22931. * Specifies if the mesh will require alpha blending
  22932. * @param mesh defines the mesh to check
  22933. * @returns a boolean specifying if alpha blending is needed for the mesh
  22934. */
  22935. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22936. /**
  22937. * Specifies if this material should be rendered in alpha test mode
  22938. * @returns a boolean specifying if an alpha test is needed.
  22939. */
  22940. needAlphaTesting(): boolean;
  22941. /**
  22942. * Gets the texture used for the alpha test
  22943. * @returns the texture to use for alpha testing
  22944. */
  22945. getAlphaTestTexture(): Nullable<BaseTexture>;
  22946. /**
  22947. * Marks the material to indicate that it needs to be re-calculated
  22948. */
  22949. markDirty(): void;
  22950. /** @hidden */
  22951. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22952. /**
  22953. * Binds the material to the mesh
  22954. * @param world defines the world transformation matrix
  22955. * @param mesh defines the mesh to bind the material to
  22956. */
  22957. bind(world: Matrix, mesh?: Mesh): void;
  22958. /**
  22959. * Binds the submesh to the material
  22960. * @param world defines the world transformation matrix
  22961. * @param mesh defines the mesh containing the submesh
  22962. * @param subMesh defines the submesh to bind the material to
  22963. */
  22964. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22965. /**
  22966. * Binds the world matrix to the material
  22967. * @param world defines the world transformation matrix
  22968. */
  22969. bindOnlyWorldMatrix(world: Matrix): void;
  22970. /**
  22971. * Binds the scene's uniform buffer to the effect.
  22972. * @param effect defines the effect to bind to the scene uniform buffer
  22973. * @param sceneUbo defines the uniform buffer storing scene data
  22974. */
  22975. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22976. /**
  22977. * Binds the view matrix to the effect
  22978. * @param effect defines the effect to bind the view matrix to
  22979. */
  22980. bindView(effect: Effect): void;
  22981. /**
  22982. * Binds the view projection matrix to the effect
  22983. * @param effect defines the effect to bind the view projection matrix to
  22984. */
  22985. bindViewProjection(effect: Effect): void;
  22986. /**
  22987. * Specifies if material alpha testing should be turned on for the mesh
  22988. * @param mesh defines the mesh to check
  22989. */
  22990. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22991. /**
  22992. * Processes to execute after binding the material to a mesh
  22993. * @param mesh defines the rendered mesh
  22994. */
  22995. protected _afterBind(mesh?: Mesh): void;
  22996. /**
  22997. * Unbinds the material from the mesh
  22998. */
  22999. unbind(): void;
  23000. /**
  23001. * Gets the active textures from the material
  23002. * @returns an array of textures
  23003. */
  23004. getActiveTextures(): BaseTexture[];
  23005. /**
  23006. * Specifies if the material uses a texture
  23007. * @param texture defines the texture to check against the material
  23008. * @returns a boolean specifying if the material uses the texture
  23009. */
  23010. hasTexture(texture: BaseTexture): boolean;
  23011. /**
  23012. * Makes a duplicate of the material, and gives it a new name
  23013. * @param name defines the new name for the duplicated material
  23014. * @returns the cloned material
  23015. */
  23016. clone(name: string): Nullable<Material>;
  23017. /**
  23018. * Gets the meshes bound to the material
  23019. * @returns an array of meshes bound to the material
  23020. */
  23021. getBindedMeshes(): AbstractMesh[];
  23022. /**
  23023. * Force shader compilation
  23024. * @param mesh defines the mesh associated with this material
  23025. * @param onCompiled defines a function to execute once the material is compiled
  23026. * @param options defines the options to configure the compilation
  23027. */
  23028. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23029. clipPlane: boolean;
  23030. }>): void;
  23031. /**
  23032. * Force shader compilation
  23033. * @param mesh defines the mesh that will use this material
  23034. * @param options defines additional options for compiling the shaders
  23035. * @returns a promise that resolves when the compilation completes
  23036. */
  23037. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23038. clipPlane: boolean;
  23039. }>): Promise<void>;
  23040. private static readonly _ImageProcessingDirtyCallBack;
  23041. private static readonly _TextureDirtyCallBack;
  23042. private static readonly _FresnelDirtyCallBack;
  23043. private static readonly _MiscDirtyCallBack;
  23044. private static readonly _LightsDirtyCallBack;
  23045. private static readonly _AttributeDirtyCallBack;
  23046. private static _FresnelAndMiscDirtyCallBack;
  23047. private static _TextureAndMiscDirtyCallBack;
  23048. private static readonly _DirtyCallbackArray;
  23049. private static readonly _RunDirtyCallBacks;
  23050. /**
  23051. * Marks a define in the material to indicate that it needs to be re-computed
  23052. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23053. */
  23054. markAsDirty(flag: number): void;
  23055. /**
  23056. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23057. * @param func defines a function which checks material defines against the submeshes
  23058. */
  23059. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23060. /**
  23061. * Indicates that image processing needs to be re-calculated for all submeshes
  23062. */
  23063. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23064. /**
  23065. * Indicates that textures need to be re-calculated for all submeshes
  23066. */
  23067. protected _markAllSubMeshesAsTexturesDirty(): void;
  23068. /**
  23069. * Indicates that fresnel needs to be re-calculated for all submeshes
  23070. */
  23071. protected _markAllSubMeshesAsFresnelDirty(): void;
  23072. /**
  23073. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23074. */
  23075. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23076. /**
  23077. * Indicates that lights need to be re-calculated for all submeshes
  23078. */
  23079. protected _markAllSubMeshesAsLightsDirty(): void;
  23080. /**
  23081. * Indicates that attributes need to be re-calculated for all submeshes
  23082. */
  23083. protected _markAllSubMeshesAsAttributesDirty(): void;
  23084. /**
  23085. * Indicates that misc needs to be re-calculated for all submeshes
  23086. */
  23087. protected _markAllSubMeshesAsMiscDirty(): void;
  23088. /**
  23089. * Indicates that textures and misc need to be re-calculated for all submeshes
  23090. */
  23091. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23092. /**
  23093. * Disposes the material
  23094. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23095. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23096. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23097. */
  23098. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23099. /** @hidden */
  23100. private releaseVertexArrayObject;
  23101. /**
  23102. * Serializes this material
  23103. * @returns the serialized material object
  23104. */
  23105. serialize(): any;
  23106. /**
  23107. * Creates a material from parsed material data
  23108. * @param parsedMaterial defines parsed material data
  23109. * @param scene defines the hosting scene
  23110. * @param rootUrl defines the root URL to use to load textures
  23111. * @returns a new material
  23112. */
  23113. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23114. }
  23115. }
  23116. declare module "babylonjs/Meshes/subMesh" {
  23117. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23118. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23119. import { Engine } from "babylonjs/Engines/engine";
  23120. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23121. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23122. import { Effect } from "babylonjs/Materials/effect";
  23123. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23124. import { Collider } from "babylonjs/Collisions/collider";
  23125. import { Material } from "babylonjs/Materials/material";
  23126. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23128. import { Mesh } from "babylonjs/Meshes/mesh";
  23129. import { Ray } from "babylonjs/Culling/ray";
  23130. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23131. /**
  23132. * Base class for submeshes
  23133. */
  23134. export class BaseSubMesh {
  23135. /** @hidden */
  23136. _materialDefines: Nullable<MaterialDefines>;
  23137. /** @hidden */
  23138. _materialEffect: Nullable<Effect>;
  23139. /**
  23140. * Gets associated effect
  23141. */
  23142. readonly effect: Nullable<Effect>;
  23143. /**
  23144. * Sets associated effect (effect used to render this submesh)
  23145. * @param effect defines the effect to associate with
  23146. * @param defines defines the set of defines used to compile this effect
  23147. */
  23148. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23149. }
  23150. /**
  23151. * Defines a subdivision inside a mesh
  23152. */
  23153. export class SubMesh extends BaseSubMesh implements ICullable {
  23154. /** the material index to use */
  23155. materialIndex: number;
  23156. /** vertex index start */
  23157. verticesStart: number;
  23158. /** vertices count */
  23159. verticesCount: number;
  23160. /** index start */
  23161. indexStart: number;
  23162. /** indices count */
  23163. indexCount: number;
  23164. /** @hidden */
  23165. _linesIndexCount: number;
  23166. private _mesh;
  23167. private _renderingMesh;
  23168. private _boundingInfo;
  23169. private _linesIndexBuffer;
  23170. /** @hidden */
  23171. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23172. /** @hidden */
  23173. _trianglePlanes: Plane[];
  23174. /** @hidden */
  23175. _lastColliderTransformMatrix: Nullable<Matrix>;
  23176. /** @hidden */
  23177. _renderId: number;
  23178. /** @hidden */
  23179. _alphaIndex: number;
  23180. /** @hidden */
  23181. _distanceToCamera: number;
  23182. /** @hidden */
  23183. _id: number;
  23184. private _currentMaterial;
  23185. /**
  23186. * Add a new submesh to a mesh
  23187. * @param materialIndex defines the material index to use
  23188. * @param verticesStart defines vertex index start
  23189. * @param verticesCount defines vertices count
  23190. * @param indexStart defines index start
  23191. * @param indexCount defines indices count
  23192. * @param mesh defines the parent mesh
  23193. * @param renderingMesh defines an optional rendering mesh
  23194. * @param createBoundingBox defines if bounding box should be created for this submesh
  23195. * @returns the new submesh
  23196. */
  23197. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23198. /**
  23199. * Creates a new submesh
  23200. * @param materialIndex defines the material index to use
  23201. * @param verticesStart defines vertex index start
  23202. * @param verticesCount defines vertices count
  23203. * @param indexStart defines index start
  23204. * @param indexCount defines indices count
  23205. * @param mesh defines the parent mesh
  23206. * @param renderingMesh defines an optional rendering mesh
  23207. * @param createBoundingBox defines if bounding box should be created for this submesh
  23208. */
  23209. constructor(
  23210. /** the material index to use */
  23211. materialIndex: number,
  23212. /** vertex index start */
  23213. verticesStart: number,
  23214. /** vertices count */
  23215. verticesCount: number,
  23216. /** index start */
  23217. indexStart: number,
  23218. /** indices count */
  23219. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23220. /**
  23221. * Returns true if this submesh covers the entire parent mesh
  23222. * @ignorenaming
  23223. */
  23224. readonly IsGlobal: boolean;
  23225. /**
  23226. * Returns the submesh BoudingInfo object
  23227. * @returns current bounding info (or mesh's one if the submesh is global)
  23228. */
  23229. getBoundingInfo(): BoundingInfo;
  23230. /**
  23231. * Sets the submesh BoundingInfo
  23232. * @param boundingInfo defines the new bounding info to use
  23233. * @returns the SubMesh
  23234. */
  23235. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23236. /**
  23237. * Returns the mesh of the current submesh
  23238. * @return the parent mesh
  23239. */
  23240. getMesh(): AbstractMesh;
  23241. /**
  23242. * Returns the rendering mesh of the submesh
  23243. * @returns the rendering mesh (could be different from parent mesh)
  23244. */
  23245. getRenderingMesh(): Mesh;
  23246. /**
  23247. * Returns the submesh material
  23248. * @returns null or the current material
  23249. */
  23250. getMaterial(): Nullable<Material>;
  23251. /**
  23252. * Sets a new updated BoundingInfo object to the submesh
  23253. * @param data defines an optional position array to use to determine the bounding info
  23254. * @returns the SubMesh
  23255. */
  23256. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23257. /** @hidden */
  23258. _checkCollision(collider: Collider): boolean;
  23259. /**
  23260. * Updates the submesh BoundingInfo
  23261. * @param world defines the world matrix to use to update the bounding info
  23262. * @returns the submesh
  23263. */
  23264. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23265. /**
  23266. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23267. * @param frustumPlanes defines the frustum planes
  23268. * @returns true if the submesh is intersecting with the frustum
  23269. */
  23270. isInFrustum(frustumPlanes: Plane[]): boolean;
  23271. /**
  23272. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23273. * @param frustumPlanes defines the frustum planes
  23274. * @returns true if the submesh is inside the frustum
  23275. */
  23276. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23277. /**
  23278. * Renders the submesh
  23279. * @param enableAlphaMode defines if alpha needs to be used
  23280. * @returns the submesh
  23281. */
  23282. render(enableAlphaMode: boolean): SubMesh;
  23283. /**
  23284. * @hidden
  23285. */
  23286. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23287. /**
  23288. * Checks if the submesh intersects with a ray
  23289. * @param ray defines the ray to test
  23290. * @returns true is the passed ray intersects the submesh bounding box
  23291. */
  23292. canIntersects(ray: Ray): boolean;
  23293. /**
  23294. * Intersects current submesh with a ray
  23295. * @param ray defines the ray to test
  23296. * @param positions defines mesh's positions array
  23297. * @param indices defines mesh's indices array
  23298. * @param fastCheck defines if only bounding info should be used
  23299. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23300. * @returns intersection info or null if no intersection
  23301. */
  23302. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23303. /** @hidden */
  23304. private _intersectLines;
  23305. /** @hidden */
  23306. private _intersectTriangles;
  23307. /** @hidden */
  23308. private _intersectUnIndexedTriangles;
  23309. /** @hidden */
  23310. _rebuild(): void;
  23311. /**
  23312. * Creates a new submesh from the passed mesh
  23313. * @param newMesh defines the new hosting mesh
  23314. * @param newRenderingMesh defines an optional rendering mesh
  23315. * @returns the new submesh
  23316. */
  23317. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23318. /**
  23319. * Release associated resources
  23320. */
  23321. dispose(): void;
  23322. /**
  23323. * Gets the class name
  23324. * @returns the string "SubMesh".
  23325. */
  23326. getClassName(): string;
  23327. /**
  23328. * Creates a new submesh from indices data
  23329. * @param materialIndex the index of the main mesh material
  23330. * @param startIndex the index where to start the copy in the mesh indices array
  23331. * @param indexCount the number of indices to copy then from the startIndex
  23332. * @param mesh the main mesh to create the submesh from
  23333. * @param renderingMesh the optional rendering mesh
  23334. * @returns a new submesh
  23335. */
  23336. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23337. }
  23338. }
  23339. declare module "babylonjs/Meshes/geometry" {
  23340. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23341. import { Scene } from "babylonjs/scene";
  23342. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23343. import { Engine } from "babylonjs/Engines/engine";
  23344. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23345. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23346. import { Effect } from "babylonjs/Materials/effect";
  23347. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23348. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23349. import { Mesh } from "babylonjs/Meshes/mesh";
  23350. /**
  23351. * Class used to store geometry data (vertex buffers + index buffer)
  23352. */
  23353. export class Geometry implements IGetSetVerticesData {
  23354. /**
  23355. * Gets or sets the ID of the geometry
  23356. */
  23357. id: string;
  23358. /**
  23359. * Gets or sets the unique ID of the geometry
  23360. */
  23361. uniqueId: number;
  23362. /**
  23363. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23364. */
  23365. delayLoadState: number;
  23366. /**
  23367. * Gets the file containing the data to load when running in delay load state
  23368. */
  23369. delayLoadingFile: Nullable<string>;
  23370. /**
  23371. * Callback called when the geometry is updated
  23372. */
  23373. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23374. private _scene;
  23375. private _engine;
  23376. private _meshes;
  23377. private _totalVertices;
  23378. /** @hidden */
  23379. _indices: IndicesArray;
  23380. /** @hidden */
  23381. _vertexBuffers: {
  23382. [key: string]: VertexBuffer;
  23383. };
  23384. private _isDisposed;
  23385. private _extend;
  23386. private _boundingBias;
  23387. /** @hidden */
  23388. _delayInfo: Array<string>;
  23389. private _indexBuffer;
  23390. private _indexBufferIsUpdatable;
  23391. /** @hidden */
  23392. _boundingInfo: Nullable<BoundingInfo>;
  23393. /** @hidden */
  23394. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23395. /** @hidden */
  23396. _softwareSkinningFrameId: number;
  23397. private _vertexArrayObjects;
  23398. private _updatable;
  23399. /** @hidden */
  23400. _positions: Nullable<Vector3[]>;
  23401. /**
  23402. * 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
  23403. */
  23404. /**
  23405. * 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
  23406. */
  23407. boundingBias: Vector2;
  23408. /**
  23409. * Static function used to attach a new empty geometry to a mesh
  23410. * @param mesh defines the mesh to attach the geometry to
  23411. * @returns the new Geometry
  23412. */
  23413. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23414. /**
  23415. * Creates a new geometry
  23416. * @param id defines the unique ID
  23417. * @param scene defines the hosting scene
  23418. * @param vertexData defines the VertexData used to get geometry data
  23419. * @param updatable defines if geometry must be updatable (false by default)
  23420. * @param mesh defines the mesh that will be associated with the geometry
  23421. */
  23422. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23423. /**
  23424. * Gets the current extend of the geometry
  23425. */
  23426. readonly extend: {
  23427. minimum: Vector3;
  23428. maximum: Vector3;
  23429. };
  23430. /**
  23431. * Gets the hosting scene
  23432. * @returns the hosting Scene
  23433. */
  23434. getScene(): Scene;
  23435. /**
  23436. * Gets the hosting engine
  23437. * @returns the hosting Engine
  23438. */
  23439. getEngine(): Engine;
  23440. /**
  23441. * Defines if the geometry is ready to use
  23442. * @returns true if the geometry is ready to be used
  23443. */
  23444. isReady(): boolean;
  23445. /**
  23446. * Gets a value indicating that the geometry should not be serialized
  23447. */
  23448. readonly doNotSerialize: boolean;
  23449. /** @hidden */
  23450. _rebuild(): void;
  23451. /**
  23452. * Affects all geometry data in one call
  23453. * @param vertexData defines the geometry data
  23454. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23455. */
  23456. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23457. /**
  23458. * Set specific vertex data
  23459. * @param kind defines the data kind (Position, normal, etc...)
  23460. * @param data defines the vertex data to use
  23461. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23462. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23463. */
  23464. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23465. /**
  23466. * Removes a specific vertex data
  23467. * @param kind defines the data kind (Position, normal, etc...)
  23468. */
  23469. removeVerticesData(kind: string): void;
  23470. /**
  23471. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23472. * @param buffer defines the vertex buffer to use
  23473. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23474. */
  23475. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23476. /**
  23477. * Update a specific vertex buffer
  23478. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23479. * It will do nothing if the buffer is not updatable
  23480. * @param kind defines the data kind (Position, normal, etc...)
  23481. * @param data defines the data to use
  23482. * @param offset defines the offset in the target buffer where to store the data
  23483. * @param useBytes set to true if the offset is in bytes
  23484. */
  23485. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23486. /**
  23487. * Update a specific vertex buffer
  23488. * This function will create a new buffer if the current one is not updatable
  23489. * @param kind defines the data kind (Position, normal, etc...)
  23490. * @param data defines the data to use
  23491. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23492. */
  23493. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23494. private _updateBoundingInfo;
  23495. /** @hidden */
  23496. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23497. /**
  23498. * Gets total number of vertices
  23499. * @returns the total number of vertices
  23500. */
  23501. getTotalVertices(): number;
  23502. /**
  23503. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23504. * @param kind defines the data kind (Position, normal, etc...)
  23505. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23506. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23507. * @returns a float array containing vertex data
  23508. */
  23509. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23510. /**
  23511. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23512. * @param kind defines the data kind (Position, normal, etc...)
  23513. * @returns true if the vertex buffer with the specified kind is updatable
  23514. */
  23515. isVertexBufferUpdatable(kind: string): boolean;
  23516. /**
  23517. * Gets a specific vertex buffer
  23518. * @param kind defines the data kind (Position, normal, etc...)
  23519. * @returns a VertexBuffer
  23520. */
  23521. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23522. /**
  23523. * Returns all vertex buffers
  23524. * @return an object holding all vertex buffers indexed by kind
  23525. */
  23526. getVertexBuffers(): Nullable<{
  23527. [key: string]: VertexBuffer;
  23528. }>;
  23529. /**
  23530. * Gets a boolean indicating if specific vertex buffer is present
  23531. * @param kind defines the data kind (Position, normal, etc...)
  23532. * @returns true if data is present
  23533. */
  23534. isVerticesDataPresent(kind: string): boolean;
  23535. /**
  23536. * Gets a list of all attached data kinds (Position, normal, etc...)
  23537. * @returns a list of string containing all kinds
  23538. */
  23539. getVerticesDataKinds(): string[];
  23540. /**
  23541. * Update index buffer
  23542. * @param indices defines the indices to store in the index buffer
  23543. * @param offset defines the offset in the target buffer where to store the data
  23544. * @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)
  23545. */
  23546. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23547. /**
  23548. * Creates a new index buffer
  23549. * @param indices defines the indices to store in the index buffer
  23550. * @param totalVertices defines the total number of vertices (could be null)
  23551. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23552. */
  23553. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23554. /**
  23555. * Return the total number of indices
  23556. * @returns the total number of indices
  23557. */
  23558. getTotalIndices(): number;
  23559. /**
  23560. * Gets the index buffer array
  23561. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23562. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23563. * @returns the index buffer array
  23564. */
  23565. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23566. /**
  23567. * Gets the index buffer
  23568. * @return the index buffer
  23569. */
  23570. getIndexBuffer(): Nullable<DataBuffer>;
  23571. /** @hidden */
  23572. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23573. /**
  23574. * Release the associated resources for a specific mesh
  23575. * @param mesh defines the source mesh
  23576. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23577. */
  23578. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23579. /**
  23580. * Apply current geometry to a given mesh
  23581. * @param mesh defines the mesh to apply geometry to
  23582. */
  23583. applyToMesh(mesh: Mesh): void;
  23584. private _updateExtend;
  23585. private _applyToMesh;
  23586. private notifyUpdate;
  23587. /**
  23588. * Load the geometry if it was flagged as delay loaded
  23589. * @param scene defines the hosting scene
  23590. * @param onLoaded defines a callback called when the geometry is loaded
  23591. */
  23592. load(scene: Scene, onLoaded?: () => void): void;
  23593. private _queueLoad;
  23594. /**
  23595. * Invert the geometry to move from a right handed system to a left handed one.
  23596. */
  23597. toLeftHanded(): void;
  23598. /** @hidden */
  23599. _resetPointsArrayCache(): void;
  23600. /** @hidden */
  23601. _generatePointsArray(): boolean;
  23602. /**
  23603. * Gets a value indicating if the geometry is disposed
  23604. * @returns true if the geometry was disposed
  23605. */
  23606. isDisposed(): boolean;
  23607. private _disposeVertexArrayObjects;
  23608. /**
  23609. * Free all associated resources
  23610. */
  23611. dispose(): void;
  23612. /**
  23613. * Clone the current geometry into a new geometry
  23614. * @param id defines the unique ID of the new geometry
  23615. * @returns a new geometry object
  23616. */
  23617. copy(id: string): Geometry;
  23618. /**
  23619. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23620. * @return a JSON representation of the current geometry data (without the vertices data)
  23621. */
  23622. serialize(): any;
  23623. private toNumberArray;
  23624. /**
  23625. * Serialize all vertices data into a JSON oject
  23626. * @returns a JSON representation of the current geometry data
  23627. */
  23628. serializeVerticeData(): any;
  23629. /**
  23630. * Extracts a clone of a mesh geometry
  23631. * @param mesh defines the source mesh
  23632. * @param id defines the unique ID of the new geometry object
  23633. * @returns the new geometry object
  23634. */
  23635. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23636. /**
  23637. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23638. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23639. * Be aware Math.random() could cause collisions, but:
  23640. * "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"
  23641. * @returns a string containing a new GUID
  23642. */
  23643. static RandomId(): string;
  23644. /** @hidden */
  23645. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23646. private static _CleanMatricesWeights;
  23647. /**
  23648. * Create a new geometry from persisted data (Using .babylon file format)
  23649. * @param parsedVertexData defines the persisted data
  23650. * @param scene defines the hosting scene
  23651. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23652. * @returns the new geometry object
  23653. */
  23654. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23655. }
  23656. }
  23657. declare module "babylonjs/Meshes/mesh.vertexData" {
  23658. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23659. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23660. import { Geometry } from "babylonjs/Meshes/geometry";
  23661. import { Mesh } from "babylonjs/Meshes/mesh";
  23662. /**
  23663. * Define an interface for all classes that will get and set the data on vertices
  23664. */
  23665. export interface IGetSetVerticesData {
  23666. /**
  23667. * Gets a boolean indicating if specific vertex data is present
  23668. * @param kind defines the vertex data kind to use
  23669. * @returns true is data kind is present
  23670. */
  23671. isVerticesDataPresent(kind: string): boolean;
  23672. /**
  23673. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23674. * @param kind defines the data kind (Position, normal, etc...)
  23675. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23676. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23677. * @returns a float array containing vertex data
  23678. */
  23679. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23680. /**
  23681. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23682. * @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.
  23683. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23684. * @returns the indices array or an empty array if the mesh has no geometry
  23685. */
  23686. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23687. /**
  23688. * Set specific vertex data
  23689. * @param kind defines the data kind (Position, normal, etc...)
  23690. * @param data defines the vertex data to use
  23691. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23692. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23693. */
  23694. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23695. /**
  23696. * Update a specific associated vertex buffer
  23697. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23698. * - VertexBuffer.PositionKind
  23699. * - VertexBuffer.UVKind
  23700. * - VertexBuffer.UV2Kind
  23701. * - VertexBuffer.UV3Kind
  23702. * - VertexBuffer.UV4Kind
  23703. * - VertexBuffer.UV5Kind
  23704. * - VertexBuffer.UV6Kind
  23705. * - VertexBuffer.ColorKind
  23706. * - VertexBuffer.MatricesIndicesKind
  23707. * - VertexBuffer.MatricesIndicesExtraKind
  23708. * - VertexBuffer.MatricesWeightsKind
  23709. * - VertexBuffer.MatricesWeightsExtraKind
  23710. * @param data defines the data source
  23711. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23712. * @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)
  23713. */
  23714. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23715. /**
  23716. * Creates a new index buffer
  23717. * @param indices defines the indices to store in the index buffer
  23718. * @param totalVertices defines the total number of vertices (could be null)
  23719. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23720. */
  23721. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23722. }
  23723. /**
  23724. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23725. */
  23726. export class VertexData {
  23727. /**
  23728. * Mesh side orientation : usually the external or front surface
  23729. */
  23730. static readonly FRONTSIDE: number;
  23731. /**
  23732. * Mesh side orientation : usually the internal or back surface
  23733. */
  23734. static readonly BACKSIDE: number;
  23735. /**
  23736. * Mesh side orientation : both internal and external or front and back surfaces
  23737. */
  23738. static readonly DOUBLESIDE: number;
  23739. /**
  23740. * Mesh side orientation : by default, `FRONTSIDE`
  23741. */
  23742. static readonly DEFAULTSIDE: number;
  23743. /**
  23744. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23745. */
  23746. positions: Nullable<FloatArray>;
  23747. /**
  23748. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23749. */
  23750. normals: Nullable<FloatArray>;
  23751. /**
  23752. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23753. */
  23754. tangents: Nullable<FloatArray>;
  23755. /**
  23756. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23757. */
  23758. uvs: Nullable<FloatArray>;
  23759. /**
  23760. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23761. */
  23762. uvs2: Nullable<FloatArray>;
  23763. /**
  23764. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23765. */
  23766. uvs3: Nullable<FloatArray>;
  23767. /**
  23768. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23769. */
  23770. uvs4: Nullable<FloatArray>;
  23771. /**
  23772. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23773. */
  23774. uvs5: Nullable<FloatArray>;
  23775. /**
  23776. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23777. */
  23778. uvs6: Nullable<FloatArray>;
  23779. /**
  23780. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23781. */
  23782. colors: Nullable<FloatArray>;
  23783. /**
  23784. * 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).
  23785. */
  23786. matricesIndices: Nullable<FloatArray>;
  23787. /**
  23788. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23789. */
  23790. matricesWeights: Nullable<FloatArray>;
  23791. /**
  23792. * An array extending the number of possible indices
  23793. */
  23794. matricesIndicesExtra: Nullable<FloatArray>;
  23795. /**
  23796. * An array extending the number of possible weights when the number of indices is extended
  23797. */
  23798. matricesWeightsExtra: Nullable<FloatArray>;
  23799. /**
  23800. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23801. */
  23802. indices: Nullable<IndicesArray>;
  23803. /**
  23804. * Uses the passed data array to set the set the values for the specified kind of data
  23805. * @param data a linear array of floating numbers
  23806. * @param kind the type of data that is being set, eg positions, colors etc
  23807. */
  23808. set(data: FloatArray, kind: string): void;
  23809. /**
  23810. * Associates the vertexData to the passed Mesh.
  23811. * Sets it as updatable or not (default `false`)
  23812. * @param mesh the mesh the vertexData is applied to
  23813. * @param updatable when used and having the value true allows new data to update the vertexData
  23814. * @returns the VertexData
  23815. */
  23816. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23817. /**
  23818. * Associates the vertexData to the passed Geometry.
  23819. * Sets it as updatable or not (default `false`)
  23820. * @param geometry the geometry the vertexData is applied to
  23821. * @param updatable when used and having the value true allows new data to update the vertexData
  23822. * @returns VertexData
  23823. */
  23824. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23825. /**
  23826. * Updates the associated mesh
  23827. * @param mesh the mesh to be updated
  23828. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23829. * @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
  23830. * @returns VertexData
  23831. */
  23832. updateMesh(mesh: Mesh): VertexData;
  23833. /**
  23834. * Updates the associated geometry
  23835. * @param geometry the geometry to be updated
  23836. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23837. * @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
  23838. * @returns VertexData.
  23839. */
  23840. updateGeometry(geometry: Geometry): VertexData;
  23841. private _applyTo;
  23842. private _update;
  23843. /**
  23844. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23845. * @param matrix the transforming matrix
  23846. * @returns the VertexData
  23847. */
  23848. transform(matrix: Matrix): VertexData;
  23849. /**
  23850. * Merges the passed VertexData into the current one
  23851. * @param other the VertexData to be merged into the current one
  23852. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23853. * @returns the modified VertexData
  23854. */
  23855. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23856. private _mergeElement;
  23857. private _validate;
  23858. /**
  23859. * Serializes the VertexData
  23860. * @returns a serialized object
  23861. */
  23862. serialize(): any;
  23863. /**
  23864. * Extracts the vertexData from a mesh
  23865. * @param mesh the mesh from which to extract the VertexData
  23866. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23867. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23868. * @returns the object VertexData associated to the passed mesh
  23869. */
  23870. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23871. /**
  23872. * Extracts the vertexData from the geometry
  23873. * @param geometry the geometry from which to extract the VertexData
  23874. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23875. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23876. * @returns the object VertexData associated to the passed mesh
  23877. */
  23878. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23879. private static _ExtractFrom;
  23880. /**
  23881. * Creates the VertexData for a Ribbon
  23882. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23883. * * pathArray array of paths, each of which an array of successive Vector3
  23884. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23885. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23886. * * 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
  23887. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23888. * * 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)
  23889. * * 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)
  23890. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23891. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23892. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23893. * @returns the VertexData of the ribbon
  23894. */
  23895. static CreateRibbon(options: {
  23896. pathArray: Vector3[][];
  23897. closeArray?: boolean;
  23898. closePath?: boolean;
  23899. offset?: number;
  23900. sideOrientation?: number;
  23901. frontUVs?: Vector4;
  23902. backUVs?: Vector4;
  23903. invertUV?: boolean;
  23904. uvs?: Vector2[];
  23905. colors?: Color4[];
  23906. }): VertexData;
  23907. /**
  23908. * Creates the VertexData for a box
  23909. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23910. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23911. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23912. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23913. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23914. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23915. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23916. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23917. * * 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)
  23918. * * 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)
  23919. * @returns the VertexData of the box
  23920. */
  23921. static CreateBox(options: {
  23922. size?: number;
  23923. width?: number;
  23924. height?: number;
  23925. depth?: number;
  23926. faceUV?: Vector4[];
  23927. faceColors?: Color4[];
  23928. sideOrientation?: number;
  23929. frontUVs?: Vector4;
  23930. backUVs?: Vector4;
  23931. }): VertexData;
  23932. /**
  23933. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23934. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23935. * * segments sets the number of horizontal strips optional, default 32
  23936. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23937. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23938. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23939. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23940. * * 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
  23941. * * 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
  23942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23943. * * 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)
  23944. * * 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)
  23945. * @returns the VertexData of the ellipsoid
  23946. */
  23947. static CreateSphere(options: {
  23948. segments?: number;
  23949. diameter?: number;
  23950. diameterX?: number;
  23951. diameterY?: number;
  23952. diameterZ?: number;
  23953. arc?: number;
  23954. slice?: number;
  23955. sideOrientation?: number;
  23956. frontUVs?: Vector4;
  23957. backUVs?: Vector4;
  23958. }): VertexData;
  23959. /**
  23960. * Creates the VertexData for a cylinder, cone or prism
  23961. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23962. * * height sets the height (y direction) of the cylinder, optional, default 2
  23963. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23964. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23965. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23966. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23967. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23968. * * 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
  23969. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23970. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23971. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23972. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23974. * * 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)
  23975. * * 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)
  23976. * @returns the VertexData of the cylinder, cone or prism
  23977. */
  23978. static CreateCylinder(options: {
  23979. height?: number;
  23980. diameterTop?: number;
  23981. diameterBottom?: number;
  23982. diameter?: number;
  23983. tessellation?: number;
  23984. subdivisions?: number;
  23985. arc?: number;
  23986. faceColors?: Color4[];
  23987. faceUV?: Vector4[];
  23988. hasRings?: boolean;
  23989. enclose?: boolean;
  23990. sideOrientation?: number;
  23991. frontUVs?: Vector4;
  23992. backUVs?: Vector4;
  23993. }): VertexData;
  23994. /**
  23995. * Creates the VertexData for a torus
  23996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23997. * * diameter the diameter of the torus, optional default 1
  23998. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23999. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24000. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24001. * * 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)
  24002. * * 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)
  24003. * @returns the VertexData of the torus
  24004. */
  24005. static CreateTorus(options: {
  24006. diameter?: number;
  24007. thickness?: number;
  24008. tessellation?: number;
  24009. sideOrientation?: number;
  24010. frontUVs?: Vector4;
  24011. backUVs?: Vector4;
  24012. }): VertexData;
  24013. /**
  24014. * Creates the VertexData of the LineSystem
  24015. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24016. * - lines an array of lines, each line being an array of successive Vector3
  24017. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24018. * @returns the VertexData of the LineSystem
  24019. */
  24020. static CreateLineSystem(options: {
  24021. lines: Vector3[][];
  24022. colors?: Nullable<Color4[][]>;
  24023. }): VertexData;
  24024. /**
  24025. * Create the VertexData for a DashedLines
  24026. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24027. * - points an array successive Vector3
  24028. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24029. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24030. * - dashNb the intended total number of dashes, optional, default 200
  24031. * @returns the VertexData for the DashedLines
  24032. */
  24033. static CreateDashedLines(options: {
  24034. points: Vector3[];
  24035. dashSize?: number;
  24036. gapSize?: number;
  24037. dashNb?: number;
  24038. }): VertexData;
  24039. /**
  24040. * Creates the VertexData for a Ground
  24041. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24042. * - width the width (x direction) of the ground, optional, default 1
  24043. * - height the height (z direction) of the ground, optional, default 1
  24044. * - subdivisions the number of subdivisions per side, optional, default 1
  24045. * @returns the VertexData of the Ground
  24046. */
  24047. static CreateGround(options: {
  24048. width?: number;
  24049. height?: number;
  24050. subdivisions?: number;
  24051. subdivisionsX?: number;
  24052. subdivisionsY?: number;
  24053. }): VertexData;
  24054. /**
  24055. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24056. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24057. * * xmin the ground minimum X coordinate, optional, default -1
  24058. * * zmin the ground minimum Z coordinate, optional, default -1
  24059. * * xmax the ground maximum X coordinate, optional, default 1
  24060. * * zmax the ground maximum Z coordinate, optional, default 1
  24061. * * 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}
  24062. * * 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}
  24063. * @returns the VertexData of the TiledGround
  24064. */
  24065. static CreateTiledGround(options: {
  24066. xmin: number;
  24067. zmin: number;
  24068. xmax: number;
  24069. zmax: number;
  24070. subdivisions?: {
  24071. w: number;
  24072. h: number;
  24073. };
  24074. precision?: {
  24075. w: number;
  24076. h: number;
  24077. };
  24078. }): VertexData;
  24079. /**
  24080. * Creates the VertexData of the Ground designed from a heightmap
  24081. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24082. * * width the width (x direction) of the ground
  24083. * * height the height (z direction) of the ground
  24084. * * subdivisions the number of subdivisions per side
  24085. * * minHeight the minimum altitude on the ground, optional, default 0
  24086. * * maxHeight the maximum altitude on the ground, optional default 1
  24087. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24088. * * buffer the array holding the image color data
  24089. * * bufferWidth the width of image
  24090. * * bufferHeight the height of image
  24091. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24092. * @returns the VertexData of the Ground designed from a heightmap
  24093. */
  24094. static CreateGroundFromHeightMap(options: {
  24095. width: number;
  24096. height: number;
  24097. subdivisions: number;
  24098. minHeight: number;
  24099. maxHeight: number;
  24100. colorFilter: Color3;
  24101. buffer: Uint8Array;
  24102. bufferWidth: number;
  24103. bufferHeight: number;
  24104. alphaFilter: number;
  24105. }): VertexData;
  24106. /**
  24107. * Creates the VertexData for a Plane
  24108. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24109. * * size sets the width and height of the plane to the value of size, optional default 1
  24110. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24111. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24113. * * 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)
  24114. * * 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)
  24115. * @returns the VertexData of the box
  24116. */
  24117. static CreatePlane(options: {
  24118. size?: number;
  24119. width?: number;
  24120. height?: number;
  24121. sideOrientation?: number;
  24122. frontUVs?: Vector4;
  24123. backUVs?: Vector4;
  24124. }): VertexData;
  24125. /**
  24126. * Creates the VertexData of the Disc or regular Polygon
  24127. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24128. * * radius the radius of the disc, optional default 0.5
  24129. * * tessellation the number of polygon sides, optional, default 64
  24130. * * 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
  24131. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24132. * * 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)
  24133. * * 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)
  24134. * @returns the VertexData of the box
  24135. */
  24136. static CreateDisc(options: {
  24137. radius?: number;
  24138. tessellation?: number;
  24139. arc?: number;
  24140. sideOrientation?: number;
  24141. frontUVs?: Vector4;
  24142. backUVs?: Vector4;
  24143. }): VertexData;
  24144. /**
  24145. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24146. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24147. * @param polygon a mesh built from polygonTriangulation.build()
  24148. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24149. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24150. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24151. * @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)
  24152. * @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)
  24153. * @returns the VertexData of the Polygon
  24154. */
  24155. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24156. /**
  24157. * Creates the VertexData of the IcoSphere
  24158. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24159. * * radius the radius of the IcoSphere, optional default 1
  24160. * * radiusX allows stretching in the x direction, optional, default radius
  24161. * * radiusY allows stretching in the y direction, optional, default radius
  24162. * * radiusZ allows stretching in the z direction, optional, default radius
  24163. * * flat when true creates a flat shaded mesh, optional, default true
  24164. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24166. * * 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)
  24167. * * 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)
  24168. * @returns the VertexData of the IcoSphere
  24169. */
  24170. static CreateIcoSphere(options: {
  24171. radius?: number;
  24172. radiusX?: number;
  24173. radiusY?: number;
  24174. radiusZ?: number;
  24175. flat?: boolean;
  24176. subdivisions?: number;
  24177. sideOrientation?: number;
  24178. frontUVs?: Vector4;
  24179. backUVs?: Vector4;
  24180. }): VertexData;
  24181. /**
  24182. * Creates the VertexData for a Polyhedron
  24183. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24184. * * type provided types are:
  24185. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24186. * * 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)
  24187. * * size the size of the IcoSphere, optional default 1
  24188. * * sizeX allows stretching in the x direction, optional, default size
  24189. * * sizeY allows stretching in the y direction, optional, default size
  24190. * * sizeZ allows stretching in the z direction, optional, default size
  24191. * * 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
  24192. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24193. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24194. * * flat when true creates a flat shaded mesh, optional, default true
  24195. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24197. * * 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)
  24198. * * 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)
  24199. * @returns the VertexData of the Polyhedron
  24200. */
  24201. static CreatePolyhedron(options: {
  24202. type?: number;
  24203. size?: number;
  24204. sizeX?: number;
  24205. sizeY?: number;
  24206. sizeZ?: number;
  24207. custom?: any;
  24208. faceUV?: Vector4[];
  24209. faceColors?: Color4[];
  24210. flat?: boolean;
  24211. sideOrientation?: number;
  24212. frontUVs?: Vector4;
  24213. backUVs?: Vector4;
  24214. }): VertexData;
  24215. /**
  24216. * Creates the VertexData for a TorusKnot
  24217. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24218. * * radius the radius of the torus knot, optional, default 2
  24219. * * tube the thickness of the tube, optional, default 0.5
  24220. * * radialSegments the number of sides on each tube segments, optional, default 32
  24221. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24222. * * p the number of windings around the z axis, optional, default 2
  24223. * * q the number of windings around the x axis, optional, default 3
  24224. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24225. * * 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)
  24226. * * 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)
  24227. * @returns the VertexData of the Torus Knot
  24228. */
  24229. static CreateTorusKnot(options: {
  24230. radius?: number;
  24231. tube?: number;
  24232. radialSegments?: number;
  24233. tubularSegments?: number;
  24234. p?: number;
  24235. q?: number;
  24236. sideOrientation?: number;
  24237. frontUVs?: Vector4;
  24238. backUVs?: Vector4;
  24239. }): VertexData;
  24240. /**
  24241. * Compute normals for given positions and indices
  24242. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24243. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24244. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24245. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24246. * * facetNormals : optional array of facet normals (vector3)
  24247. * * facetPositions : optional array of facet positions (vector3)
  24248. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24249. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24250. * * bInfo : optional bounding info, required for facetPartitioning computation
  24251. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24252. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24253. * * useRightHandedSystem: optional boolean to for right handed system computation
  24254. * * depthSort : optional boolean to enable the facet depth sort computation
  24255. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24256. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24257. */
  24258. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24259. facetNormals?: any;
  24260. facetPositions?: any;
  24261. facetPartitioning?: any;
  24262. ratio?: number;
  24263. bInfo?: any;
  24264. bbSize?: Vector3;
  24265. subDiv?: any;
  24266. useRightHandedSystem?: boolean;
  24267. depthSort?: boolean;
  24268. distanceTo?: Vector3;
  24269. depthSortedFacets?: any;
  24270. }): void;
  24271. /** @hidden */
  24272. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24273. /**
  24274. * Applies VertexData created from the imported parameters to the geometry
  24275. * @param parsedVertexData the parsed data from an imported file
  24276. * @param geometry the geometry to apply the VertexData to
  24277. */
  24278. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24279. }
  24280. }
  24281. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24282. import { Nullable } from "babylonjs/types";
  24283. import { Scene } from "babylonjs/scene";
  24284. import { Vector4 } from "babylonjs/Maths/math";
  24285. import { Mesh } from "babylonjs/Meshes/mesh";
  24286. /**
  24287. * Class containing static functions to help procedurally build meshes
  24288. */
  24289. export class DiscBuilder {
  24290. /**
  24291. * Creates a plane polygonal mesh. By default, this is a disc
  24292. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24293. * * 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
  24294. * * 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
  24295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24298. * @param name defines the name of the mesh
  24299. * @param options defines the options used to create the mesh
  24300. * @param scene defines the hosting scene
  24301. * @returns the plane polygonal mesh
  24302. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24303. */
  24304. static CreateDisc(name: string, options: {
  24305. radius?: number;
  24306. tessellation?: number;
  24307. arc?: number;
  24308. updatable?: boolean;
  24309. sideOrientation?: number;
  24310. frontUVs?: Vector4;
  24311. backUVs?: Vector4;
  24312. }, scene?: Nullable<Scene>): Mesh;
  24313. }
  24314. }
  24315. declare module "babylonjs/Particles/solidParticleSystem" {
  24316. import { Vector3 } from "babylonjs/Maths/math";
  24317. import { Mesh } from "babylonjs/Meshes/mesh";
  24318. import { Scene, IDisposable } from "babylonjs/scene";
  24319. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24320. /**
  24321. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24322. *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.
  24323. * The SPS is also a particle system. It provides some methods to manage the particles.
  24324. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24325. *
  24326. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24327. */
  24328. export class SolidParticleSystem implements IDisposable {
  24329. /**
  24330. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24331. * Example : var p = SPS.particles[i];
  24332. */
  24333. particles: SolidParticle[];
  24334. /**
  24335. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24336. */
  24337. nbParticles: number;
  24338. /**
  24339. * If the particles must ever face the camera (default false). Useful for planar particles.
  24340. */
  24341. billboard: boolean;
  24342. /**
  24343. * Recompute normals when adding a shape
  24344. */
  24345. recomputeNormals: boolean;
  24346. /**
  24347. * This a counter ofr your own usage. It's not set by any SPS functions.
  24348. */
  24349. counter: number;
  24350. /**
  24351. * The SPS name. This name is also given to the underlying mesh.
  24352. */
  24353. name: string;
  24354. /**
  24355. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24356. */
  24357. mesh: Mesh;
  24358. /**
  24359. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24360. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24361. */
  24362. vars: any;
  24363. /**
  24364. * This array is populated when the SPS is set as 'pickable'.
  24365. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24366. * Each element of this array is an object `{idx: int, faceId: int}`.
  24367. * `idx` is the picked particle index in the `SPS.particles` array
  24368. * `faceId` is the picked face index counted within this particle.
  24369. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24370. */
  24371. pickedParticles: {
  24372. idx: number;
  24373. faceId: number;
  24374. }[];
  24375. /**
  24376. * This array is populated when `enableDepthSort` is set to true.
  24377. * Each element of this array is an instance of the class DepthSortedParticle.
  24378. */
  24379. depthSortedParticles: DepthSortedParticle[];
  24380. /**
  24381. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24382. * @hidden
  24383. */
  24384. _bSphereOnly: boolean;
  24385. /**
  24386. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24387. * @hidden
  24388. */
  24389. _bSphereRadiusFactor: number;
  24390. private _scene;
  24391. private _positions;
  24392. private _indices;
  24393. private _normals;
  24394. private _colors;
  24395. private _uvs;
  24396. private _indices32;
  24397. private _positions32;
  24398. private _normals32;
  24399. private _fixedNormal32;
  24400. private _colors32;
  24401. private _uvs32;
  24402. private _index;
  24403. private _updatable;
  24404. private _pickable;
  24405. private _isVisibilityBoxLocked;
  24406. private _alwaysVisible;
  24407. private _depthSort;
  24408. private _shapeCounter;
  24409. private _copy;
  24410. private _color;
  24411. private _computeParticleColor;
  24412. private _computeParticleTexture;
  24413. private _computeParticleRotation;
  24414. private _computeParticleVertex;
  24415. private _computeBoundingBox;
  24416. private _depthSortParticles;
  24417. private _camera;
  24418. private _mustUnrotateFixedNormals;
  24419. private _particlesIntersect;
  24420. private _needs32Bits;
  24421. /**
  24422. * Creates a SPS (Solid Particle System) object.
  24423. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24424. * @param scene (Scene) is the scene in which the SPS is added.
  24425. * @param options defines the options of the sps e.g.
  24426. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24427. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24428. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24429. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24430. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24431. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24432. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24433. */
  24434. constructor(name: string, scene: Scene, options?: {
  24435. updatable?: boolean;
  24436. isPickable?: boolean;
  24437. enableDepthSort?: boolean;
  24438. particleIntersection?: boolean;
  24439. boundingSphereOnly?: boolean;
  24440. bSphereRadiusFactor?: number;
  24441. });
  24442. /**
  24443. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24444. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24445. * @returns the created mesh
  24446. */
  24447. buildMesh(): Mesh;
  24448. /**
  24449. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24450. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24451. * Thus the particles generated from `digest()` have their property `position` set yet.
  24452. * @param mesh ( Mesh ) is the mesh to be digested
  24453. * @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
  24454. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24455. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24456. * @returns the current SPS
  24457. */
  24458. digest(mesh: Mesh, options?: {
  24459. facetNb?: number;
  24460. number?: number;
  24461. delta?: number;
  24462. }): SolidParticleSystem;
  24463. private _unrotateFixedNormals;
  24464. private _resetCopy;
  24465. private _meshBuilder;
  24466. private _posToShape;
  24467. private _uvsToShapeUV;
  24468. private _addParticle;
  24469. /**
  24470. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24471. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24472. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24473. * @param nb (positive integer) the number of particles to be created from this model
  24474. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24475. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24476. * @returns the number of shapes in the system
  24477. */
  24478. addShape(mesh: Mesh, nb: number, options?: {
  24479. positionFunction?: any;
  24480. vertexFunction?: any;
  24481. }): number;
  24482. private _rebuildParticle;
  24483. /**
  24484. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24485. * @returns the SPS.
  24486. */
  24487. rebuildMesh(): SolidParticleSystem;
  24488. /**
  24489. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24490. * This method calls `updateParticle()` for each particle of the SPS.
  24491. * For an animated SPS, it is usually called within the render loop.
  24492. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24493. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24494. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24495. * @returns the SPS.
  24496. */
  24497. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24498. /**
  24499. * Disposes the SPS.
  24500. */
  24501. dispose(): void;
  24502. /**
  24503. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24504. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24505. * @returns the SPS.
  24506. */
  24507. refreshVisibleSize(): SolidParticleSystem;
  24508. /**
  24509. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24510. * @param size the size (float) of the visibility box
  24511. * note : this doesn't lock the SPS mesh bounding box.
  24512. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24513. */
  24514. setVisibilityBox(size: number): void;
  24515. /**
  24516. * Gets whether the SPS as always visible or not
  24517. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24518. */
  24519. /**
  24520. * Sets the SPS as always visible or not
  24521. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24522. */
  24523. isAlwaysVisible: boolean;
  24524. /**
  24525. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24526. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24527. */
  24528. /**
  24529. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24530. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24531. */
  24532. isVisibilityBoxLocked: boolean;
  24533. /**
  24534. * Tells to `setParticles()` to compute the particle rotations or not.
  24535. * Default value : true. The SPS is faster when it's set to false.
  24536. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24537. */
  24538. /**
  24539. * Gets if `setParticles()` computes the particle rotations or not.
  24540. * Default value : true. The SPS is faster when it's set to false.
  24541. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24542. */
  24543. computeParticleRotation: boolean;
  24544. /**
  24545. * Tells to `setParticles()` to compute the particle colors or not.
  24546. * Default value : true. The SPS is faster when it's set to false.
  24547. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24548. */
  24549. /**
  24550. * Gets if `setParticles()` computes the particle colors or not.
  24551. * Default value : true. The SPS is faster when it's set to false.
  24552. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24553. */
  24554. computeParticleColor: boolean;
  24555. /**
  24556. * Gets if `setParticles()` computes the particle textures or not.
  24557. * Default value : true. The SPS is faster when it's set to false.
  24558. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24559. */
  24560. computeParticleTexture: boolean;
  24561. /**
  24562. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24563. * Default value : false. The SPS is faster when it's set to false.
  24564. * Note : the particle custom vertex positions aren't stored values.
  24565. */
  24566. /**
  24567. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24568. * Default value : false. The SPS is faster when it's set to false.
  24569. * Note : the particle custom vertex positions aren't stored values.
  24570. */
  24571. computeParticleVertex: boolean;
  24572. /**
  24573. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24574. */
  24575. /**
  24576. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24577. */
  24578. computeBoundingBox: boolean;
  24579. /**
  24580. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24581. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24582. * Default : `true`
  24583. */
  24584. /**
  24585. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24586. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24587. * Default : `true`
  24588. */
  24589. depthSortParticles: boolean;
  24590. /**
  24591. * This function does nothing. It may be overwritten to set all the particle first values.
  24592. * The SPS doesn't call this function, you may have to call it by your own.
  24593. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24594. */
  24595. initParticles(): void;
  24596. /**
  24597. * This function does nothing. It may be overwritten to recycle a particle.
  24598. * The SPS doesn't call this function, you may have to call it by your own.
  24599. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24600. * @param particle The particle to recycle
  24601. * @returns the recycled particle
  24602. */
  24603. recycleParticle(particle: SolidParticle): SolidParticle;
  24604. /**
  24605. * Updates a particle : this function should be overwritten by the user.
  24606. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24607. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24608. * @example : just set a particle position or velocity and recycle conditions
  24609. * @param particle The particle to update
  24610. * @returns the updated particle
  24611. */
  24612. updateParticle(particle: SolidParticle): SolidParticle;
  24613. /**
  24614. * Updates a vertex of a particle : it can be overwritten by the user.
  24615. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24616. * @param particle the current particle
  24617. * @param vertex the current index of the current particle
  24618. * @param pt the index of the current vertex in the particle shape
  24619. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24620. * @example : just set a vertex particle position
  24621. * @returns the updated vertex
  24622. */
  24623. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24624. /**
  24625. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24626. * This does nothing and may be overwritten by the user.
  24627. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24628. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24629. * @param update the boolean update value actually passed to setParticles()
  24630. */
  24631. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24632. /**
  24633. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24634. * This will be passed three parameters.
  24635. * This does nothing and may be overwritten by the user.
  24636. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24637. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24638. * @param update the boolean update value actually passed to setParticles()
  24639. */
  24640. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24641. }
  24642. }
  24643. declare module "babylonjs/Particles/solidParticle" {
  24644. import { Nullable } from "babylonjs/types";
  24645. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24646. import { Mesh } from "babylonjs/Meshes/mesh";
  24647. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24648. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24649. /**
  24650. * Represents one particle of a solid particle system.
  24651. */
  24652. export class SolidParticle {
  24653. /**
  24654. * particle global index
  24655. */
  24656. idx: number;
  24657. /**
  24658. * The color of the particle
  24659. */
  24660. color: Nullable<Color4>;
  24661. /**
  24662. * The world space position of the particle.
  24663. */
  24664. position: Vector3;
  24665. /**
  24666. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24667. */
  24668. rotation: Vector3;
  24669. /**
  24670. * The world space rotation quaternion of the particle.
  24671. */
  24672. rotationQuaternion: Nullable<Quaternion>;
  24673. /**
  24674. * The scaling of the particle.
  24675. */
  24676. scaling: Vector3;
  24677. /**
  24678. * The uvs of the particle.
  24679. */
  24680. uvs: Vector4;
  24681. /**
  24682. * The current speed of the particle.
  24683. */
  24684. velocity: Vector3;
  24685. /**
  24686. * The pivot point in the particle local space.
  24687. */
  24688. pivot: Vector3;
  24689. /**
  24690. * Must the particle be translated from its pivot point in its local space ?
  24691. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24692. * Default : false
  24693. */
  24694. translateFromPivot: boolean;
  24695. /**
  24696. * Is the particle active or not ?
  24697. */
  24698. alive: boolean;
  24699. /**
  24700. * Is the particle visible or not ?
  24701. */
  24702. isVisible: boolean;
  24703. /**
  24704. * Index of this particle in the global "positions" array (Internal use)
  24705. * @hidden
  24706. */
  24707. _pos: number;
  24708. /**
  24709. * @hidden Index of this particle in the global "indices" array (Internal use)
  24710. */
  24711. _ind: number;
  24712. /**
  24713. * @hidden ModelShape of this particle (Internal use)
  24714. */
  24715. _model: ModelShape;
  24716. /**
  24717. * ModelShape id of this particle
  24718. */
  24719. shapeId: number;
  24720. /**
  24721. * Index of the particle in its shape id (Internal use)
  24722. */
  24723. idxInShape: number;
  24724. /**
  24725. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24726. */
  24727. _modelBoundingInfo: BoundingInfo;
  24728. /**
  24729. * @hidden Particle BoundingInfo object (Internal use)
  24730. */
  24731. _boundingInfo: BoundingInfo;
  24732. /**
  24733. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24734. */
  24735. _sps: SolidParticleSystem;
  24736. /**
  24737. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24738. */
  24739. _stillInvisible: boolean;
  24740. /**
  24741. * @hidden Last computed particle rotation matrix
  24742. */
  24743. _rotationMatrix: number[];
  24744. /**
  24745. * Parent particle Id, if any.
  24746. * Default null.
  24747. */
  24748. parentId: Nullable<number>;
  24749. /**
  24750. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24751. * The possible values are :
  24752. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24753. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24754. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24755. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24756. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24757. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24758. * */
  24759. cullingStrategy: number;
  24760. /**
  24761. * @hidden Internal global position in the SPS.
  24762. */
  24763. _globalPosition: Vector3;
  24764. /**
  24765. * Creates a Solid Particle object.
  24766. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24767. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24768. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24769. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24770. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24771. * @param shapeId (integer) is the model shape identifier in the SPS.
  24772. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24773. * @param sps defines the sps it is associated to
  24774. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24775. */
  24776. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24777. /**
  24778. * Legacy support, changed scale to scaling
  24779. */
  24780. /**
  24781. * Legacy support, changed scale to scaling
  24782. */
  24783. scale: Vector3;
  24784. /**
  24785. * Legacy support, changed quaternion to rotationQuaternion
  24786. */
  24787. /**
  24788. * Legacy support, changed quaternion to rotationQuaternion
  24789. */
  24790. quaternion: Nullable<Quaternion>;
  24791. /**
  24792. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24793. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24794. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24795. * @returns true if it intersects
  24796. */
  24797. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24798. /**
  24799. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24800. * A particle is in the frustum if its bounding box intersects the frustum
  24801. * @param frustumPlanes defines the frustum to test
  24802. * @returns true if the particle is in the frustum planes
  24803. */
  24804. isInFrustum(frustumPlanes: Plane[]): boolean;
  24805. /**
  24806. * get the rotation matrix of the particle
  24807. * @hidden
  24808. */
  24809. getRotationMatrix(m: Matrix): void;
  24810. }
  24811. /**
  24812. * Represents the shape of the model used by one particle of a solid particle system.
  24813. * SPS internal tool, don't use it manually.
  24814. */
  24815. export class ModelShape {
  24816. /**
  24817. * The shape id
  24818. * @hidden
  24819. */
  24820. shapeID: number;
  24821. /**
  24822. * flat array of model positions (internal use)
  24823. * @hidden
  24824. */
  24825. _shape: Vector3[];
  24826. /**
  24827. * flat array of model UVs (internal use)
  24828. * @hidden
  24829. */
  24830. _shapeUV: number[];
  24831. /**
  24832. * length of the shape in the model indices array (internal use)
  24833. * @hidden
  24834. */
  24835. _indicesLength: number;
  24836. /**
  24837. * Custom position function (internal use)
  24838. * @hidden
  24839. */
  24840. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24841. /**
  24842. * Custom vertex function (internal use)
  24843. * @hidden
  24844. */
  24845. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24846. /**
  24847. * 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.
  24848. * SPS internal tool, don't use it manually.
  24849. * @hidden
  24850. */
  24851. 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>);
  24852. }
  24853. /**
  24854. * Represents a Depth Sorted Particle in the solid particle system.
  24855. */
  24856. export class DepthSortedParticle {
  24857. /**
  24858. * Index of the particle in the "indices" array
  24859. */
  24860. ind: number;
  24861. /**
  24862. * Length of the particle shape in the "indices" array
  24863. */
  24864. indicesLength: number;
  24865. /**
  24866. * Squared distance from the particle to the camera
  24867. */
  24868. sqDistance: number;
  24869. }
  24870. }
  24871. declare module "babylonjs/Collisions/meshCollisionData" {
  24872. import { Collider } from "babylonjs/Collisions/collider";
  24873. import { Vector3 } from "babylonjs/Maths/math";
  24874. import { Nullable } from "babylonjs/types";
  24875. import { Observer } from "babylonjs/Misc/observable";
  24876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24877. /**
  24878. * @hidden
  24879. */
  24880. export class _MeshCollisionData {
  24881. _checkCollisions: boolean;
  24882. _collisionMask: number;
  24883. _collisionGroup: number;
  24884. _collider: Nullable<Collider>;
  24885. _oldPositionForCollisions: Vector3;
  24886. _diffPositionForCollisions: Vector3;
  24887. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24888. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24889. }
  24890. }
  24891. declare module "babylonjs/Meshes/abstractMesh" {
  24892. import { Observable } from "babylonjs/Misc/observable";
  24893. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24894. import { Camera } from "babylonjs/Cameras/camera";
  24895. import { Scene, IDisposable } from "babylonjs/scene";
  24896. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24897. import { Node } from "babylonjs/node";
  24898. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24899. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24900. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24901. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24902. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24903. import { Material } from "babylonjs/Materials/material";
  24904. import { Light } from "babylonjs/Lights/light";
  24905. import { Skeleton } from "babylonjs/Bones/skeleton";
  24906. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24907. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24908. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24909. import { Ray } from "babylonjs/Culling/ray";
  24910. import { Collider } from "babylonjs/Collisions/collider";
  24911. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24912. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24913. /**
  24914. * Class used to store all common mesh properties
  24915. */
  24916. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24917. /** No occlusion */
  24918. static OCCLUSION_TYPE_NONE: number;
  24919. /** Occlusion set to optimisitic */
  24920. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24921. /** Occlusion set to strict */
  24922. static OCCLUSION_TYPE_STRICT: number;
  24923. /** Use an accurante occlusion algorithm */
  24924. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24925. /** Use a conservative occlusion algorithm */
  24926. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24927. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24928. * Test order :
  24929. * Is the bounding sphere outside the frustum ?
  24930. * If not, are the bounding box vertices outside the frustum ?
  24931. * It not, then the cullable object is in the frustum.
  24932. */
  24933. static readonly CULLINGSTRATEGY_STANDARD: number;
  24934. /** Culling strategy : Bounding Sphere Only.
  24935. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24936. * It's also less accurate than the standard because some not visible objects can still be selected.
  24937. * Test : is the bounding sphere outside the frustum ?
  24938. * If not, then the cullable object is in the frustum.
  24939. */
  24940. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24941. /** Culling strategy : Optimistic Inclusion.
  24942. * This in an inclusion test first, then the standard exclusion test.
  24943. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24944. * 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.
  24945. * Anyway, it's as accurate as the standard strategy.
  24946. * Test :
  24947. * Is the cullable object bounding sphere center in the frustum ?
  24948. * If not, apply the default culling strategy.
  24949. */
  24950. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24951. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24952. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24953. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24954. * 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.
  24955. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24956. * Test :
  24957. * Is the cullable object bounding sphere center in the frustum ?
  24958. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24959. */
  24960. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24961. /**
  24962. * No billboard
  24963. */
  24964. static readonly BILLBOARDMODE_NONE: number;
  24965. /** Billboard on X axis */
  24966. static readonly BILLBOARDMODE_X: number;
  24967. /** Billboard on Y axis */
  24968. static readonly BILLBOARDMODE_Y: number;
  24969. /** Billboard on Z axis */
  24970. static readonly BILLBOARDMODE_Z: number;
  24971. /** Billboard on all axes */
  24972. static readonly BILLBOARDMODE_ALL: number;
  24973. private _internalAbstractMeshDataInfo;
  24974. /**
  24975. * The culling strategy to use to check whether the mesh must be rendered or not.
  24976. * This value can be changed at any time and will be used on the next render mesh selection.
  24977. * The possible values are :
  24978. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24979. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24980. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24981. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24982. * Please read each static variable documentation to get details about the culling process.
  24983. * */
  24984. cullingStrategy: number;
  24985. /**
  24986. * Gets the number of facets in the mesh
  24987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24988. */
  24989. readonly facetNb: number;
  24990. /**
  24991. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24992. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24993. */
  24994. partitioningSubdivisions: number;
  24995. /**
  24996. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24997. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24999. */
  25000. partitioningBBoxRatio: number;
  25001. /**
  25002. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25003. * Works only for updatable meshes.
  25004. * Doesn't work with multi-materials
  25005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25006. */
  25007. mustDepthSortFacets: boolean;
  25008. /**
  25009. * The location (Vector3) where the facet depth sort must be computed from.
  25010. * By default, the active camera position.
  25011. * Used only when facet depth sort is enabled
  25012. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25013. */
  25014. facetDepthSortFrom: Vector3;
  25015. /**
  25016. * gets a boolean indicating if facetData is enabled
  25017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25018. */
  25019. readonly isFacetDataEnabled: boolean;
  25020. /** @hidden */
  25021. _updateNonUniformScalingState(value: boolean): boolean;
  25022. /**
  25023. * An event triggered when this mesh collides with another one
  25024. */
  25025. onCollideObservable: Observable<AbstractMesh>;
  25026. /** Set a function to call when this mesh collides with another one */
  25027. onCollide: () => void;
  25028. /**
  25029. * An event triggered when the collision's position changes
  25030. */
  25031. onCollisionPositionChangeObservable: Observable<Vector3>;
  25032. /** Set a function to call when the collision's position changes */
  25033. onCollisionPositionChange: () => void;
  25034. /**
  25035. * An event triggered when material is changed
  25036. */
  25037. onMaterialChangedObservable: Observable<AbstractMesh>;
  25038. /**
  25039. * Gets or sets the orientation for POV movement & rotation
  25040. */
  25041. definedFacingForward: boolean;
  25042. /** @hidden */
  25043. _occlusionQuery: Nullable<WebGLQuery>;
  25044. /** @hidden */
  25045. _isActive: boolean;
  25046. /** @hidden */
  25047. _onlyForInstances: boolean;
  25048. /** @hidden */
  25049. _renderingGroup: Nullable<RenderingGroup>;
  25050. /**
  25051. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25052. */
  25053. /**
  25054. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25055. */
  25056. visibility: number;
  25057. /** Gets or sets the alpha index used to sort transparent meshes
  25058. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25059. */
  25060. alphaIndex: number;
  25061. /**
  25062. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25063. */
  25064. isVisible: boolean;
  25065. /**
  25066. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25067. */
  25068. isPickable: boolean;
  25069. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25070. showSubMeshesBoundingBox: boolean;
  25071. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25072. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25073. */
  25074. isBlocker: boolean;
  25075. /**
  25076. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25077. */
  25078. enablePointerMoveEvents: boolean;
  25079. /**
  25080. * Specifies the rendering group id for this mesh (0 by default)
  25081. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25082. */
  25083. renderingGroupId: number;
  25084. private _material;
  25085. /** Gets or sets current material */
  25086. material: Nullable<Material>;
  25087. /**
  25088. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25089. * @see http://doc.babylonjs.com/babylon101/shadows
  25090. */
  25091. receiveShadows: boolean;
  25092. /** Defines color to use when rendering outline */
  25093. outlineColor: Color3;
  25094. /** Define width to use when rendering outline */
  25095. outlineWidth: number;
  25096. /** Defines color to use when rendering overlay */
  25097. overlayColor: Color3;
  25098. /** Defines alpha to use when rendering overlay */
  25099. overlayAlpha: number;
  25100. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25101. hasVertexAlpha: boolean;
  25102. /** 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) */
  25103. useVertexColors: boolean;
  25104. /**
  25105. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25106. */
  25107. computeBonesUsingShaders: boolean;
  25108. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25109. numBoneInfluencers: number;
  25110. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25111. applyFog: boolean;
  25112. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25113. useOctreeForRenderingSelection: boolean;
  25114. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25115. useOctreeForPicking: boolean;
  25116. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25117. useOctreeForCollisions: boolean;
  25118. /**
  25119. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25120. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25121. */
  25122. layerMask: number;
  25123. /**
  25124. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25125. */
  25126. alwaysSelectAsActiveMesh: boolean;
  25127. /**
  25128. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25129. */
  25130. doNotSyncBoundingInfo: boolean;
  25131. /**
  25132. * Gets or sets the current action manager
  25133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25134. */
  25135. actionManager: Nullable<AbstractActionManager>;
  25136. private _meshCollisionData;
  25137. /**
  25138. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25140. */
  25141. ellipsoid: Vector3;
  25142. /**
  25143. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25145. */
  25146. ellipsoidOffset: Vector3;
  25147. /**
  25148. * Gets or sets a collision mask used to mask collisions (default is -1).
  25149. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25150. */
  25151. collisionMask: number;
  25152. /**
  25153. * Gets or sets the current collision group mask (-1 by default).
  25154. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25155. */
  25156. collisionGroup: number;
  25157. /**
  25158. * Defines edge width used when edgesRenderer is enabled
  25159. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25160. */
  25161. edgesWidth: number;
  25162. /**
  25163. * Defines edge color used when edgesRenderer is enabled
  25164. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25165. */
  25166. edgesColor: Color4;
  25167. /** @hidden */
  25168. _edgesRenderer: Nullable<IEdgesRenderer>;
  25169. /** @hidden */
  25170. _masterMesh: Nullable<AbstractMesh>;
  25171. /** @hidden */
  25172. _boundingInfo: Nullable<BoundingInfo>;
  25173. /** @hidden */
  25174. _renderId: number;
  25175. /**
  25176. * Gets or sets the list of subMeshes
  25177. * @see http://doc.babylonjs.com/how_to/multi_materials
  25178. */
  25179. subMeshes: SubMesh[];
  25180. /** @hidden */
  25181. _intersectionsInProgress: AbstractMesh[];
  25182. /** @hidden */
  25183. _unIndexed: boolean;
  25184. /** @hidden */
  25185. _lightSources: Light[];
  25186. /** Gets the list of lights affecting that mesh */
  25187. readonly lightSources: Light[];
  25188. /** @hidden */
  25189. readonly _positions: Nullable<Vector3[]>;
  25190. /** @hidden */
  25191. _waitingData: {
  25192. lods: Nullable<any>;
  25193. actions: Nullable<any>;
  25194. freezeWorldMatrix: Nullable<boolean>;
  25195. };
  25196. /** @hidden */
  25197. _bonesTransformMatrices: Nullable<Float32Array>;
  25198. /**
  25199. * Gets or sets a skeleton to apply skining transformations
  25200. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25201. */
  25202. skeleton: Nullable<Skeleton>;
  25203. /**
  25204. * An event triggered when the mesh is rebuilt.
  25205. */
  25206. onRebuildObservable: Observable<AbstractMesh>;
  25207. /**
  25208. * Creates a new AbstractMesh
  25209. * @param name defines the name of the mesh
  25210. * @param scene defines the hosting scene
  25211. */
  25212. constructor(name: string, scene?: Nullable<Scene>);
  25213. /**
  25214. * Returns the string "AbstractMesh"
  25215. * @returns "AbstractMesh"
  25216. */
  25217. getClassName(): string;
  25218. /**
  25219. * Gets a string representation of the current mesh
  25220. * @param fullDetails defines a boolean indicating if full details must be included
  25221. * @returns a string representation of the current mesh
  25222. */
  25223. toString(fullDetails?: boolean): string;
  25224. /**
  25225. * @hidden
  25226. */
  25227. protected _getEffectiveParent(): Nullable<Node>;
  25228. /** @hidden */
  25229. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25230. /** @hidden */
  25231. _rebuild(): void;
  25232. /** @hidden */
  25233. _resyncLightSources(): void;
  25234. /** @hidden */
  25235. _resyncLighSource(light: Light): void;
  25236. /** @hidden */
  25237. _unBindEffect(): void;
  25238. /** @hidden */
  25239. _removeLightSource(light: Light): void;
  25240. private _markSubMeshesAsDirty;
  25241. /** @hidden */
  25242. _markSubMeshesAsLightDirty(): void;
  25243. /** @hidden */
  25244. _markSubMeshesAsAttributesDirty(): void;
  25245. /** @hidden */
  25246. _markSubMeshesAsMiscDirty(): void;
  25247. /**
  25248. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25249. */
  25250. scaling: Vector3;
  25251. /**
  25252. * Returns true if the mesh is blocked. Implemented by child classes
  25253. */
  25254. readonly isBlocked: boolean;
  25255. /**
  25256. * Returns the mesh itself by default. Implemented by child classes
  25257. * @param camera defines the camera to use to pick the right LOD level
  25258. * @returns the currentAbstractMesh
  25259. */
  25260. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25261. /**
  25262. * Returns 0 by default. Implemented by child classes
  25263. * @returns an integer
  25264. */
  25265. getTotalVertices(): number;
  25266. /**
  25267. * Returns a positive integer : the total number of indices in this mesh geometry.
  25268. * @returns the numner of indices or zero if the mesh has no geometry.
  25269. */
  25270. getTotalIndices(): number;
  25271. /**
  25272. * Returns null by default. Implemented by child classes
  25273. * @returns null
  25274. */
  25275. getIndices(): Nullable<IndicesArray>;
  25276. /**
  25277. * Returns the array of the requested vertex data kind. Implemented by child classes
  25278. * @param kind defines the vertex data kind to use
  25279. * @returns null
  25280. */
  25281. getVerticesData(kind: string): Nullable<FloatArray>;
  25282. /**
  25283. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25284. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25285. * Note that a new underlying VertexBuffer object is created each call.
  25286. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25287. * @param kind defines vertex data kind:
  25288. * * VertexBuffer.PositionKind
  25289. * * VertexBuffer.UVKind
  25290. * * VertexBuffer.UV2Kind
  25291. * * VertexBuffer.UV3Kind
  25292. * * VertexBuffer.UV4Kind
  25293. * * VertexBuffer.UV5Kind
  25294. * * VertexBuffer.UV6Kind
  25295. * * VertexBuffer.ColorKind
  25296. * * VertexBuffer.MatricesIndicesKind
  25297. * * VertexBuffer.MatricesIndicesExtraKind
  25298. * * VertexBuffer.MatricesWeightsKind
  25299. * * VertexBuffer.MatricesWeightsExtraKind
  25300. * @param data defines the data source
  25301. * @param updatable defines if the data must be flagged as updatable (or static)
  25302. * @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
  25303. * @returns the current mesh
  25304. */
  25305. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25306. /**
  25307. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25308. * If the mesh has no geometry, it is simply returned as it is.
  25309. * @param kind defines vertex data kind:
  25310. * * VertexBuffer.PositionKind
  25311. * * VertexBuffer.UVKind
  25312. * * VertexBuffer.UV2Kind
  25313. * * VertexBuffer.UV3Kind
  25314. * * VertexBuffer.UV4Kind
  25315. * * VertexBuffer.UV5Kind
  25316. * * VertexBuffer.UV6Kind
  25317. * * VertexBuffer.ColorKind
  25318. * * VertexBuffer.MatricesIndicesKind
  25319. * * VertexBuffer.MatricesIndicesExtraKind
  25320. * * VertexBuffer.MatricesWeightsKind
  25321. * * VertexBuffer.MatricesWeightsExtraKind
  25322. * @param data defines the data source
  25323. * @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
  25324. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25325. * @returns the current mesh
  25326. */
  25327. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25328. /**
  25329. * Sets the mesh indices,
  25330. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25331. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25332. * @param totalVertices Defines the total number of vertices
  25333. * @returns the current mesh
  25334. */
  25335. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25336. /**
  25337. * Gets a boolean indicating if specific vertex data is present
  25338. * @param kind defines the vertex data kind to use
  25339. * @returns true is data kind is present
  25340. */
  25341. isVerticesDataPresent(kind: string): boolean;
  25342. /**
  25343. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25344. * @returns a BoundingInfo
  25345. */
  25346. getBoundingInfo(): BoundingInfo;
  25347. /**
  25348. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25349. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25350. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25351. * @returns the current mesh
  25352. */
  25353. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25354. /**
  25355. * Overwrite the current bounding info
  25356. * @param boundingInfo defines the new bounding info
  25357. * @returns the current mesh
  25358. */
  25359. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25360. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25361. readonly useBones: boolean;
  25362. /** @hidden */
  25363. _preActivate(): void;
  25364. /** @hidden */
  25365. _preActivateForIntermediateRendering(renderId: number): void;
  25366. /** @hidden */
  25367. _activate(renderId: number): boolean;
  25368. /** @hidden */
  25369. _postActivate(): void;
  25370. /** @hidden */
  25371. _freeze(): void;
  25372. /** @hidden */
  25373. _unFreeze(): void;
  25374. /**
  25375. * Gets the current world matrix
  25376. * @returns a Matrix
  25377. */
  25378. getWorldMatrix(): Matrix;
  25379. /** @hidden */
  25380. _getWorldMatrixDeterminant(): number;
  25381. /**
  25382. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25383. */
  25384. readonly isAnInstance: boolean;
  25385. /**
  25386. * Perform relative position change from the point of view of behind the front of the mesh.
  25387. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25388. * Supports definition of mesh facing forward or backward
  25389. * @param amountRight defines the distance on the right axis
  25390. * @param amountUp defines the distance on the up axis
  25391. * @param amountForward defines the distance on the forward axis
  25392. * @returns the current mesh
  25393. */
  25394. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25395. /**
  25396. * Calculate relative position change from the point of view of behind the front of the mesh.
  25397. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25398. * Supports definition of mesh facing forward or backward
  25399. * @param amountRight defines the distance on the right axis
  25400. * @param amountUp defines the distance on the up axis
  25401. * @param amountForward defines the distance on the forward axis
  25402. * @returns the new displacement vector
  25403. */
  25404. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25405. /**
  25406. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25407. * Supports definition of mesh facing forward or backward
  25408. * @param flipBack defines the flip
  25409. * @param twirlClockwise defines the twirl
  25410. * @param tiltRight defines the tilt
  25411. * @returns the current mesh
  25412. */
  25413. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25414. /**
  25415. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25416. * Supports definition of mesh facing forward or backward.
  25417. * @param flipBack defines the flip
  25418. * @param twirlClockwise defines the twirl
  25419. * @param tiltRight defines the tilt
  25420. * @returns the new rotation vector
  25421. */
  25422. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25423. /**
  25424. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25425. * This means the mesh underlying bounding box and sphere are recomputed.
  25426. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25427. * @returns the current mesh
  25428. */
  25429. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25430. /** @hidden */
  25431. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25432. /** @hidden */
  25433. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25434. /** @hidden */
  25435. _updateBoundingInfo(): AbstractMesh;
  25436. /** @hidden */
  25437. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25438. /** @hidden */
  25439. protected _afterComputeWorldMatrix(): void;
  25440. /** @hidden */
  25441. readonly _effectiveMesh: AbstractMesh;
  25442. /**
  25443. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25444. * A mesh is in the frustum if its bounding box intersects the frustum
  25445. * @param frustumPlanes defines the frustum to test
  25446. * @returns true if the mesh is in the frustum planes
  25447. */
  25448. isInFrustum(frustumPlanes: Plane[]): boolean;
  25449. /**
  25450. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25451. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25452. * @param frustumPlanes defines the frustum to test
  25453. * @returns true if the mesh is completely in the frustum planes
  25454. */
  25455. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25456. /**
  25457. * True if the mesh intersects another mesh or a SolidParticle object
  25458. * @param mesh defines a target mesh or SolidParticle to test
  25459. * @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)
  25460. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25461. * @returns true if there is an intersection
  25462. */
  25463. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25464. /**
  25465. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25466. * @param point defines the point to test
  25467. * @returns true if there is an intersection
  25468. */
  25469. intersectsPoint(point: Vector3): boolean;
  25470. /**
  25471. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25472. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25473. */
  25474. checkCollisions: boolean;
  25475. /**
  25476. * Gets Collider object used to compute collisions (not physics)
  25477. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25478. */
  25479. readonly collider: Nullable<Collider>;
  25480. /**
  25481. * Move the mesh using collision engine
  25482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25483. * @param displacement defines the requested displacement vector
  25484. * @returns the current mesh
  25485. */
  25486. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25487. private _onCollisionPositionChange;
  25488. /** @hidden */
  25489. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25490. /** @hidden */
  25491. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25492. /** @hidden */
  25493. _checkCollision(collider: Collider): AbstractMesh;
  25494. /** @hidden */
  25495. _generatePointsArray(): boolean;
  25496. /**
  25497. * Checks if the passed Ray intersects with the mesh
  25498. * @param ray defines the ray to use
  25499. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25500. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25501. * @returns the picking info
  25502. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25503. */
  25504. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25505. /**
  25506. * Clones the current mesh
  25507. * @param name defines the mesh name
  25508. * @param newParent defines the new mesh parent
  25509. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25510. * @returns the new mesh
  25511. */
  25512. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25513. /**
  25514. * Disposes all the submeshes of the current meshnp
  25515. * @returns the current mesh
  25516. */
  25517. releaseSubMeshes(): AbstractMesh;
  25518. /**
  25519. * Releases resources associated with this abstract mesh.
  25520. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25521. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25522. */
  25523. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25524. /**
  25525. * Adds the passed mesh as a child to the current mesh
  25526. * @param mesh defines the child mesh
  25527. * @returns the current mesh
  25528. */
  25529. addChild(mesh: AbstractMesh): AbstractMesh;
  25530. /**
  25531. * Removes the passed mesh from the current mesh children list
  25532. * @param mesh defines the child mesh
  25533. * @returns the current mesh
  25534. */
  25535. removeChild(mesh: AbstractMesh): AbstractMesh;
  25536. /** @hidden */
  25537. private _initFacetData;
  25538. /**
  25539. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25540. * This method can be called within the render loop.
  25541. * 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
  25542. * @returns the current mesh
  25543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25544. */
  25545. updateFacetData(): AbstractMesh;
  25546. /**
  25547. * Returns the facetLocalNormals array.
  25548. * The normals are expressed in the mesh local spac
  25549. * @returns an array of Vector3
  25550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25551. */
  25552. getFacetLocalNormals(): Vector3[];
  25553. /**
  25554. * Returns the facetLocalPositions array.
  25555. * The facet positions are expressed in the mesh local space
  25556. * @returns an array of Vector3
  25557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25558. */
  25559. getFacetLocalPositions(): Vector3[];
  25560. /**
  25561. * Returns the facetLocalPartioning array
  25562. * @returns an array of array of numbers
  25563. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25564. */
  25565. getFacetLocalPartitioning(): number[][];
  25566. /**
  25567. * Returns the i-th facet position in the world system.
  25568. * This method allocates a new Vector3 per call
  25569. * @param i defines the facet index
  25570. * @returns a new Vector3
  25571. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25572. */
  25573. getFacetPosition(i: number): Vector3;
  25574. /**
  25575. * Sets the reference Vector3 with the i-th facet position in the world system
  25576. * @param i defines the facet index
  25577. * @param ref defines the target vector
  25578. * @returns the current mesh
  25579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25580. */
  25581. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25582. /**
  25583. * Returns the i-th facet normal in the world system.
  25584. * This method allocates a new Vector3 per call
  25585. * @param i defines the facet index
  25586. * @returns a new Vector3
  25587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25588. */
  25589. getFacetNormal(i: number): Vector3;
  25590. /**
  25591. * Sets the reference Vector3 with the i-th facet normal in the world system
  25592. * @param i defines the facet index
  25593. * @param ref defines the target vector
  25594. * @returns the current mesh
  25595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25596. */
  25597. getFacetNormalToRef(i: number, ref: Vector3): this;
  25598. /**
  25599. * 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)
  25600. * @param x defines x coordinate
  25601. * @param y defines y coordinate
  25602. * @param z defines z coordinate
  25603. * @returns the array of facet indexes
  25604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25605. */
  25606. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25607. /**
  25608. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25609. * @param projected sets as the (x,y,z) world projection on the facet
  25610. * @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
  25611. * @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
  25612. * @param x defines x coordinate
  25613. * @param y defines y coordinate
  25614. * @param z defines z coordinate
  25615. * @returns the face index if found (or null instead)
  25616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25617. */
  25618. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25619. /**
  25620. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25621. * @param projected sets as the (x,y,z) local projection on the facet
  25622. * @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
  25623. * @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
  25624. * @param x defines x coordinate
  25625. * @param y defines y coordinate
  25626. * @param z defines z coordinate
  25627. * @returns the face index if found (or null instead)
  25628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25629. */
  25630. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25631. /**
  25632. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25633. * @returns the parameters
  25634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25635. */
  25636. getFacetDataParameters(): any;
  25637. /**
  25638. * Disables the feature FacetData and frees the related memory
  25639. * @returns the current mesh
  25640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25641. */
  25642. disableFacetData(): AbstractMesh;
  25643. /**
  25644. * Updates the AbstractMesh indices array
  25645. * @param indices defines the data source
  25646. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25647. * @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)
  25648. * @returns the current mesh
  25649. */
  25650. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25651. /**
  25652. * Creates new normals data for the mesh
  25653. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25654. * @returns the current mesh
  25655. */
  25656. createNormals(updatable: boolean): AbstractMesh;
  25657. /**
  25658. * Align the mesh with a normal
  25659. * @param normal defines the normal to use
  25660. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25661. * @returns the current mesh
  25662. */
  25663. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25664. /** @hidden */
  25665. _checkOcclusionQuery(): boolean;
  25666. }
  25667. }
  25668. declare module "babylonjs/Actions/actionEvent" {
  25669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25670. import { Nullable } from "babylonjs/types";
  25671. import { Sprite } from "babylonjs/Sprites/sprite";
  25672. import { Scene } from "babylonjs/scene";
  25673. import { Vector2 } from "babylonjs/Maths/math";
  25674. /**
  25675. * Interface used to define ActionEvent
  25676. */
  25677. export interface IActionEvent {
  25678. /** The mesh or sprite that triggered the action */
  25679. source: any;
  25680. /** The X mouse cursor position at the time of the event */
  25681. pointerX: number;
  25682. /** The Y mouse cursor position at the time of the event */
  25683. pointerY: number;
  25684. /** The mesh that is currently pointed at (can be null) */
  25685. meshUnderPointer: Nullable<AbstractMesh>;
  25686. /** the original (browser) event that triggered the ActionEvent */
  25687. sourceEvent?: any;
  25688. /** additional data for the event */
  25689. additionalData?: any;
  25690. }
  25691. /**
  25692. * ActionEvent is the event being sent when an action is triggered.
  25693. */
  25694. export class ActionEvent implements IActionEvent {
  25695. /** The mesh or sprite that triggered the action */
  25696. source: any;
  25697. /** The X mouse cursor position at the time of the event */
  25698. pointerX: number;
  25699. /** The Y mouse cursor position at the time of the event */
  25700. pointerY: number;
  25701. /** The mesh that is currently pointed at (can be null) */
  25702. meshUnderPointer: Nullable<AbstractMesh>;
  25703. /** the original (browser) event that triggered the ActionEvent */
  25704. sourceEvent?: any;
  25705. /** additional data for the event */
  25706. additionalData?: any;
  25707. /**
  25708. * Creates a new ActionEvent
  25709. * @param source The mesh or sprite that triggered the action
  25710. * @param pointerX The X mouse cursor position at the time of the event
  25711. * @param pointerY The Y mouse cursor position at the time of the event
  25712. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25713. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25714. * @param additionalData additional data for the event
  25715. */
  25716. constructor(
  25717. /** The mesh or sprite that triggered the action */
  25718. source: any,
  25719. /** The X mouse cursor position at the time of the event */
  25720. pointerX: number,
  25721. /** The Y mouse cursor position at the time of the event */
  25722. pointerY: number,
  25723. /** The mesh that is currently pointed at (can be null) */
  25724. meshUnderPointer: Nullable<AbstractMesh>,
  25725. /** the original (browser) event that triggered the ActionEvent */
  25726. sourceEvent?: any,
  25727. /** additional data for the event */
  25728. additionalData?: any);
  25729. /**
  25730. * Helper function to auto-create an ActionEvent from a source mesh.
  25731. * @param source The source mesh that triggered the event
  25732. * @param evt The original (browser) event
  25733. * @param additionalData additional data for the event
  25734. * @returns the new ActionEvent
  25735. */
  25736. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25737. /**
  25738. * Helper function to auto-create an ActionEvent from a source sprite
  25739. * @param source The source sprite that triggered the event
  25740. * @param scene Scene associated with the sprite
  25741. * @param evt The original (browser) event
  25742. * @param additionalData additional data for the event
  25743. * @returns the new ActionEvent
  25744. */
  25745. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25746. /**
  25747. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25748. * @param scene the scene where the event occurred
  25749. * @param evt The original (browser) event
  25750. * @returns the new ActionEvent
  25751. */
  25752. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25753. /**
  25754. * Helper function to auto-create an ActionEvent from a primitive
  25755. * @param prim defines the target primitive
  25756. * @param pointerPos defines the pointer position
  25757. * @param evt The original (browser) event
  25758. * @param additionalData additional data for the event
  25759. * @returns the new ActionEvent
  25760. */
  25761. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25762. }
  25763. }
  25764. declare module "babylonjs/Actions/abstractActionManager" {
  25765. import { IDisposable } from "babylonjs/scene";
  25766. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25767. import { IAction } from "babylonjs/Actions/action";
  25768. import { Nullable } from "babylonjs/types";
  25769. /**
  25770. * Abstract class used to decouple action Manager from scene and meshes.
  25771. * Do not instantiate.
  25772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25773. */
  25774. export abstract class AbstractActionManager implements IDisposable {
  25775. /** Gets the list of active triggers */
  25776. static Triggers: {
  25777. [key: string]: number;
  25778. };
  25779. /** Gets the cursor to use when hovering items */
  25780. hoverCursor: string;
  25781. /** Gets the list of actions */
  25782. actions: IAction[];
  25783. /**
  25784. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25785. */
  25786. isRecursive: boolean;
  25787. /**
  25788. * Releases all associated resources
  25789. */
  25790. abstract dispose(): void;
  25791. /**
  25792. * Does this action manager has pointer triggers
  25793. */
  25794. abstract readonly hasPointerTriggers: boolean;
  25795. /**
  25796. * Does this action manager has pick triggers
  25797. */
  25798. abstract readonly hasPickTriggers: boolean;
  25799. /**
  25800. * Process a specific trigger
  25801. * @param trigger defines the trigger to process
  25802. * @param evt defines the event details to be processed
  25803. */
  25804. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25805. /**
  25806. * Does this action manager handles actions of any of the given triggers
  25807. * @param triggers defines the triggers to be tested
  25808. * @return a boolean indicating whether one (or more) of the triggers is handled
  25809. */
  25810. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25811. /**
  25812. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25813. * speed.
  25814. * @param triggerA defines the trigger to be tested
  25815. * @param triggerB defines the trigger to be tested
  25816. * @return a boolean indicating whether one (or more) of the triggers is handled
  25817. */
  25818. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25819. /**
  25820. * Does this action manager handles actions of a given trigger
  25821. * @param trigger defines the trigger to be tested
  25822. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25823. * @return whether the trigger is handled
  25824. */
  25825. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25826. /**
  25827. * Serialize this manager to a JSON object
  25828. * @param name defines the property name to store this manager
  25829. * @returns a JSON representation of this manager
  25830. */
  25831. abstract serialize(name: string): any;
  25832. /**
  25833. * Registers an action to this action manager
  25834. * @param action defines the action to be registered
  25835. * @return the action amended (prepared) after registration
  25836. */
  25837. abstract registerAction(action: IAction): Nullable<IAction>;
  25838. /**
  25839. * Unregisters an action to this action manager
  25840. * @param action defines the action to be unregistered
  25841. * @return a boolean indicating whether the action has been unregistered
  25842. */
  25843. abstract unregisterAction(action: IAction): Boolean;
  25844. /**
  25845. * Does exist one action manager with at least one trigger
  25846. **/
  25847. static readonly HasTriggers: boolean;
  25848. /**
  25849. * Does exist one action manager with at least one pick trigger
  25850. **/
  25851. static readonly HasPickTriggers: boolean;
  25852. /**
  25853. * Does exist one action manager that handles actions of a given trigger
  25854. * @param trigger defines the trigger to be tested
  25855. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25856. **/
  25857. static HasSpecificTrigger(trigger: number): boolean;
  25858. }
  25859. }
  25860. declare module "babylonjs/node" {
  25861. import { Scene } from "babylonjs/scene";
  25862. import { Nullable } from "babylonjs/types";
  25863. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25864. import { Engine } from "babylonjs/Engines/engine";
  25865. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25866. import { Observable } from "babylonjs/Misc/observable";
  25867. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25868. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25869. import { Animatable } from "babylonjs/Animations/animatable";
  25870. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25871. import { Animation } from "babylonjs/Animations/animation";
  25872. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25874. /**
  25875. * Defines how a node can be built from a string name.
  25876. */
  25877. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25878. /**
  25879. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25880. */
  25881. export class Node implements IBehaviorAware<Node> {
  25882. /** @hidden */
  25883. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25884. private static _NodeConstructors;
  25885. /**
  25886. * Add a new node constructor
  25887. * @param type defines the type name of the node to construct
  25888. * @param constructorFunc defines the constructor function
  25889. */
  25890. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25891. /**
  25892. * Returns a node constructor based on type name
  25893. * @param type defines the type name
  25894. * @param name defines the new node name
  25895. * @param scene defines the hosting scene
  25896. * @param options defines optional options to transmit to constructors
  25897. * @returns the new constructor or null
  25898. */
  25899. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25900. /**
  25901. * Gets or sets the name of the node
  25902. */
  25903. name: string;
  25904. /**
  25905. * Gets or sets the id of the node
  25906. */
  25907. id: string;
  25908. /**
  25909. * Gets or sets the unique id of the node
  25910. */
  25911. uniqueId: number;
  25912. /**
  25913. * Gets or sets a string used to store user defined state for the node
  25914. */
  25915. state: string;
  25916. /**
  25917. * Gets or sets an object used to store user defined information for the node
  25918. */
  25919. metadata: any;
  25920. /**
  25921. * For internal use only. Please do not use.
  25922. */
  25923. reservedDataStore: any;
  25924. /**
  25925. * List of inspectable custom properties (used by the Inspector)
  25926. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25927. */
  25928. inspectableCustomProperties: IInspectable[];
  25929. /**
  25930. * Gets or sets a boolean used to define if the node must be serialized
  25931. */
  25932. doNotSerialize: boolean;
  25933. /** @hidden */
  25934. _isDisposed: boolean;
  25935. /**
  25936. * Gets a list of Animations associated with the node
  25937. */
  25938. animations: import("babylonjs/Animations/animation").Animation[];
  25939. protected _ranges: {
  25940. [name: string]: Nullable<AnimationRange>;
  25941. };
  25942. /**
  25943. * Callback raised when the node is ready to be used
  25944. */
  25945. onReady: Nullable<(node: Node) => void>;
  25946. private _isEnabled;
  25947. private _isParentEnabled;
  25948. private _isReady;
  25949. /** @hidden */
  25950. _currentRenderId: number;
  25951. private _parentUpdateId;
  25952. /** @hidden */
  25953. _childUpdateId: number;
  25954. /** @hidden */
  25955. _waitingParentId: Nullable<string>;
  25956. /** @hidden */
  25957. _scene: Scene;
  25958. /** @hidden */
  25959. _cache: any;
  25960. private _parentNode;
  25961. private _children;
  25962. /** @hidden */
  25963. _worldMatrix: Matrix;
  25964. /** @hidden */
  25965. _worldMatrixDeterminant: number;
  25966. /** @hidden */
  25967. _worldMatrixDeterminantIsDirty: boolean;
  25968. /** @hidden */
  25969. private _sceneRootNodesIndex;
  25970. /**
  25971. * Gets a boolean indicating if the node has been disposed
  25972. * @returns true if the node was disposed
  25973. */
  25974. isDisposed(): boolean;
  25975. /**
  25976. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25977. * @see https://doc.babylonjs.com/how_to/parenting
  25978. */
  25979. parent: Nullable<Node>;
  25980. private addToSceneRootNodes;
  25981. private removeFromSceneRootNodes;
  25982. private _animationPropertiesOverride;
  25983. /**
  25984. * Gets or sets the animation properties override
  25985. */
  25986. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25987. /**
  25988. * Gets a string idenfifying the name of the class
  25989. * @returns "Node" string
  25990. */
  25991. getClassName(): string;
  25992. /** @hidden */
  25993. readonly _isNode: boolean;
  25994. /**
  25995. * An event triggered when the mesh is disposed
  25996. */
  25997. onDisposeObservable: Observable<Node>;
  25998. private _onDisposeObserver;
  25999. /**
  26000. * Sets a callback that will be raised when the node will be disposed
  26001. */
  26002. onDispose: () => void;
  26003. /**
  26004. * Creates a new Node
  26005. * @param name the name and id to be given to this node
  26006. * @param scene the scene this node will be added to
  26007. * @param addToRootNodes the node will be added to scene.rootNodes
  26008. */
  26009. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26010. /**
  26011. * Gets the scene of the node
  26012. * @returns a scene
  26013. */
  26014. getScene(): Scene;
  26015. /**
  26016. * Gets the engine of the node
  26017. * @returns a Engine
  26018. */
  26019. getEngine(): Engine;
  26020. private _behaviors;
  26021. /**
  26022. * Attach a behavior to the node
  26023. * @see http://doc.babylonjs.com/features/behaviour
  26024. * @param behavior defines the behavior to attach
  26025. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26026. * @returns the current Node
  26027. */
  26028. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26029. /**
  26030. * Remove an attached behavior
  26031. * @see http://doc.babylonjs.com/features/behaviour
  26032. * @param behavior defines the behavior to attach
  26033. * @returns the current Node
  26034. */
  26035. removeBehavior(behavior: Behavior<Node>): Node;
  26036. /**
  26037. * Gets the list of attached behaviors
  26038. * @see http://doc.babylonjs.com/features/behaviour
  26039. */
  26040. readonly behaviors: Behavior<Node>[];
  26041. /**
  26042. * Gets an attached behavior by name
  26043. * @param name defines the name of the behavior to look for
  26044. * @see http://doc.babylonjs.com/features/behaviour
  26045. * @returns null if behavior was not found else the requested behavior
  26046. */
  26047. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26048. /**
  26049. * Returns the latest update of the World matrix
  26050. * @returns a Matrix
  26051. */
  26052. getWorldMatrix(): Matrix;
  26053. /** @hidden */
  26054. _getWorldMatrixDeterminant(): number;
  26055. /**
  26056. * Returns directly the latest state of the mesh World matrix.
  26057. * A Matrix is returned.
  26058. */
  26059. readonly worldMatrixFromCache: Matrix;
  26060. /** @hidden */
  26061. _initCache(): void;
  26062. /** @hidden */
  26063. updateCache(force?: boolean): void;
  26064. /** @hidden */
  26065. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26066. /** @hidden */
  26067. _updateCache(ignoreParentClass?: boolean): void;
  26068. /** @hidden */
  26069. _isSynchronized(): boolean;
  26070. /** @hidden */
  26071. _markSyncedWithParent(): void;
  26072. /** @hidden */
  26073. isSynchronizedWithParent(): boolean;
  26074. /** @hidden */
  26075. isSynchronized(): boolean;
  26076. /**
  26077. * Is this node ready to be used/rendered
  26078. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26079. * @return true if the node is ready
  26080. */
  26081. isReady(completeCheck?: boolean): boolean;
  26082. /**
  26083. * Is this node enabled?
  26084. * 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
  26085. * @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
  26086. * @return whether this node (and its parent) is enabled
  26087. */
  26088. isEnabled(checkAncestors?: boolean): boolean;
  26089. /** @hidden */
  26090. protected _syncParentEnabledState(): void;
  26091. /**
  26092. * Set the enabled state of this node
  26093. * @param value defines the new enabled state
  26094. */
  26095. setEnabled(value: boolean): void;
  26096. /**
  26097. * Is this node a descendant of the given node?
  26098. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26099. * @param ancestor defines the parent node to inspect
  26100. * @returns a boolean indicating if this node is a descendant of the given node
  26101. */
  26102. isDescendantOf(ancestor: Node): boolean;
  26103. /** @hidden */
  26104. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26105. /**
  26106. * Will return all nodes that have this node as ascendant
  26107. * @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
  26108. * @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
  26109. * @return all children nodes of all types
  26110. */
  26111. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26112. /**
  26113. * Get all child-meshes of this node
  26114. * @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)
  26115. * @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
  26116. * @returns an array of AbstractMesh
  26117. */
  26118. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26119. /**
  26120. * Get all direct children of this node
  26121. * @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
  26122. * @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)
  26123. * @returns an array of Node
  26124. */
  26125. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26126. /** @hidden */
  26127. _setReady(state: boolean): void;
  26128. /**
  26129. * Get an animation by name
  26130. * @param name defines the name of the animation to look for
  26131. * @returns null if not found else the requested animation
  26132. */
  26133. getAnimationByName(name: string): Nullable<Animation>;
  26134. /**
  26135. * Creates an animation range for this node
  26136. * @param name defines the name of the range
  26137. * @param from defines the starting key
  26138. * @param to defines the end key
  26139. */
  26140. createAnimationRange(name: string, from: number, to: number): void;
  26141. /**
  26142. * Delete a specific animation range
  26143. * @param name defines the name of the range to delete
  26144. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26145. */
  26146. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26147. /**
  26148. * Get an animation range by name
  26149. * @param name defines the name of the animation range to look for
  26150. * @returns null if not found else the requested animation range
  26151. */
  26152. getAnimationRange(name: string): Nullable<AnimationRange>;
  26153. /**
  26154. * Gets the list of all animation ranges defined on this node
  26155. * @returns an array
  26156. */
  26157. getAnimationRanges(): Nullable<AnimationRange>[];
  26158. /**
  26159. * Will start the animation sequence
  26160. * @param name defines the range frames for animation sequence
  26161. * @param loop defines if the animation should loop (false by default)
  26162. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26163. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26164. * @returns the object created for this animation. If range does not exist, it will return null
  26165. */
  26166. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26167. /**
  26168. * Serialize animation ranges into a JSON compatible object
  26169. * @returns serialization object
  26170. */
  26171. serializeAnimationRanges(): any;
  26172. /**
  26173. * Computes the world matrix of the node
  26174. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26175. * @returns the world matrix
  26176. */
  26177. computeWorldMatrix(force?: boolean): Matrix;
  26178. /**
  26179. * Releases resources associated with this node.
  26180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26182. */
  26183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26184. /**
  26185. * Parse animation range data from a serialization object and store them into a given node
  26186. * @param node defines where to store the animation ranges
  26187. * @param parsedNode defines the serialization object to read data from
  26188. * @param scene defines the hosting scene
  26189. */
  26190. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26191. /**
  26192. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26193. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26194. * @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
  26195. * @returns the new bounding vectors
  26196. */
  26197. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26198. min: Vector3;
  26199. max: Vector3;
  26200. };
  26201. }
  26202. }
  26203. declare module "babylonjs/Animations/animation" {
  26204. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26205. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26206. import { Nullable } from "babylonjs/types";
  26207. import { Scene } from "babylonjs/scene";
  26208. import { IAnimatable } from "babylonjs/Misc/tools";
  26209. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26210. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26211. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26212. import { Node } from "babylonjs/node";
  26213. import { Animatable } from "babylonjs/Animations/animatable";
  26214. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26215. /**
  26216. * @hidden
  26217. */
  26218. export class _IAnimationState {
  26219. key: number;
  26220. repeatCount: number;
  26221. workValue?: any;
  26222. loopMode?: number;
  26223. offsetValue?: any;
  26224. highLimitValue?: any;
  26225. }
  26226. /**
  26227. * Class used to store any kind of animation
  26228. */
  26229. export class Animation {
  26230. /**Name of the animation */
  26231. name: string;
  26232. /**Property to animate */
  26233. targetProperty: string;
  26234. /**The frames per second of the animation */
  26235. framePerSecond: number;
  26236. /**The data type of the animation */
  26237. dataType: number;
  26238. /**The loop mode of the animation */
  26239. loopMode?: number | undefined;
  26240. /**Specifies if blending should be enabled */
  26241. enableBlending?: boolean | undefined;
  26242. /**
  26243. * Use matrix interpolation instead of using direct key value when animating matrices
  26244. */
  26245. static AllowMatricesInterpolation: boolean;
  26246. /**
  26247. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26248. */
  26249. static AllowMatrixDecomposeForInterpolation: boolean;
  26250. /**
  26251. * Stores the key frames of the animation
  26252. */
  26253. private _keys;
  26254. /**
  26255. * Stores the easing function of the animation
  26256. */
  26257. private _easingFunction;
  26258. /**
  26259. * @hidden Internal use only
  26260. */
  26261. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26262. /**
  26263. * The set of event that will be linked to this animation
  26264. */
  26265. private _events;
  26266. /**
  26267. * Stores an array of target property paths
  26268. */
  26269. targetPropertyPath: string[];
  26270. /**
  26271. * Stores the blending speed of the animation
  26272. */
  26273. blendingSpeed: number;
  26274. /**
  26275. * Stores the animation ranges for the animation
  26276. */
  26277. private _ranges;
  26278. /**
  26279. * @hidden Internal use
  26280. */
  26281. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26282. /**
  26283. * Sets up an animation
  26284. * @param property The property to animate
  26285. * @param animationType The animation type to apply
  26286. * @param framePerSecond The frames per second of the animation
  26287. * @param easingFunction The easing function used in the animation
  26288. * @returns The created animation
  26289. */
  26290. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26291. /**
  26292. * Create and start an animation on a node
  26293. * @param name defines the name of the global animation that will be run on all nodes
  26294. * @param node defines the root node where the animation will take place
  26295. * @param targetProperty defines property to animate
  26296. * @param framePerSecond defines the number of frame per second yo use
  26297. * @param totalFrame defines the number of frames in total
  26298. * @param from defines the initial value
  26299. * @param to defines the final value
  26300. * @param loopMode defines which loop mode you want to use (off by default)
  26301. * @param easingFunction defines the easing function to use (linear by default)
  26302. * @param onAnimationEnd defines the callback to call when animation end
  26303. * @returns the animatable created for this animation
  26304. */
  26305. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26306. /**
  26307. * Create and start an animation on a node and its descendants
  26308. * @param name defines the name of the global animation that will be run on all nodes
  26309. * @param node defines the root node where the animation will take place
  26310. * @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
  26311. * @param targetProperty defines property to animate
  26312. * @param framePerSecond defines the number of frame per second to use
  26313. * @param totalFrame defines the number of frames in total
  26314. * @param from defines the initial value
  26315. * @param to defines the final value
  26316. * @param loopMode defines which loop mode you want to use (off by default)
  26317. * @param easingFunction defines the easing function to use (linear by default)
  26318. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26319. * @returns the list of animatables created for all nodes
  26320. * @example https://www.babylonjs-playground.com/#MH0VLI
  26321. */
  26322. 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[]>;
  26323. /**
  26324. * Creates a new animation, merges it with the existing animations and starts it
  26325. * @param name Name of the animation
  26326. * @param node Node which contains the scene that begins the animations
  26327. * @param targetProperty Specifies which property to animate
  26328. * @param framePerSecond The frames per second of the animation
  26329. * @param totalFrame The total number of frames
  26330. * @param from The frame at the beginning of the animation
  26331. * @param to The frame at the end of the animation
  26332. * @param loopMode Specifies the loop mode of the animation
  26333. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26334. * @param onAnimationEnd Callback to run once the animation is complete
  26335. * @returns Nullable animation
  26336. */
  26337. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26338. /**
  26339. * Transition property of an host to the target Value
  26340. * @param property The property to transition
  26341. * @param targetValue The target Value of the property
  26342. * @param host The object where the property to animate belongs
  26343. * @param scene Scene used to run the animation
  26344. * @param frameRate Framerate (in frame/s) to use
  26345. * @param transition The transition type we want to use
  26346. * @param duration The duration of the animation, in milliseconds
  26347. * @param onAnimationEnd Callback trigger at the end of the animation
  26348. * @returns Nullable animation
  26349. */
  26350. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26351. /**
  26352. * Return the array of runtime animations currently using this animation
  26353. */
  26354. readonly runtimeAnimations: RuntimeAnimation[];
  26355. /**
  26356. * Specifies if any of the runtime animations are currently running
  26357. */
  26358. readonly hasRunningRuntimeAnimations: boolean;
  26359. /**
  26360. * Initializes the animation
  26361. * @param name Name of the animation
  26362. * @param targetProperty Property to animate
  26363. * @param framePerSecond The frames per second of the animation
  26364. * @param dataType The data type of the animation
  26365. * @param loopMode The loop mode of the animation
  26366. * @param enableBlending Specifies if blending should be enabled
  26367. */
  26368. constructor(
  26369. /**Name of the animation */
  26370. name: string,
  26371. /**Property to animate */
  26372. targetProperty: string,
  26373. /**The frames per second of the animation */
  26374. framePerSecond: number,
  26375. /**The data type of the animation */
  26376. dataType: number,
  26377. /**The loop mode of the animation */
  26378. loopMode?: number | undefined,
  26379. /**Specifies if blending should be enabled */
  26380. enableBlending?: boolean | undefined);
  26381. /**
  26382. * Converts the animation to a string
  26383. * @param fullDetails support for multiple levels of logging within scene loading
  26384. * @returns String form of the animation
  26385. */
  26386. toString(fullDetails?: boolean): string;
  26387. /**
  26388. * Add an event to this animation
  26389. * @param event Event to add
  26390. */
  26391. addEvent(event: AnimationEvent): void;
  26392. /**
  26393. * Remove all events found at the given frame
  26394. * @param frame The frame to remove events from
  26395. */
  26396. removeEvents(frame: number): void;
  26397. /**
  26398. * Retrieves all the events from the animation
  26399. * @returns Events from the animation
  26400. */
  26401. getEvents(): AnimationEvent[];
  26402. /**
  26403. * Creates an animation range
  26404. * @param name Name of the animation range
  26405. * @param from Starting frame of the animation range
  26406. * @param to Ending frame of the animation
  26407. */
  26408. createRange(name: string, from: number, to: number): void;
  26409. /**
  26410. * Deletes an animation range by name
  26411. * @param name Name of the animation range to delete
  26412. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26413. */
  26414. deleteRange(name: string, deleteFrames?: boolean): void;
  26415. /**
  26416. * Gets the animation range by name, or null if not defined
  26417. * @param name Name of the animation range
  26418. * @returns Nullable animation range
  26419. */
  26420. getRange(name: string): Nullable<AnimationRange>;
  26421. /**
  26422. * Gets the key frames from the animation
  26423. * @returns The key frames of the animation
  26424. */
  26425. getKeys(): Array<IAnimationKey>;
  26426. /**
  26427. * Gets the highest frame rate of the animation
  26428. * @returns Highest frame rate of the animation
  26429. */
  26430. getHighestFrame(): number;
  26431. /**
  26432. * Gets the easing function of the animation
  26433. * @returns Easing function of the animation
  26434. */
  26435. getEasingFunction(): IEasingFunction;
  26436. /**
  26437. * Sets the easing function of the animation
  26438. * @param easingFunction A custom mathematical formula for animation
  26439. */
  26440. setEasingFunction(easingFunction: EasingFunction): void;
  26441. /**
  26442. * Interpolates a scalar linearly
  26443. * @param startValue Start value of the animation curve
  26444. * @param endValue End value of the animation curve
  26445. * @param gradient Scalar amount to interpolate
  26446. * @returns Interpolated scalar value
  26447. */
  26448. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26449. /**
  26450. * Interpolates a scalar cubically
  26451. * @param startValue Start value of the animation curve
  26452. * @param outTangent End tangent of the animation
  26453. * @param endValue End value of the animation curve
  26454. * @param inTangent Start tangent of the animation curve
  26455. * @param gradient Scalar amount to interpolate
  26456. * @returns Interpolated scalar value
  26457. */
  26458. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26459. /**
  26460. * Interpolates a quaternion using a spherical linear interpolation
  26461. * @param startValue Start value of the animation curve
  26462. * @param endValue End value of the animation curve
  26463. * @param gradient Scalar amount to interpolate
  26464. * @returns Interpolated quaternion value
  26465. */
  26466. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26467. /**
  26468. * Interpolates a quaternion cubically
  26469. * @param startValue Start value of the animation curve
  26470. * @param outTangent End tangent of the animation curve
  26471. * @param endValue End value of the animation curve
  26472. * @param inTangent Start tangent of the animation curve
  26473. * @param gradient Scalar amount to interpolate
  26474. * @returns Interpolated quaternion value
  26475. */
  26476. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26477. /**
  26478. * Interpolates a Vector3 linearl
  26479. * @param startValue Start value of the animation curve
  26480. * @param endValue End value of the animation curve
  26481. * @param gradient Scalar amount to interpolate
  26482. * @returns Interpolated scalar value
  26483. */
  26484. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26485. /**
  26486. * Interpolates a Vector3 cubically
  26487. * @param startValue Start value of the animation curve
  26488. * @param outTangent End tangent of the animation
  26489. * @param endValue End value of the animation curve
  26490. * @param inTangent Start tangent of the animation curve
  26491. * @param gradient Scalar amount to interpolate
  26492. * @returns InterpolatedVector3 value
  26493. */
  26494. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26495. /**
  26496. * Interpolates a Vector2 linearly
  26497. * @param startValue Start value of the animation curve
  26498. * @param endValue End value of the animation curve
  26499. * @param gradient Scalar amount to interpolate
  26500. * @returns Interpolated Vector2 value
  26501. */
  26502. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26503. /**
  26504. * Interpolates a Vector2 cubically
  26505. * @param startValue Start value of the animation curve
  26506. * @param outTangent End tangent of the animation
  26507. * @param endValue End value of the animation curve
  26508. * @param inTangent Start tangent of the animation curve
  26509. * @param gradient Scalar amount to interpolate
  26510. * @returns Interpolated Vector2 value
  26511. */
  26512. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26513. /**
  26514. * Interpolates a size linearly
  26515. * @param startValue Start value of the animation curve
  26516. * @param endValue End value of the animation curve
  26517. * @param gradient Scalar amount to interpolate
  26518. * @returns Interpolated Size value
  26519. */
  26520. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26521. /**
  26522. * Interpolates a Color3 linearly
  26523. * @param startValue Start value of the animation curve
  26524. * @param endValue End value of the animation curve
  26525. * @param gradient Scalar amount to interpolate
  26526. * @returns Interpolated Color3 value
  26527. */
  26528. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26529. /**
  26530. * @hidden Internal use only
  26531. */
  26532. _getKeyValue(value: any): any;
  26533. /**
  26534. * @hidden Internal use only
  26535. */
  26536. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26537. /**
  26538. * Defines the function to use to interpolate matrices
  26539. * @param startValue defines the start matrix
  26540. * @param endValue defines the end matrix
  26541. * @param gradient defines the gradient between both matrices
  26542. * @param result defines an optional target matrix where to store the interpolation
  26543. * @returns the interpolated matrix
  26544. */
  26545. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26546. /**
  26547. * Makes a copy of the animation
  26548. * @returns Cloned animation
  26549. */
  26550. clone(): Animation;
  26551. /**
  26552. * Sets the key frames of the animation
  26553. * @param values The animation key frames to set
  26554. */
  26555. setKeys(values: Array<IAnimationKey>): void;
  26556. /**
  26557. * Serializes the animation to an object
  26558. * @returns Serialized object
  26559. */
  26560. serialize(): any;
  26561. /**
  26562. * Float animation type
  26563. */
  26564. private static _ANIMATIONTYPE_FLOAT;
  26565. /**
  26566. * Vector3 animation type
  26567. */
  26568. private static _ANIMATIONTYPE_VECTOR3;
  26569. /**
  26570. * Quaternion animation type
  26571. */
  26572. private static _ANIMATIONTYPE_QUATERNION;
  26573. /**
  26574. * Matrix animation type
  26575. */
  26576. private static _ANIMATIONTYPE_MATRIX;
  26577. /**
  26578. * Color3 animation type
  26579. */
  26580. private static _ANIMATIONTYPE_COLOR3;
  26581. /**
  26582. * Vector2 animation type
  26583. */
  26584. private static _ANIMATIONTYPE_VECTOR2;
  26585. /**
  26586. * Size animation type
  26587. */
  26588. private static _ANIMATIONTYPE_SIZE;
  26589. /**
  26590. * Relative Loop Mode
  26591. */
  26592. private static _ANIMATIONLOOPMODE_RELATIVE;
  26593. /**
  26594. * Cycle Loop Mode
  26595. */
  26596. private static _ANIMATIONLOOPMODE_CYCLE;
  26597. /**
  26598. * Constant Loop Mode
  26599. */
  26600. private static _ANIMATIONLOOPMODE_CONSTANT;
  26601. /**
  26602. * Get the float animation type
  26603. */
  26604. static readonly ANIMATIONTYPE_FLOAT: number;
  26605. /**
  26606. * Get the Vector3 animation type
  26607. */
  26608. static readonly ANIMATIONTYPE_VECTOR3: number;
  26609. /**
  26610. * Get the Vector2 animation type
  26611. */
  26612. static readonly ANIMATIONTYPE_VECTOR2: number;
  26613. /**
  26614. * Get the Size animation type
  26615. */
  26616. static readonly ANIMATIONTYPE_SIZE: number;
  26617. /**
  26618. * Get the Quaternion animation type
  26619. */
  26620. static readonly ANIMATIONTYPE_QUATERNION: number;
  26621. /**
  26622. * Get the Matrix animation type
  26623. */
  26624. static readonly ANIMATIONTYPE_MATRIX: number;
  26625. /**
  26626. * Get the Color3 animation type
  26627. */
  26628. static readonly ANIMATIONTYPE_COLOR3: number;
  26629. /**
  26630. * Get the Relative Loop Mode
  26631. */
  26632. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26633. /**
  26634. * Get the Cycle Loop Mode
  26635. */
  26636. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26637. /**
  26638. * Get the Constant Loop Mode
  26639. */
  26640. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26641. /** @hidden */
  26642. static _UniversalLerp(left: any, right: any, amount: number): any;
  26643. /**
  26644. * Parses an animation object and creates an animation
  26645. * @param parsedAnimation Parsed animation object
  26646. * @returns Animation object
  26647. */
  26648. static Parse(parsedAnimation: any): Animation;
  26649. /**
  26650. * Appends the serialized animations from the source animations
  26651. * @param source Source containing the animations
  26652. * @param destination Target to store the animations
  26653. */
  26654. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26655. }
  26656. }
  26657. declare module "babylonjs/Materials/Textures/baseTexture" {
  26658. import { Observable } from "babylonjs/Misc/observable";
  26659. import { IAnimatable } from "babylonjs/Misc/tools";
  26660. import { Nullable } from "babylonjs/types";
  26661. import { Scene } from "babylonjs/scene";
  26662. import { Matrix, ISize } from "babylonjs/Maths/math";
  26663. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26665. /**
  26666. * Base class of all the textures in babylon.
  26667. * It groups all the common properties the materials, post process, lights... might need
  26668. * in order to make a correct use of the texture.
  26669. */
  26670. export class BaseTexture implements IAnimatable {
  26671. /**
  26672. * Default anisotropic filtering level for the application.
  26673. * It is set to 4 as a good tradeoff between perf and quality.
  26674. */
  26675. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26676. /**
  26677. * Gets or sets the unique id of the texture
  26678. */
  26679. uniqueId: number;
  26680. /**
  26681. * Define the name of the texture.
  26682. */
  26683. name: string;
  26684. /**
  26685. * Gets or sets an object used to store user defined information.
  26686. */
  26687. metadata: any;
  26688. /**
  26689. * For internal use only. Please do not use.
  26690. */
  26691. reservedDataStore: any;
  26692. private _hasAlpha;
  26693. /**
  26694. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26695. */
  26696. hasAlpha: boolean;
  26697. /**
  26698. * Defines if the alpha value should be determined via the rgb values.
  26699. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26700. */
  26701. getAlphaFromRGB: boolean;
  26702. /**
  26703. * Intensity or strength of the texture.
  26704. * It is commonly used by materials to fine tune the intensity of the texture
  26705. */
  26706. level: number;
  26707. /**
  26708. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26709. * This is part of the texture as textures usually maps to one uv set.
  26710. */
  26711. coordinatesIndex: number;
  26712. private _coordinatesMode;
  26713. /**
  26714. * How a texture is mapped.
  26715. *
  26716. * | Value | Type | Description |
  26717. * | ----- | ----------------------------------- | ----------- |
  26718. * | 0 | EXPLICIT_MODE | |
  26719. * | 1 | SPHERICAL_MODE | |
  26720. * | 2 | PLANAR_MODE | |
  26721. * | 3 | CUBIC_MODE | |
  26722. * | 4 | PROJECTION_MODE | |
  26723. * | 5 | SKYBOX_MODE | |
  26724. * | 6 | INVCUBIC_MODE | |
  26725. * | 7 | EQUIRECTANGULAR_MODE | |
  26726. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26727. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26728. */
  26729. coordinatesMode: number;
  26730. /**
  26731. * | Value | Type | Description |
  26732. * | ----- | ------------------ | ----------- |
  26733. * | 0 | CLAMP_ADDRESSMODE | |
  26734. * | 1 | WRAP_ADDRESSMODE | |
  26735. * | 2 | MIRROR_ADDRESSMODE | |
  26736. */
  26737. wrapU: number;
  26738. /**
  26739. * | Value | Type | Description |
  26740. * | ----- | ------------------ | ----------- |
  26741. * | 0 | CLAMP_ADDRESSMODE | |
  26742. * | 1 | WRAP_ADDRESSMODE | |
  26743. * | 2 | MIRROR_ADDRESSMODE | |
  26744. */
  26745. wrapV: number;
  26746. /**
  26747. * | Value | Type | Description |
  26748. * | ----- | ------------------ | ----------- |
  26749. * | 0 | CLAMP_ADDRESSMODE | |
  26750. * | 1 | WRAP_ADDRESSMODE | |
  26751. * | 2 | MIRROR_ADDRESSMODE | |
  26752. */
  26753. wrapR: number;
  26754. /**
  26755. * With compliant hardware and browser (supporting anisotropic filtering)
  26756. * this defines the level of anisotropic filtering in the texture.
  26757. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26758. */
  26759. anisotropicFilteringLevel: number;
  26760. /**
  26761. * Define if the texture is a cube texture or if false a 2d texture.
  26762. */
  26763. isCube: boolean;
  26764. /**
  26765. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26766. */
  26767. is3D: boolean;
  26768. /**
  26769. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26770. * HDR texture are usually stored in linear space.
  26771. * This only impacts the PBR and Background materials
  26772. */
  26773. gammaSpace: boolean;
  26774. /**
  26775. * Gets whether or not the texture contains RGBD data.
  26776. */
  26777. readonly isRGBD: boolean;
  26778. /**
  26779. * Is Z inverted in the texture (useful in a cube texture).
  26780. */
  26781. invertZ: boolean;
  26782. /**
  26783. * Are mip maps generated for this texture or not.
  26784. */
  26785. readonly noMipmap: boolean;
  26786. /**
  26787. * @hidden
  26788. */
  26789. lodLevelInAlpha: boolean;
  26790. /**
  26791. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26792. */
  26793. lodGenerationOffset: number;
  26794. /**
  26795. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26796. */
  26797. lodGenerationScale: number;
  26798. /**
  26799. * Define if the texture is a render target.
  26800. */
  26801. isRenderTarget: boolean;
  26802. /**
  26803. * Define the unique id of the texture in the scene.
  26804. */
  26805. readonly uid: string;
  26806. /**
  26807. * Return a string representation of the texture.
  26808. * @returns the texture as a string
  26809. */
  26810. toString(): string;
  26811. /**
  26812. * Get the class name of the texture.
  26813. * @returns "BaseTexture"
  26814. */
  26815. getClassName(): string;
  26816. /**
  26817. * Define the list of animation attached to the texture.
  26818. */
  26819. animations: import("babylonjs/Animations/animation").Animation[];
  26820. /**
  26821. * An event triggered when the texture is disposed.
  26822. */
  26823. onDisposeObservable: Observable<BaseTexture>;
  26824. private _onDisposeObserver;
  26825. /**
  26826. * Callback triggered when the texture has been disposed.
  26827. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26828. */
  26829. onDispose: () => void;
  26830. /**
  26831. * Define the current state of the loading sequence when in delayed load mode.
  26832. */
  26833. delayLoadState: number;
  26834. private _scene;
  26835. /** @hidden */
  26836. _texture: Nullable<InternalTexture>;
  26837. private _uid;
  26838. /**
  26839. * Define if the texture is preventinga material to render or not.
  26840. * If not and the texture is not ready, the engine will use a default black texture instead.
  26841. */
  26842. readonly isBlocking: boolean;
  26843. /**
  26844. * Instantiates a new BaseTexture.
  26845. * Base class of all the textures in babylon.
  26846. * It groups all the common properties the materials, post process, lights... might need
  26847. * in order to make a correct use of the texture.
  26848. * @param scene Define the scene the texture blongs to
  26849. */
  26850. constructor(scene: Nullable<Scene>);
  26851. /**
  26852. * Get the scene the texture belongs to.
  26853. * @returns the scene or null if undefined
  26854. */
  26855. getScene(): Nullable<Scene>;
  26856. /**
  26857. * Get the texture transform matrix used to offset tile the texture for istance.
  26858. * @returns the transformation matrix
  26859. */
  26860. getTextureMatrix(): Matrix;
  26861. /**
  26862. * Get the texture reflection matrix used to rotate/transform the reflection.
  26863. * @returns the reflection matrix
  26864. */
  26865. getReflectionTextureMatrix(): Matrix;
  26866. /**
  26867. * Get the underlying lower level texture from Babylon.
  26868. * @returns the insternal texture
  26869. */
  26870. getInternalTexture(): Nullable<InternalTexture>;
  26871. /**
  26872. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26873. * @returns true if ready or not blocking
  26874. */
  26875. isReadyOrNotBlocking(): boolean;
  26876. /**
  26877. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26878. * @returns true if fully ready
  26879. */
  26880. isReady(): boolean;
  26881. private _cachedSize;
  26882. /**
  26883. * Get the size of the texture.
  26884. * @returns the texture size.
  26885. */
  26886. getSize(): ISize;
  26887. /**
  26888. * Get the base size of the texture.
  26889. * It can be different from the size if the texture has been resized for POT for instance
  26890. * @returns the base size
  26891. */
  26892. getBaseSize(): ISize;
  26893. /**
  26894. * Update the sampling mode of the texture.
  26895. * Default is Trilinear mode.
  26896. *
  26897. * | Value | Type | Description |
  26898. * | ----- | ------------------ | ----------- |
  26899. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26900. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26901. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26902. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26903. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26904. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26905. * | 7 | NEAREST_LINEAR | |
  26906. * | 8 | NEAREST_NEAREST | |
  26907. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26908. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26909. * | 11 | LINEAR_LINEAR | |
  26910. * | 12 | LINEAR_NEAREST | |
  26911. *
  26912. * > _mag_: magnification filter (close to the viewer)
  26913. * > _min_: minification filter (far from the viewer)
  26914. * > _mip_: filter used between mip map levels
  26915. *@param samplingMode Define the new sampling mode of the texture
  26916. */
  26917. updateSamplingMode(samplingMode: number): void;
  26918. /**
  26919. * Scales the texture if is `canRescale()`
  26920. * @param ratio the resize factor we want to use to rescale
  26921. */
  26922. scale(ratio: number): void;
  26923. /**
  26924. * Get if the texture can rescale.
  26925. */
  26926. readonly canRescale: boolean;
  26927. /** @hidden */
  26928. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26929. /** @hidden */
  26930. _rebuild(): void;
  26931. /**
  26932. * Triggers the load sequence in delayed load mode.
  26933. */
  26934. delayLoad(): void;
  26935. /**
  26936. * Clones the texture.
  26937. * @returns the cloned texture
  26938. */
  26939. clone(): Nullable<BaseTexture>;
  26940. /**
  26941. * Get the texture underlying type (INT, FLOAT...)
  26942. */
  26943. readonly textureType: number;
  26944. /**
  26945. * Get the texture underlying format (RGB, RGBA...)
  26946. */
  26947. readonly textureFormat: number;
  26948. /**
  26949. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26950. * This will returns an RGBA array buffer containing either in values (0-255) or
  26951. * float values (0-1) depending of the underlying buffer type.
  26952. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26953. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26954. * @param buffer defines a user defined buffer to fill with data (can be null)
  26955. * @returns The Array buffer containing the pixels data.
  26956. */
  26957. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26958. /**
  26959. * Release and destroy the underlying lower level texture aka internalTexture.
  26960. */
  26961. releaseInternalTexture(): void;
  26962. /**
  26963. * Get the polynomial representation of the texture data.
  26964. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26965. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26966. */
  26967. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26968. /** @hidden */
  26969. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26970. /** @hidden */
  26971. readonly _lodTextureMid: Nullable<BaseTexture>;
  26972. /** @hidden */
  26973. readonly _lodTextureLow: Nullable<BaseTexture>;
  26974. /**
  26975. * Dispose the texture and release its associated resources.
  26976. */
  26977. dispose(): void;
  26978. /**
  26979. * Serialize the texture into a JSON representation that can be parsed later on.
  26980. * @returns the JSON representation of the texture
  26981. */
  26982. serialize(): any;
  26983. /**
  26984. * Helper function to be called back once a list of texture contains only ready textures.
  26985. * @param textures Define the list of textures to wait for
  26986. * @param callback Define the callback triggered once the entire list will be ready
  26987. */
  26988. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26989. }
  26990. }
  26991. declare module "babylonjs/Materials/uniformBuffer" {
  26992. import { Nullable, FloatArray } from "babylonjs/types";
  26993. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26994. import { Engine } from "babylonjs/Engines/engine";
  26995. import { Effect } from "babylonjs/Materials/effect";
  26996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26997. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26998. /**
  26999. * Uniform buffer objects.
  27000. *
  27001. * Handles blocks of uniform on the GPU.
  27002. *
  27003. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27004. *
  27005. * For more information, please refer to :
  27006. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27007. */
  27008. export class UniformBuffer {
  27009. private _engine;
  27010. private _buffer;
  27011. private _data;
  27012. private _bufferData;
  27013. private _dynamic?;
  27014. private _uniformLocations;
  27015. private _uniformSizes;
  27016. private _uniformLocationPointer;
  27017. private _needSync;
  27018. private _noUBO;
  27019. private _currentEffect;
  27020. private static _MAX_UNIFORM_SIZE;
  27021. private static _tempBuffer;
  27022. /**
  27023. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27024. * This is dynamic to allow compat with webgl 1 and 2.
  27025. * You will need to pass the name of the uniform as well as the value.
  27026. */
  27027. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27028. /**
  27029. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27030. * This is dynamic to allow compat with webgl 1 and 2.
  27031. * You will need to pass the name of the uniform as well as the value.
  27032. */
  27033. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27034. /**
  27035. * Lambda to Update a single float in a uniform buffer.
  27036. * This is dynamic to allow compat with webgl 1 and 2.
  27037. * You will need to pass the name of the uniform as well as the value.
  27038. */
  27039. updateFloat: (name: string, x: number) => void;
  27040. /**
  27041. * Lambda to Update a vec2 of float in a uniform buffer.
  27042. * This is dynamic to allow compat with webgl 1 and 2.
  27043. * You will need to pass the name of the uniform as well as the value.
  27044. */
  27045. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27046. /**
  27047. * Lambda to Update a vec3 of float in a uniform buffer.
  27048. * This is dynamic to allow compat with webgl 1 and 2.
  27049. * You will need to pass the name of the uniform as well as the value.
  27050. */
  27051. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27052. /**
  27053. * Lambda to Update a vec4 of float in a uniform buffer.
  27054. * This is dynamic to allow compat with webgl 1 and 2.
  27055. * You will need to pass the name of the uniform as well as the value.
  27056. */
  27057. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27058. /**
  27059. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27060. * This is dynamic to allow compat with webgl 1 and 2.
  27061. * You will need to pass the name of the uniform as well as the value.
  27062. */
  27063. updateMatrix: (name: string, mat: Matrix) => void;
  27064. /**
  27065. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27066. * This is dynamic to allow compat with webgl 1 and 2.
  27067. * You will need to pass the name of the uniform as well as the value.
  27068. */
  27069. updateVector3: (name: string, vector: Vector3) => void;
  27070. /**
  27071. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27072. * This is dynamic to allow compat with webgl 1 and 2.
  27073. * You will need to pass the name of the uniform as well as the value.
  27074. */
  27075. updateVector4: (name: string, vector: Vector4) => void;
  27076. /**
  27077. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27078. * This is dynamic to allow compat with webgl 1 and 2.
  27079. * You will need to pass the name of the uniform as well as the value.
  27080. */
  27081. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27082. /**
  27083. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27084. * This is dynamic to allow compat with webgl 1 and 2.
  27085. * You will need to pass the name of the uniform as well as the value.
  27086. */
  27087. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27088. /**
  27089. * Instantiates a new Uniform buffer objects.
  27090. *
  27091. * Handles blocks of uniform on the GPU.
  27092. *
  27093. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27094. *
  27095. * For more information, please refer to :
  27096. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27097. * @param engine Define the engine the buffer is associated with
  27098. * @param data Define the data contained in the buffer
  27099. * @param dynamic Define if the buffer is updatable
  27100. */
  27101. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27102. /**
  27103. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27104. * or just falling back on setUniformXXX calls.
  27105. */
  27106. readonly useUbo: boolean;
  27107. /**
  27108. * Indicates if the WebGL underlying uniform buffer is in sync
  27109. * with the javascript cache data.
  27110. */
  27111. readonly isSync: boolean;
  27112. /**
  27113. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27114. * Also, a dynamic UniformBuffer will disable cache verification and always
  27115. * update the underlying WebGL uniform buffer to the GPU.
  27116. * @returns if Dynamic, otherwise false
  27117. */
  27118. isDynamic(): boolean;
  27119. /**
  27120. * The data cache on JS side.
  27121. * @returns the underlying data as a float array
  27122. */
  27123. getData(): Float32Array;
  27124. /**
  27125. * The underlying WebGL Uniform buffer.
  27126. * @returns the webgl buffer
  27127. */
  27128. getBuffer(): Nullable<DataBuffer>;
  27129. /**
  27130. * std140 layout specifies how to align data within an UBO structure.
  27131. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27132. * for specs.
  27133. */
  27134. private _fillAlignment;
  27135. /**
  27136. * Adds an uniform in the buffer.
  27137. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27138. * for the layout to be correct !
  27139. * @param name Name of the uniform, as used in the uniform block in the shader.
  27140. * @param size Data size, or data directly.
  27141. */
  27142. addUniform(name: string, size: number | number[]): void;
  27143. /**
  27144. * Adds a Matrix 4x4 to the uniform buffer.
  27145. * @param name Name of the uniform, as used in the uniform block in the shader.
  27146. * @param mat A 4x4 matrix.
  27147. */
  27148. addMatrix(name: string, mat: Matrix): void;
  27149. /**
  27150. * Adds a vec2 to the uniform buffer.
  27151. * @param name Name of the uniform, as used in the uniform block in the shader.
  27152. * @param x Define the x component value of the vec2
  27153. * @param y Define the y component value of the vec2
  27154. */
  27155. addFloat2(name: string, x: number, y: number): void;
  27156. /**
  27157. * Adds a vec3 to the uniform buffer.
  27158. * @param name Name of the uniform, as used in the uniform block in the shader.
  27159. * @param x Define the x component value of the vec3
  27160. * @param y Define the y component value of the vec3
  27161. * @param z Define the z component value of the vec3
  27162. */
  27163. addFloat3(name: string, x: number, y: number, z: number): void;
  27164. /**
  27165. * Adds a vec3 to the uniform buffer.
  27166. * @param name Name of the uniform, as used in the uniform block in the shader.
  27167. * @param color Define the vec3 from a Color
  27168. */
  27169. addColor3(name: string, color: Color3): void;
  27170. /**
  27171. * Adds a vec4 to the uniform buffer.
  27172. * @param name Name of the uniform, as used in the uniform block in the shader.
  27173. * @param color Define the rgb components from a Color
  27174. * @param alpha Define the a component of the vec4
  27175. */
  27176. addColor4(name: string, color: Color3, alpha: number): void;
  27177. /**
  27178. * Adds a vec3 to the uniform buffer.
  27179. * @param name Name of the uniform, as used in the uniform block in the shader.
  27180. * @param vector Define the vec3 components from a Vector
  27181. */
  27182. addVector3(name: string, vector: Vector3): void;
  27183. /**
  27184. * Adds a Matrix 3x3 to the uniform buffer.
  27185. * @param name Name of the uniform, as used in the uniform block in the shader.
  27186. */
  27187. addMatrix3x3(name: string): void;
  27188. /**
  27189. * Adds a Matrix 2x2 to the uniform buffer.
  27190. * @param name Name of the uniform, as used in the uniform block in the shader.
  27191. */
  27192. addMatrix2x2(name: string): void;
  27193. /**
  27194. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27195. */
  27196. create(): void;
  27197. /** @hidden */
  27198. _rebuild(): void;
  27199. /**
  27200. * Updates the WebGL Uniform Buffer on the GPU.
  27201. * If the `dynamic` flag is set to true, no cache comparison is done.
  27202. * Otherwise, the buffer will be updated only if the cache differs.
  27203. */
  27204. update(): void;
  27205. /**
  27206. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27207. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27208. * @param data Define the flattened data
  27209. * @param size Define the size of the data.
  27210. */
  27211. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27212. private _updateMatrix3x3ForUniform;
  27213. private _updateMatrix3x3ForEffect;
  27214. private _updateMatrix2x2ForEffect;
  27215. private _updateMatrix2x2ForUniform;
  27216. private _updateFloatForEffect;
  27217. private _updateFloatForUniform;
  27218. private _updateFloat2ForEffect;
  27219. private _updateFloat2ForUniform;
  27220. private _updateFloat3ForEffect;
  27221. private _updateFloat3ForUniform;
  27222. private _updateFloat4ForEffect;
  27223. private _updateFloat4ForUniform;
  27224. private _updateMatrixForEffect;
  27225. private _updateMatrixForUniform;
  27226. private _updateVector3ForEffect;
  27227. private _updateVector3ForUniform;
  27228. private _updateVector4ForEffect;
  27229. private _updateVector4ForUniform;
  27230. private _updateColor3ForEffect;
  27231. private _updateColor3ForUniform;
  27232. private _updateColor4ForEffect;
  27233. private _updateColor4ForUniform;
  27234. /**
  27235. * Sets a sampler uniform on the effect.
  27236. * @param name Define the name of the sampler.
  27237. * @param texture Define the texture to set in the sampler
  27238. */
  27239. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27240. /**
  27241. * Directly updates the value of the uniform in the cache AND on the GPU.
  27242. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27243. * @param data Define the flattened data
  27244. */
  27245. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27246. /**
  27247. * Binds this uniform buffer to an effect.
  27248. * @param effect Define the effect to bind the buffer to
  27249. * @param name Name of the uniform block in the shader.
  27250. */
  27251. bindToEffect(effect: Effect, name: string): void;
  27252. /**
  27253. * Disposes the uniform buffer.
  27254. */
  27255. dispose(): void;
  27256. }
  27257. }
  27258. declare module "babylonjs/Audio/analyser" {
  27259. import { Scene } from "babylonjs/scene";
  27260. /**
  27261. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27263. */
  27264. export class Analyser {
  27265. /**
  27266. * Gets or sets the smoothing
  27267. * @ignorenaming
  27268. */
  27269. SMOOTHING: number;
  27270. /**
  27271. * Gets or sets the FFT table size
  27272. * @ignorenaming
  27273. */
  27274. FFT_SIZE: number;
  27275. /**
  27276. * Gets or sets the bar graph amplitude
  27277. * @ignorenaming
  27278. */
  27279. BARGRAPHAMPLITUDE: number;
  27280. /**
  27281. * Gets or sets the position of the debug canvas
  27282. * @ignorenaming
  27283. */
  27284. DEBUGCANVASPOS: {
  27285. x: number;
  27286. y: number;
  27287. };
  27288. /**
  27289. * Gets or sets the debug canvas size
  27290. * @ignorenaming
  27291. */
  27292. DEBUGCANVASSIZE: {
  27293. width: number;
  27294. height: number;
  27295. };
  27296. private _byteFreqs;
  27297. private _byteTime;
  27298. private _floatFreqs;
  27299. private _webAudioAnalyser;
  27300. private _debugCanvas;
  27301. private _debugCanvasContext;
  27302. private _scene;
  27303. private _registerFunc;
  27304. private _audioEngine;
  27305. /**
  27306. * Creates a new analyser
  27307. * @param scene defines hosting scene
  27308. */
  27309. constructor(scene: Scene);
  27310. /**
  27311. * Get the number of data values you will have to play with for the visualization
  27312. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27313. * @returns a number
  27314. */
  27315. getFrequencyBinCount(): number;
  27316. /**
  27317. * Gets the current frequency data as a byte array
  27318. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27319. * @returns a Uint8Array
  27320. */
  27321. getByteFrequencyData(): Uint8Array;
  27322. /**
  27323. * Gets the current waveform as a byte array
  27324. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27325. * @returns a Uint8Array
  27326. */
  27327. getByteTimeDomainData(): Uint8Array;
  27328. /**
  27329. * Gets the current frequency data as a float array
  27330. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27331. * @returns a Float32Array
  27332. */
  27333. getFloatFrequencyData(): Float32Array;
  27334. /**
  27335. * Renders the debug canvas
  27336. */
  27337. drawDebugCanvas(): void;
  27338. /**
  27339. * Stops rendering the debug canvas and removes it
  27340. */
  27341. stopDebugCanvas(): void;
  27342. /**
  27343. * Connects two audio nodes
  27344. * @param inputAudioNode defines first node to connect
  27345. * @param outputAudioNode defines second node to connect
  27346. */
  27347. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27348. /**
  27349. * Releases all associated resources
  27350. */
  27351. dispose(): void;
  27352. }
  27353. }
  27354. declare module "babylonjs/Audio/audioEngine" {
  27355. import { IDisposable } from "babylonjs/scene";
  27356. import { Analyser } from "babylonjs/Audio/analyser";
  27357. import { Nullable } from "babylonjs/types";
  27358. import { Observable } from "babylonjs/Misc/observable";
  27359. /**
  27360. * This represents an audio engine and it is responsible
  27361. * to play, synchronize and analyse sounds throughout the application.
  27362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27363. */
  27364. export interface IAudioEngine extends IDisposable {
  27365. /**
  27366. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27367. */
  27368. readonly canUseWebAudio: boolean;
  27369. /**
  27370. * Gets the current AudioContext if available.
  27371. */
  27372. readonly audioContext: Nullable<AudioContext>;
  27373. /**
  27374. * The master gain node defines the global audio volume of your audio engine.
  27375. */
  27376. readonly masterGain: GainNode;
  27377. /**
  27378. * Gets whether or not mp3 are supported by your browser.
  27379. */
  27380. readonly isMP3supported: boolean;
  27381. /**
  27382. * Gets whether or not ogg are supported by your browser.
  27383. */
  27384. readonly isOGGsupported: boolean;
  27385. /**
  27386. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27387. * @ignoreNaming
  27388. */
  27389. WarnedWebAudioUnsupported: boolean;
  27390. /**
  27391. * Defines if the audio engine relies on a custom unlocked button.
  27392. * In this case, the embedded button will not be displayed.
  27393. */
  27394. useCustomUnlockedButton: boolean;
  27395. /**
  27396. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27397. */
  27398. readonly unlocked: boolean;
  27399. /**
  27400. * Event raised when audio has been unlocked on the browser.
  27401. */
  27402. onAudioUnlockedObservable: Observable<AudioEngine>;
  27403. /**
  27404. * Event raised when audio has been locked on the browser.
  27405. */
  27406. onAudioLockedObservable: Observable<AudioEngine>;
  27407. /**
  27408. * Flags the audio engine in Locked state.
  27409. * This happens due to new browser policies preventing audio to autoplay.
  27410. */
  27411. lock(): void;
  27412. /**
  27413. * Unlocks the audio engine once a user action has been done on the dom.
  27414. * This is helpful to resume play once browser policies have been satisfied.
  27415. */
  27416. unlock(): void;
  27417. }
  27418. /**
  27419. * This represents the default audio engine used in babylon.
  27420. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27422. */
  27423. export class AudioEngine implements IAudioEngine {
  27424. private _audioContext;
  27425. private _audioContextInitialized;
  27426. private _muteButton;
  27427. private _hostElement;
  27428. /**
  27429. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27430. */
  27431. canUseWebAudio: boolean;
  27432. /**
  27433. * The master gain node defines the global audio volume of your audio engine.
  27434. */
  27435. masterGain: GainNode;
  27436. /**
  27437. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27438. * @ignoreNaming
  27439. */
  27440. WarnedWebAudioUnsupported: boolean;
  27441. /**
  27442. * Gets whether or not mp3 are supported by your browser.
  27443. */
  27444. isMP3supported: boolean;
  27445. /**
  27446. * Gets whether or not ogg are supported by your browser.
  27447. */
  27448. isOGGsupported: boolean;
  27449. /**
  27450. * Gets whether audio has been unlocked on the device.
  27451. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27452. * a user interaction has happened.
  27453. */
  27454. unlocked: boolean;
  27455. /**
  27456. * Defines if the audio engine relies on a custom unlocked button.
  27457. * In this case, the embedded button will not be displayed.
  27458. */
  27459. useCustomUnlockedButton: boolean;
  27460. /**
  27461. * Event raised when audio has been unlocked on the browser.
  27462. */
  27463. onAudioUnlockedObservable: Observable<AudioEngine>;
  27464. /**
  27465. * Event raised when audio has been locked on the browser.
  27466. */
  27467. onAudioLockedObservable: Observable<AudioEngine>;
  27468. /**
  27469. * Gets the current AudioContext if available.
  27470. */
  27471. readonly audioContext: Nullable<AudioContext>;
  27472. private _connectedAnalyser;
  27473. /**
  27474. * Instantiates a new audio engine.
  27475. *
  27476. * There should be only one per page as some browsers restrict the number
  27477. * of audio contexts you can create.
  27478. * @param hostElement defines the host element where to display the mute icon if necessary
  27479. */
  27480. constructor(hostElement?: Nullable<HTMLElement>);
  27481. /**
  27482. * Flags the audio engine in Locked state.
  27483. * This happens due to new browser policies preventing audio to autoplay.
  27484. */
  27485. lock(): void;
  27486. /**
  27487. * Unlocks the audio engine once a user action has been done on the dom.
  27488. * This is helpful to resume play once browser policies have been satisfied.
  27489. */
  27490. unlock(): void;
  27491. private _resumeAudioContext;
  27492. private _initializeAudioContext;
  27493. private _tryToRun;
  27494. private _triggerRunningState;
  27495. private _triggerSuspendedState;
  27496. private _displayMuteButton;
  27497. private _moveButtonToTopLeft;
  27498. private _onResize;
  27499. private _hideMuteButton;
  27500. /**
  27501. * Destroy and release the resources associated with the audio ccontext.
  27502. */
  27503. dispose(): void;
  27504. /**
  27505. * Gets the global volume sets on the master gain.
  27506. * @returns the global volume if set or -1 otherwise
  27507. */
  27508. getGlobalVolume(): number;
  27509. /**
  27510. * Sets the global volume of your experience (sets on the master gain).
  27511. * @param newVolume Defines the new global volume of the application
  27512. */
  27513. setGlobalVolume(newVolume: number): void;
  27514. /**
  27515. * Connect the audio engine to an audio analyser allowing some amazing
  27516. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27518. * @param analyser The analyser to connect to the engine
  27519. */
  27520. connectToAnalyser(analyser: Analyser): void;
  27521. }
  27522. }
  27523. declare module "babylonjs/Loading/loadingScreen" {
  27524. /**
  27525. * Interface used to present a loading screen while loading a scene
  27526. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27527. */
  27528. export interface ILoadingScreen {
  27529. /**
  27530. * Function called to display the loading screen
  27531. */
  27532. displayLoadingUI: () => void;
  27533. /**
  27534. * Function called to hide the loading screen
  27535. */
  27536. hideLoadingUI: () => void;
  27537. /**
  27538. * Gets or sets the color to use for the background
  27539. */
  27540. loadingUIBackgroundColor: string;
  27541. /**
  27542. * Gets or sets the text to display while loading
  27543. */
  27544. loadingUIText: string;
  27545. }
  27546. /**
  27547. * Class used for the default loading screen
  27548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27549. */
  27550. export class DefaultLoadingScreen implements ILoadingScreen {
  27551. private _renderingCanvas;
  27552. private _loadingText;
  27553. private _loadingDivBackgroundColor;
  27554. private _loadingDiv;
  27555. private _loadingTextDiv;
  27556. /**
  27557. * Creates a new default loading screen
  27558. * @param _renderingCanvas defines the canvas used to render the scene
  27559. * @param _loadingText defines the default text to display
  27560. * @param _loadingDivBackgroundColor defines the default background color
  27561. */
  27562. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27563. /**
  27564. * Function called to display the loading screen
  27565. */
  27566. displayLoadingUI(): void;
  27567. /**
  27568. * Function called to hide the loading screen
  27569. */
  27570. hideLoadingUI(): void;
  27571. /**
  27572. * Gets or sets the text to display while loading
  27573. */
  27574. loadingUIText: string;
  27575. /**
  27576. * Gets or sets the color to use for the background
  27577. */
  27578. loadingUIBackgroundColor: string;
  27579. private _resizeLoadingUI;
  27580. }
  27581. }
  27582. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27583. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27584. import { Engine } from "babylonjs/Engines/engine";
  27585. import { Nullable } from "babylonjs/types";
  27586. /** @hidden */
  27587. export class WebGLPipelineContext implements IPipelineContext {
  27588. engine: Engine;
  27589. program: Nullable<WebGLProgram>;
  27590. context?: WebGLRenderingContext;
  27591. vertexShader?: WebGLShader;
  27592. fragmentShader?: WebGLShader;
  27593. isParallelCompiled: boolean;
  27594. onCompiled?: () => void;
  27595. transformFeedback?: WebGLTransformFeedback | null;
  27596. readonly isAsync: boolean;
  27597. readonly isReady: boolean;
  27598. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27599. }
  27600. }
  27601. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27602. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27603. /** @hidden */
  27604. export class WebGLDataBuffer extends DataBuffer {
  27605. private _buffer;
  27606. constructor(resource: WebGLBuffer);
  27607. readonly underlyingResource: any;
  27608. }
  27609. }
  27610. declare module "babylonjs/Materials/Textures/videoTexture" {
  27611. import { Observable } from "babylonjs/Misc/observable";
  27612. import { Nullable } from "babylonjs/types";
  27613. import { Scene } from "babylonjs/scene";
  27614. import { Texture } from "babylonjs/Materials/Textures/texture";
  27615. /**
  27616. * Settings for finer control over video usage
  27617. */
  27618. export interface VideoTextureSettings {
  27619. /**
  27620. * Applies `autoplay` to video, if specified
  27621. */
  27622. autoPlay?: boolean;
  27623. /**
  27624. * Applies `loop` to video, if specified
  27625. */
  27626. loop?: boolean;
  27627. /**
  27628. * Automatically updates internal texture from video at every frame in the render loop
  27629. */
  27630. autoUpdateTexture: boolean;
  27631. /**
  27632. * Image src displayed during the video loading or until the user interacts with the video.
  27633. */
  27634. poster?: string;
  27635. }
  27636. /**
  27637. * If you want to display a video in your scene, this is the special texture for that.
  27638. * This special texture works similar to other textures, with the exception of a few parameters.
  27639. * @see https://doc.babylonjs.com/how_to/video_texture
  27640. */
  27641. export class VideoTexture extends Texture {
  27642. /**
  27643. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27644. */
  27645. readonly autoUpdateTexture: boolean;
  27646. /**
  27647. * The video instance used by the texture internally
  27648. */
  27649. readonly video: HTMLVideoElement;
  27650. private _onUserActionRequestedObservable;
  27651. /**
  27652. * Event triggerd when a dom action is required by the user to play the video.
  27653. * This happens due to recent changes in browser policies preventing video to auto start.
  27654. */
  27655. readonly onUserActionRequestedObservable: Observable<Texture>;
  27656. private _generateMipMaps;
  27657. private _engine;
  27658. private _stillImageCaptured;
  27659. private _displayingPosterTexture;
  27660. private _settings;
  27661. private _createInternalTextureOnEvent;
  27662. /**
  27663. * Creates a video texture.
  27664. * If you want to display a video in your scene, this is the special texture for that.
  27665. * This special texture works similar to other textures, with the exception of a few parameters.
  27666. * @see https://doc.babylonjs.com/how_to/video_texture
  27667. * @param name optional name, will detect from video source, if not defined
  27668. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27669. * @param scene is obviously the current scene.
  27670. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27671. * @param invertY is false by default but can be used to invert video on Y axis
  27672. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27673. * @param settings allows finer control over video usage
  27674. */
  27675. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27676. private _getName;
  27677. private _getVideo;
  27678. private _createInternalTexture;
  27679. private reset;
  27680. /**
  27681. * @hidden Internal method to initiate `update`.
  27682. */
  27683. _rebuild(): void;
  27684. /**
  27685. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27686. */
  27687. update(): void;
  27688. /**
  27689. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27690. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27691. */
  27692. updateTexture(isVisible: boolean): void;
  27693. protected _updateInternalTexture: () => void;
  27694. /**
  27695. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27696. * @param url New url.
  27697. */
  27698. updateURL(url: string): void;
  27699. /**
  27700. * Dispose the texture and release its associated resources.
  27701. */
  27702. dispose(): void;
  27703. /**
  27704. * Creates a video texture straight from a stream.
  27705. * @param scene Define the scene the texture should be created in
  27706. * @param stream Define the stream the texture should be created from
  27707. * @returns The created video texture as a promise
  27708. */
  27709. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27710. /**
  27711. * Creates a video texture straight from your WebCam video feed.
  27712. * @param scene Define the scene the texture should be created in
  27713. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27714. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27715. * @returns The created video texture as a promise
  27716. */
  27717. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27718. minWidth: number;
  27719. maxWidth: number;
  27720. minHeight: number;
  27721. maxHeight: number;
  27722. deviceId: string;
  27723. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27724. /**
  27725. * Creates a video texture straight from your WebCam video feed.
  27726. * @param scene Define the scene the texture should be created in
  27727. * @param onReady Define a callback to triggered once the texture will be ready
  27728. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27729. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27730. */
  27731. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27732. minWidth: number;
  27733. maxWidth: number;
  27734. minHeight: number;
  27735. maxHeight: number;
  27736. deviceId: string;
  27737. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27738. }
  27739. }
  27740. declare module "babylonjs/Engines/engine" {
  27741. import { Observable } from "babylonjs/Misc/observable";
  27742. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27743. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27744. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27745. import { Camera } from "babylonjs/Cameras/camera";
  27746. import { Scene } from "babylonjs/scene";
  27747. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27748. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27749. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27750. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27751. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27752. import { Material } from "babylonjs/Materials/material";
  27753. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27754. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27756. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27757. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27758. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27759. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27760. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27761. import { WebRequest } from "babylonjs/Misc/webRequest";
  27762. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27763. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27764. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27765. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27766. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27767. /**
  27768. * Interface for attribute information associated with buffer instanciation
  27769. */
  27770. export class InstancingAttributeInfo {
  27771. /**
  27772. * Index/offset of the attribute in the vertex shader
  27773. */
  27774. index: number;
  27775. /**
  27776. * size of the attribute, 1, 2, 3 or 4
  27777. */
  27778. attributeSize: number;
  27779. /**
  27780. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27781. * default is FLOAT
  27782. */
  27783. attribyteType: number;
  27784. /**
  27785. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27786. */
  27787. normalized: boolean;
  27788. /**
  27789. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27790. */
  27791. offset: number;
  27792. /**
  27793. * Name of the GLSL attribute, for debugging purpose only
  27794. */
  27795. attributeName: string;
  27796. }
  27797. /**
  27798. * Define options used to create a depth texture
  27799. */
  27800. export class DepthTextureCreationOptions {
  27801. /** Specifies whether or not a stencil should be allocated in the texture */
  27802. generateStencil?: boolean;
  27803. /** Specifies whether or not bilinear filtering is enable on the texture */
  27804. bilinearFiltering?: boolean;
  27805. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27806. comparisonFunction?: number;
  27807. /** Specifies if the created texture is a cube texture */
  27808. isCube?: boolean;
  27809. }
  27810. /**
  27811. * Class used to describe the capabilities of the engine relatively to the current browser
  27812. */
  27813. export class EngineCapabilities {
  27814. /** Maximum textures units per fragment shader */
  27815. maxTexturesImageUnits: number;
  27816. /** Maximum texture units per vertex shader */
  27817. maxVertexTextureImageUnits: number;
  27818. /** Maximum textures units in the entire pipeline */
  27819. maxCombinedTexturesImageUnits: number;
  27820. /** Maximum texture size */
  27821. maxTextureSize: number;
  27822. /** Maximum cube texture size */
  27823. maxCubemapTextureSize: number;
  27824. /** Maximum render texture size */
  27825. maxRenderTextureSize: number;
  27826. /** Maximum number of vertex attributes */
  27827. maxVertexAttribs: number;
  27828. /** Maximum number of varyings */
  27829. maxVaryingVectors: number;
  27830. /** Maximum number of uniforms per vertex shader */
  27831. maxVertexUniformVectors: number;
  27832. /** Maximum number of uniforms per fragment shader */
  27833. maxFragmentUniformVectors: number;
  27834. /** Defines if standard derivates (dx/dy) are supported */
  27835. standardDerivatives: boolean;
  27836. /** Defines if s3tc texture compression is supported */
  27837. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27838. /** Defines if pvrtc texture compression is supported */
  27839. pvrtc: any;
  27840. /** Defines if etc1 texture compression is supported */
  27841. etc1: any;
  27842. /** Defines if etc2 texture compression is supported */
  27843. etc2: any;
  27844. /** Defines if astc texture compression is supported */
  27845. astc: any;
  27846. /** Defines if float textures are supported */
  27847. textureFloat: boolean;
  27848. /** Defines if vertex array objects are supported */
  27849. vertexArrayObject: boolean;
  27850. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27851. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27852. /** Gets the maximum level of anisotropy supported */
  27853. maxAnisotropy: number;
  27854. /** Defines if instancing is supported */
  27855. instancedArrays: boolean;
  27856. /** Defines if 32 bits indices are supported */
  27857. uintIndices: boolean;
  27858. /** Defines if high precision shaders are supported */
  27859. highPrecisionShaderSupported: boolean;
  27860. /** Defines if depth reading in the fragment shader is supported */
  27861. fragmentDepthSupported: boolean;
  27862. /** Defines if float texture linear filtering is supported*/
  27863. textureFloatLinearFiltering: boolean;
  27864. /** Defines if rendering to float textures is supported */
  27865. textureFloatRender: boolean;
  27866. /** Defines if half float textures are supported*/
  27867. textureHalfFloat: boolean;
  27868. /** Defines if half float texture linear filtering is supported*/
  27869. textureHalfFloatLinearFiltering: boolean;
  27870. /** Defines if rendering to half float textures is supported */
  27871. textureHalfFloatRender: boolean;
  27872. /** Defines if textureLOD shader command is supported */
  27873. textureLOD: boolean;
  27874. /** Defines if draw buffers extension is supported */
  27875. drawBuffersExtension: boolean;
  27876. /** Defines if depth textures are supported */
  27877. depthTextureExtension: boolean;
  27878. /** Defines if float color buffer are supported */
  27879. colorBufferFloat: boolean;
  27880. /** Gets disjoint timer query extension (null if not supported) */
  27881. timerQuery: EXT_disjoint_timer_query;
  27882. /** Defines if timestamp can be used with timer query */
  27883. canUseTimestampForTimerQuery: boolean;
  27884. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27885. multiview: any;
  27886. /** Function used to let the system compiles shaders in background */
  27887. parallelShaderCompile: {
  27888. COMPLETION_STATUS_KHR: number;
  27889. };
  27890. }
  27891. /** Interface defining initialization parameters for Engine class */
  27892. export interface EngineOptions extends WebGLContextAttributes {
  27893. /**
  27894. * Defines if the engine should no exceed a specified device ratio
  27895. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27896. */
  27897. limitDeviceRatio?: number;
  27898. /**
  27899. * Defines if webvr should be enabled automatically
  27900. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27901. */
  27902. autoEnableWebVR?: boolean;
  27903. /**
  27904. * Defines if webgl2 should be turned off even if supported
  27905. * @see http://doc.babylonjs.com/features/webgl2
  27906. */
  27907. disableWebGL2Support?: boolean;
  27908. /**
  27909. * Defines if webaudio should be initialized as well
  27910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27911. */
  27912. audioEngine?: boolean;
  27913. /**
  27914. * Defines if animations should run using a deterministic lock step
  27915. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27916. */
  27917. deterministicLockstep?: boolean;
  27918. /** Defines the maximum steps to use with deterministic lock step mode */
  27919. lockstepMaxSteps?: number;
  27920. /**
  27921. * Defines that engine should ignore context lost events
  27922. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27923. */
  27924. doNotHandleContextLost?: boolean;
  27925. /**
  27926. * Defines that engine should ignore modifying touch action attribute and style
  27927. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27928. */
  27929. doNotHandleTouchAction?: boolean;
  27930. /**
  27931. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27932. */
  27933. useHighPrecisionFloats?: boolean;
  27934. }
  27935. /**
  27936. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27937. */
  27938. export class Engine {
  27939. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27940. static ExceptionList: ({
  27941. key: string;
  27942. capture: string;
  27943. captureConstraint: number;
  27944. targets: string[];
  27945. } | {
  27946. key: string;
  27947. capture: null;
  27948. captureConstraint: null;
  27949. targets: string[];
  27950. })[];
  27951. /** Gets the list of created engines */
  27952. static readonly Instances: Engine[];
  27953. /**
  27954. * Gets the latest created engine
  27955. */
  27956. static readonly LastCreatedEngine: Nullable<Engine>;
  27957. /**
  27958. * Gets the latest created scene
  27959. */
  27960. static readonly LastCreatedScene: Nullable<Scene>;
  27961. /**
  27962. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27963. * @param flag defines which part of the materials must be marked as dirty
  27964. * @param predicate defines a predicate used to filter which materials should be affected
  27965. */
  27966. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27967. /**
  27968. * Hidden
  27969. */
  27970. static _TextureLoaders: IInternalTextureLoader[];
  27971. /** Defines that alpha blending is disabled */
  27972. static readonly ALPHA_DISABLE: number;
  27973. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27974. static readonly ALPHA_ADD: number;
  27975. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27976. static readonly ALPHA_COMBINE: number;
  27977. /** Defines that alpha blending to DEST - SRC * DEST */
  27978. static readonly ALPHA_SUBTRACT: number;
  27979. /** Defines that alpha blending to SRC * DEST */
  27980. static readonly ALPHA_MULTIPLY: number;
  27981. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27982. static readonly ALPHA_MAXIMIZED: number;
  27983. /** Defines that alpha blending to SRC + DEST */
  27984. static readonly ALPHA_ONEONE: number;
  27985. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27986. static readonly ALPHA_PREMULTIPLIED: number;
  27987. /**
  27988. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27989. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27990. */
  27991. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27992. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27993. static readonly ALPHA_INTERPOLATE: number;
  27994. /**
  27995. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27996. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27997. */
  27998. static readonly ALPHA_SCREENMODE: number;
  27999. /** Defines that the ressource is not delayed*/
  28000. static readonly DELAYLOADSTATE_NONE: number;
  28001. /** Defines that the ressource was successfully delay loaded */
  28002. static readonly DELAYLOADSTATE_LOADED: number;
  28003. /** Defines that the ressource is currently delay loading */
  28004. static readonly DELAYLOADSTATE_LOADING: number;
  28005. /** Defines that the ressource is delayed and has not started loading */
  28006. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28007. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28008. static readonly NEVER: number;
  28009. /** 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 */
  28010. static readonly ALWAYS: number;
  28011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28012. static readonly LESS: number;
  28013. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28014. static readonly EQUAL: number;
  28015. /** 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 */
  28016. static readonly LEQUAL: number;
  28017. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28018. static readonly GREATER: number;
  28019. /** 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 */
  28020. static readonly GEQUAL: number;
  28021. /** 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 */
  28022. static readonly NOTEQUAL: number;
  28023. /** Passed to stencilOperation to specify that stencil value must be kept */
  28024. static readonly KEEP: number;
  28025. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28026. static readonly REPLACE: number;
  28027. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28028. static readonly INCR: number;
  28029. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28030. static readonly DECR: number;
  28031. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28032. static readonly INVERT: number;
  28033. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28034. static readonly INCR_WRAP: number;
  28035. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28036. static readonly DECR_WRAP: number;
  28037. /** Texture is not repeating outside of 0..1 UVs */
  28038. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28039. /** Texture is repeating outside of 0..1 UVs */
  28040. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28041. /** Texture is repeating and mirrored */
  28042. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28043. /** ALPHA */
  28044. static readonly TEXTUREFORMAT_ALPHA: number;
  28045. /** LUMINANCE */
  28046. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28047. /** LUMINANCE_ALPHA */
  28048. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28049. /** RGB */
  28050. static readonly TEXTUREFORMAT_RGB: number;
  28051. /** RGBA */
  28052. static readonly TEXTUREFORMAT_RGBA: number;
  28053. /** RED */
  28054. static readonly TEXTUREFORMAT_RED: number;
  28055. /** RED (2nd reference) */
  28056. static readonly TEXTUREFORMAT_R: number;
  28057. /** RG */
  28058. static readonly TEXTUREFORMAT_RG: number;
  28059. /** RED_INTEGER */
  28060. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28061. /** RED_INTEGER (2nd reference) */
  28062. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28063. /** RG_INTEGER */
  28064. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28065. /** RGB_INTEGER */
  28066. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28067. /** RGBA_INTEGER */
  28068. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28069. /** UNSIGNED_BYTE */
  28070. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28071. /** UNSIGNED_BYTE (2nd reference) */
  28072. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28073. /** FLOAT */
  28074. static readonly TEXTURETYPE_FLOAT: number;
  28075. /** HALF_FLOAT */
  28076. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28077. /** BYTE */
  28078. static readonly TEXTURETYPE_BYTE: number;
  28079. /** SHORT */
  28080. static readonly TEXTURETYPE_SHORT: number;
  28081. /** UNSIGNED_SHORT */
  28082. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28083. /** INT */
  28084. static readonly TEXTURETYPE_INT: number;
  28085. /** UNSIGNED_INT */
  28086. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28087. /** UNSIGNED_SHORT_4_4_4_4 */
  28088. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28089. /** UNSIGNED_SHORT_5_5_5_1 */
  28090. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28091. /** UNSIGNED_SHORT_5_6_5 */
  28092. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28093. /** UNSIGNED_INT_2_10_10_10_REV */
  28094. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28095. /** UNSIGNED_INT_24_8 */
  28096. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28097. /** UNSIGNED_INT_10F_11F_11F_REV */
  28098. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28099. /** UNSIGNED_INT_5_9_9_9_REV */
  28100. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28101. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28102. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28103. /** nearest is mag = nearest and min = nearest and mip = linear */
  28104. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28105. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28106. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28107. /** Trilinear is mag = linear and min = linear and mip = linear */
  28108. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28109. /** nearest is mag = nearest and min = nearest and mip = linear */
  28110. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28111. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28112. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28113. /** Trilinear is mag = linear and min = linear and mip = linear */
  28114. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28115. /** mag = nearest and min = nearest and mip = nearest */
  28116. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28117. /** mag = nearest and min = linear and mip = nearest */
  28118. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28119. /** mag = nearest and min = linear and mip = linear */
  28120. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28121. /** mag = nearest and min = linear and mip = none */
  28122. static readonly TEXTURE_NEAREST_LINEAR: number;
  28123. /** mag = nearest and min = nearest and mip = none */
  28124. static readonly TEXTURE_NEAREST_NEAREST: number;
  28125. /** mag = linear and min = nearest and mip = nearest */
  28126. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28127. /** mag = linear and min = nearest and mip = linear */
  28128. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28129. /** mag = linear and min = linear and mip = none */
  28130. static readonly TEXTURE_LINEAR_LINEAR: number;
  28131. /** mag = linear and min = nearest and mip = none */
  28132. static readonly TEXTURE_LINEAR_NEAREST: number;
  28133. /** Explicit coordinates mode */
  28134. static readonly TEXTURE_EXPLICIT_MODE: number;
  28135. /** Spherical coordinates mode */
  28136. static readonly TEXTURE_SPHERICAL_MODE: number;
  28137. /** Planar coordinates mode */
  28138. static readonly TEXTURE_PLANAR_MODE: number;
  28139. /** Cubic coordinates mode */
  28140. static readonly TEXTURE_CUBIC_MODE: number;
  28141. /** Projection coordinates mode */
  28142. static readonly TEXTURE_PROJECTION_MODE: number;
  28143. /** Skybox coordinates mode */
  28144. static readonly TEXTURE_SKYBOX_MODE: number;
  28145. /** Inverse Cubic coordinates mode */
  28146. static readonly TEXTURE_INVCUBIC_MODE: number;
  28147. /** Equirectangular coordinates mode */
  28148. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28149. /** Equirectangular Fixed coordinates mode */
  28150. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28151. /** Equirectangular Fixed Mirrored coordinates mode */
  28152. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28153. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28154. static readonly SCALEMODE_FLOOR: number;
  28155. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28156. static readonly SCALEMODE_NEAREST: number;
  28157. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28158. static readonly SCALEMODE_CEILING: number;
  28159. /**
  28160. * Returns the current npm package of the sdk
  28161. */
  28162. static readonly NpmPackage: string;
  28163. /**
  28164. * Returns the current version of the framework
  28165. */
  28166. static readonly Version: string;
  28167. /**
  28168. * Returns a string describing the current engine
  28169. */
  28170. readonly description: string;
  28171. /**
  28172. * Gets or sets the epsilon value used by collision engine
  28173. */
  28174. static CollisionsEpsilon: number;
  28175. /**
  28176. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28177. */
  28178. static ShadersRepository: string;
  28179. /**
  28180. * Method called to create the default loading screen.
  28181. * This can be overriden in your own app.
  28182. * @param canvas The rendering canvas element
  28183. * @returns The loading screen
  28184. */
  28185. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28186. /**
  28187. * Method called to create the default rescale post process on each engine.
  28188. */
  28189. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28190. /**
  28191. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28192. */
  28193. forcePOTTextures: boolean;
  28194. /**
  28195. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28196. */
  28197. isFullscreen: boolean;
  28198. /**
  28199. * Gets a boolean indicating if the pointer is currently locked
  28200. */
  28201. isPointerLock: boolean;
  28202. /**
  28203. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28204. */
  28205. cullBackFaces: boolean;
  28206. /**
  28207. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28208. */
  28209. renderEvenInBackground: boolean;
  28210. /**
  28211. * Gets or sets a boolean indicating that cache can be kept between frames
  28212. */
  28213. preventCacheWipeBetweenFrames: boolean;
  28214. /**
  28215. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28216. **/
  28217. enableOfflineSupport: boolean;
  28218. /**
  28219. * 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)
  28220. **/
  28221. disableManifestCheck: boolean;
  28222. /**
  28223. * Gets the list of created scenes
  28224. */
  28225. scenes: Scene[];
  28226. /**
  28227. * Event raised when a new scene is created
  28228. */
  28229. onNewSceneAddedObservable: Observable<Scene>;
  28230. /**
  28231. * Gets the list of created postprocesses
  28232. */
  28233. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28234. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28235. validateShaderPrograms: boolean;
  28236. /**
  28237. * Observable event triggered each time the rendering canvas is resized
  28238. */
  28239. onResizeObservable: Observable<Engine>;
  28240. /**
  28241. * Observable event triggered each time the canvas loses focus
  28242. */
  28243. onCanvasBlurObservable: Observable<Engine>;
  28244. /**
  28245. * Observable event triggered each time the canvas gains focus
  28246. */
  28247. onCanvasFocusObservable: Observable<Engine>;
  28248. /**
  28249. * Observable event triggered each time the canvas receives pointerout event
  28250. */
  28251. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28252. /**
  28253. * Observable event triggered before each texture is initialized
  28254. */
  28255. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28256. /**
  28257. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28258. */
  28259. disableUniformBuffers: boolean;
  28260. /** @hidden */
  28261. _uniformBuffers: UniformBuffer[];
  28262. /**
  28263. * Gets a boolean indicating that the engine supports uniform buffers
  28264. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28265. */
  28266. readonly supportsUniformBuffers: boolean;
  28267. /**
  28268. * Observable raised when the engine begins a new frame
  28269. */
  28270. onBeginFrameObservable: Observable<Engine>;
  28271. /**
  28272. * If set, will be used to request the next animation frame for the render loop
  28273. */
  28274. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28275. /**
  28276. * Observable raised when the engine ends the current frame
  28277. */
  28278. onEndFrameObservable: Observable<Engine>;
  28279. /**
  28280. * Observable raised when the engine is about to compile a shader
  28281. */
  28282. onBeforeShaderCompilationObservable: Observable<Engine>;
  28283. /**
  28284. * Observable raised when the engine has jsut compiled a shader
  28285. */
  28286. onAfterShaderCompilationObservable: Observable<Engine>;
  28287. /** @hidden */
  28288. _gl: WebGLRenderingContext;
  28289. private _renderingCanvas;
  28290. private _windowIsBackground;
  28291. private _webGLVersion;
  28292. protected _highPrecisionShadersAllowed: boolean;
  28293. /** @hidden */
  28294. readonly _shouldUseHighPrecisionShader: boolean;
  28295. /**
  28296. * Gets a boolean indicating that only power of 2 textures are supported
  28297. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28298. */
  28299. readonly needPOTTextures: boolean;
  28300. /** @hidden */
  28301. _badOS: boolean;
  28302. /** @hidden */
  28303. _badDesktopOS: boolean;
  28304. /**
  28305. * Gets the audio engine
  28306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28307. * @ignorenaming
  28308. */
  28309. static audioEngine: IAudioEngine;
  28310. /**
  28311. * Default AudioEngine factory responsible of creating the Audio Engine.
  28312. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28313. */
  28314. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28315. /**
  28316. * Default offline support factory responsible of creating a tool used to store data locally.
  28317. * By default, this will create a Database object if the workload has been embedded.
  28318. */
  28319. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28320. private _onFocus;
  28321. private _onBlur;
  28322. private _onCanvasPointerOut;
  28323. private _onCanvasBlur;
  28324. private _onCanvasFocus;
  28325. private _onFullscreenChange;
  28326. private _onPointerLockChange;
  28327. private _hardwareScalingLevel;
  28328. /** @hidden */
  28329. _caps: EngineCapabilities;
  28330. private _pointerLockRequested;
  28331. private _isStencilEnable;
  28332. private _colorWrite;
  28333. private _loadingScreen;
  28334. /** @hidden */
  28335. _drawCalls: PerfCounter;
  28336. private _glVersion;
  28337. private _glRenderer;
  28338. private _glVendor;
  28339. private _videoTextureSupported;
  28340. private _renderingQueueLaunched;
  28341. private _activeRenderLoops;
  28342. private _deterministicLockstep;
  28343. private _lockstepMaxSteps;
  28344. /**
  28345. * Observable signaled when a context lost event is raised
  28346. */
  28347. onContextLostObservable: Observable<Engine>;
  28348. /**
  28349. * Observable signaled when a context restored event is raised
  28350. */
  28351. onContextRestoredObservable: Observable<Engine>;
  28352. private _onContextLost;
  28353. private _onContextRestored;
  28354. private _contextWasLost;
  28355. /** @hidden */
  28356. _doNotHandleContextLost: boolean;
  28357. /**
  28358. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28360. */
  28361. doNotHandleContextLost: boolean;
  28362. private _performanceMonitor;
  28363. private _fps;
  28364. private _deltaTime;
  28365. /**
  28366. * Turn this value on if you want to pause FPS computation when in background
  28367. */
  28368. disablePerformanceMonitorInBackground: boolean;
  28369. /**
  28370. * Gets the performance monitor attached to this engine
  28371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28372. */
  28373. readonly performanceMonitor: PerformanceMonitor;
  28374. /**
  28375. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28376. */
  28377. disableVertexArrayObjects: boolean;
  28378. /** @hidden */
  28379. protected _depthCullingState: _DepthCullingState;
  28380. /** @hidden */
  28381. protected _stencilState: _StencilState;
  28382. /** @hidden */
  28383. protected _alphaState: _AlphaState;
  28384. /** @hidden */
  28385. protected _alphaMode: number;
  28386. /** @hidden */
  28387. _internalTexturesCache: InternalTexture[];
  28388. /** @hidden */
  28389. protected _activeChannel: number;
  28390. private _currentTextureChannel;
  28391. /** @hidden */
  28392. protected _boundTexturesCache: {
  28393. [key: string]: Nullable<InternalTexture>;
  28394. };
  28395. /** @hidden */
  28396. protected _currentEffect: Nullable<Effect>;
  28397. /** @hidden */
  28398. protected _currentProgram: Nullable<WebGLProgram>;
  28399. private _compiledEffects;
  28400. private _vertexAttribArraysEnabled;
  28401. /** @hidden */
  28402. protected _cachedViewport: Nullable<Viewport>;
  28403. private _cachedVertexArrayObject;
  28404. /** @hidden */
  28405. protected _cachedVertexBuffers: any;
  28406. /** @hidden */
  28407. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28408. /** @hidden */
  28409. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28410. /** @hidden */
  28411. _currentRenderTarget: Nullable<InternalTexture>;
  28412. private _uintIndicesCurrentlySet;
  28413. private _currentBoundBuffer;
  28414. /** @hidden */
  28415. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28416. private _currentBufferPointers;
  28417. private _currentInstanceLocations;
  28418. private _currentInstanceBuffers;
  28419. private _textureUnits;
  28420. /** @hidden */
  28421. _workingCanvas: Nullable<HTMLCanvasElement>;
  28422. /** @hidden */
  28423. _workingContext: Nullable<CanvasRenderingContext2D>;
  28424. private _rescalePostProcess;
  28425. private _dummyFramebuffer;
  28426. private _externalData;
  28427. /** @hidden */
  28428. _bindedRenderFunction: any;
  28429. private _vaoRecordInProgress;
  28430. private _mustWipeVertexAttributes;
  28431. private _emptyTexture;
  28432. private _emptyCubeTexture;
  28433. private _emptyTexture3D;
  28434. /** @hidden */
  28435. _frameHandler: number;
  28436. private _nextFreeTextureSlots;
  28437. private _maxSimultaneousTextures;
  28438. private _activeRequests;
  28439. private _texturesSupported;
  28440. /** @hidden */
  28441. _textureFormatInUse: Nullable<string>;
  28442. /**
  28443. * Gets the list of texture formats supported
  28444. */
  28445. readonly texturesSupported: Array<string>;
  28446. /**
  28447. * Gets the list of texture formats in use
  28448. */
  28449. readonly textureFormatInUse: Nullable<string>;
  28450. /**
  28451. * Gets the current viewport
  28452. */
  28453. readonly currentViewport: Nullable<Viewport>;
  28454. /**
  28455. * Gets the default empty texture
  28456. */
  28457. readonly emptyTexture: InternalTexture;
  28458. /**
  28459. * Gets the default empty 3D texture
  28460. */
  28461. readonly emptyTexture3D: InternalTexture;
  28462. /**
  28463. * Gets the default empty cube texture
  28464. */
  28465. readonly emptyCubeTexture: InternalTexture;
  28466. /**
  28467. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28468. */
  28469. readonly premultipliedAlpha: boolean;
  28470. /**
  28471. * Creates a new engine
  28472. * @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
  28473. * @param antialias defines enable antialiasing (default: false)
  28474. * @param options defines further options to be sent to the getContext() function
  28475. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28476. */
  28477. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28478. /**
  28479. * Initializes a webVR display and starts listening to display change events
  28480. * The onVRDisplayChangedObservable will be notified upon these changes
  28481. * @returns The onVRDisplayChangedObservable
  28482. */
  28483. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28484. /** @hidden */
  28485. _prepareVRComponent(): void;
  28486. /** @hidden */
  28487. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28488. /** @hidden */
  28489. _submitVRFrame(): void;
  28490. /**
  28491. * Call this function to leave webVR mode
  28492. * Will do nothing if webVR is not supported or if there is no webVR device
  28493. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28494. */
  28495. disableVR(): void;
  28496. /**
  28497. * Gets a boolean indicating that the system is in VR mode and is presenting
  28498. * @returns true if VR mode is engaged
  28499. */
  28500. isVRPresenting(): boolean;
  28501. /** @hidden */
  28502. _requestVRFrame(): void;
  28503. private _disableTouchAction;
  28504. private _rebuildInternalTextures;
  28505. private _rebuildEffects;
  28506. /**
  28507. * Gets a boolean indicating if all created effects are ready
  28508. * @returns true if all effects are ready
  28509. */
  28510. areAllEffectsReady(): boolean;
  28511. private _rebuildBuffers;
  28512. private _initGLContext;
  28513. /**
  28514. * Gets version of the current webGL context
  28515. */
  28516. readonly webGLVersion: number;
  28517. /**
  28518. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28519. */
  28520. readonly isStencilEnable: boolean;
  28521. /** @hidden */
  28522. _prepareWorkingCanvas(): void;
  28523. /**
  28524. * Reset the texture cache to empty state
  28525. */
  28526. resetTextureCache(): void;
  28527. /**
  28528. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28530. * @returns true if engine is in deterministic lock step mode
  28531. */
  28532. isDeterministicLockStep(): boolean;
  28533. /**
  28534. * Gets the max steps when engine is running in deterministic lock step
  28535. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28536. * @returns the max steps
  28537. */
  28538. getLockstepMaxSteps(): number;
  28539. /**
  28540. * Gets an object containing information about the current webGL context
  28541. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28542. */
  28543. getGlInfo(): {
  28544. vendor: string;
  28545. renderer: string;
  28546. version: string;
  28547. };
  28548. /**
  28549. * Gets current aspect ratio
  28550. * @param camera defines the camera to use to get the aspect ratio
  28551. * @param useScreen defines if screen size must be used (or the current render target if any)
  28552. * @returns a number defining the aspect ratio
  28553. */
  28554. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28555. /**
  28556. * Gets current screen aspect ratio
  28557. * @returns a number defining the aspect ratio
  28558. */
  28559. getScreenAspectRatio(): number;
  28560. /**
  28561. * Gets the current render width
  28562. * @param useScreen defines if screen size must be used (or the current render target if any)
  28563. * @returns a number defining the current render width
  28564. */
  28565. getRenderWidth(useScreen?: boolean): number;
  28566. /**
  28567. * Gets the current render height
  28568. * @param useScreen defines if screen size must be used (or the current render target if any)
  28569. * @returns a number defining the current render height
  28570. */
  28571. getRenderHeight(useScreen?: boolean): number;
  28572. /**
  28573. * Gets the HTML canvas attached with the current webGL context
  28574. * @returns a HTML canvas
  28575. */
  28576. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28577. /**
  28578. * Gets the client rect of the HTML canvas attached with the current webGL context
  28579. * @returns a client rectanglee
  28580. */
  28581. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28582. /**
  28583. * Defines the hardware scaling level.
  28584. * By default the hardware scaling level is computed from the window device ratio.
  28585. * 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.
  28586. * @param level defines the level to use
  28587. */
  28588. setHardwareScalingLevel(level: number): void;
  28589. /**
  28590. * Gets the current hardware scaling level.
  28591. * By default the hardware scaling level is computed from the window device ratio.
  28592. * 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.
  28593. * @returns a number indicating the current hardware scaling level
  28594. */
  28595. getHardwareScalingLevel(): number;
  28596. /**
  28597. * Gets the list of loaded textures
  28598. * @returns an array containing all loaded textures
  28599. */
  28600. getLoadedTexturesCache(): InternalTexture[];
  28601. /**
  28602. * Gets the object containing all engine capabilities
  28603. * @returns the EngineCapabilities object
  28604. */
  28605. getCaps(): EngineCapabilities;
  28606. /**
  28607. * Gets the current depth function
  28608. * @returns a number defining the depth function
  28609. */
  28610. getDepthFunction(): Nullable<number>;
  28611. /**
  28612. * Sets the current depth function
  28613. * @param depthFunc defines the function to use
  28614. */
  28615. setDepthFunction(depthFunc: number): void;
  28616. /**
  28617. * Sets the current depth function to GREATER
  28618. */
  28619. setDepthFunctionToGreater(): void;
  28620. /**
  28621. * Sets the current depth function to GEQUAL
  28622. */
  28623. setDepthFunctionToGreaterOrEqual(): void;
  28624. /**
  28625. * Sets the current depth function to LESS
  28626. */
  28627. setDepthFunctionToLess(): void;
  28628. private _cachedStencilBuffer;
  28629. private _cachedStencilFunction;
  28630. private _cachedStencilMask;
  28631. private _cachedStencilOperationPass;
  28632. private _cachedStencilOperationFail;
  28633. private _cachedStencilOperationDepthFail;
  28634. private _cachedStencilReference;
  28635. /**
  28636. * Caches the the state of the stencil buffer
  28637. */
  28638. cacheStencilState(): void;
  28639. /**
  28640. * Restores the state of the stencil buffer
  28641. */
  28642. restoreStencilState(): void;
  28643. /**
  28644. * Sets the current depth function to LEQUAL
  28645. */
  28646. setDepthFunctionToLessOrEqual(): void;
  28647. /**
  28648. * Gets a boolean indicating if stencil buffer is enabled
  28649. * @returns the current stencil buffer state
  28650. */
  28651. getStencilBuffer(): boolean;
  28652. /**
  28653. * Enable or disable the stencil buffer
  28654. * @param enable defines if the stencil buffer must be enabled or disabled
  28655. */
  28656. setStencilBuffer(enable: boolean): void;
  28657. /**
  28658. * Gets the current stencil mask
  28659. * @returns a number defining the new stencil mask to use
  28660. */
  28661. getStencilMask(): number;
  28662. /**
  28663. * Sets the current stencil mask
  28664. * @param mask defines the new stencil mask to use
  28665. */
  28666. setStencilMask(mask: number): void;
  28667. /**
  28668. * Gets the current stencil function
  28669. * @returns a number defining the stencil function to use
  28670. */
  28671. getStencilFunction(): number;
  28672. /**
  28673. * Gets the current stencil reference value
  28674. * @returns a number defining the stencil reference value to use
  28675. */
  28676. getStencilFunctionReference(): number;
  28677. /**
  28678. * Gets the current stencil mask
  28679. * @returns a number defining the stencil mask to use
  28680. */
  28681. getStencilFunctionMask(): number;
  28682. /**
  28683. * Sets the current stencil function
  28684. * @param stencilFunc defines the new stencil function to use
  28685. */
  28686. setStencilFunction(stencilFunc: number): void;
  28687. /**
  28688. * Sets the current stencil reference
  28689. * @param reference defines the new stencil reference to use
  28690. */
  28691. setStencilFunctionReference(reference: number): void;
  28692. /**
  28693. * Sets the current stencil mask
  28694. * @param mask defines the new stencil mask to use
  28695. */
  28696. setStencilFunctionMask(mask: number): void;
  28697. /**
  28698. * Gets the current stencil operation when stencil fails
  28699. * @returns a number defining stencil operation to use when stencil fails
  28700. */
  28701. getStencilOperationFail(): number;
  28702. /**
  28703. * Gets the current stencil operation when depth fails
  28704. * @returns a number defining stencil operation to use when depth fails
  28705. */
  28706. getStencilOperationDepthFail(): number;
  28707. /**
  28708. * Gets the current stencil operation when stencil passes
  28709. * @returns a number defining stencil operation to use when stencil passes
  28710. */
  28711. getStencilOperationPass(): number;
  28712. /**
  28713. * Sets the stencil operation to use when stencil fails
  28714. * @param operation defines the stencil operation to use when stencil fails
  28715. */
  28716. setStencilOperationFail(operation: number): void;
  28717. /**
  28718. * Sets the stencil operation to use when depth fails
  28719. * @param operation defines the stencil operation to use when depth fails
  28720. */
  28721. setStencilOperationDepthFail(operation: number): void;
  28722. /**
  28723. * Sets the stencil operation to use when stencil passes
  28724. * @param operation defines the stencil operation to use when stencil passes
  28725. */
  28726. setStencilOperationPass(operation: number): void;
  28727. /**
  28728. * Sets a boolean indicating if the dithering state is enabled or disabled
  28729. * @param value defines the dithering state
  28730. */
  28731. setDitheringState(value: boolean): void;
  28732. /**
  28733. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28734. * @param value defines the rasterizer state
  28735. */
  28736. setRasterizerState(value: boolean): void;
  28737. /**
  28738. * stop executing a render loop function and remove it from the execution array
  28739. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28740. */
  28741. stopRenderLoop(renderFunction?: () => void): void;
  28742. /** @hidden */
  28743. _renderLoop(): void;
  28744. /**
  28745. * Register and execute a render loop. The engine can have more than one render function
  28746. * @param renderFunction defines the function to continuously execute
  28747. */
  28748. runRenderLoop(renderFunction: () => void): void;
  28749. /**
  28750. * Toggle full screen mode
  28751. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28752. */
  28753. switchFullscreen(requestPointerLock: boolean): void;
  28754. /**
  28755. * Enters full screen mode
  28756. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28757. */
  28758. enterFullscreen(requestPointerLock: boolean): void;
  28759. /**
  28760. * Exits full screen mode
  28761. */
  28762. exitFullscreen(): void;
  28763. /**
  28764. * Clear the current render buffer or the current render target (if any is set up)
  28765. * @param color defines the color to use
  28766. * @param backBuffer defines if the back buffer must be cleared
  28767. * @param depth defines if the depth buffer must be cleared
  28768. * @param stencil defines if the stencil buffer must be cleared
  28769. */
  28770. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28771. /**
  28772. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28773. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28774. * @param y defines the y-coordinate of the corner of the clear rectangle
  28775. * @param width defines the width of the clear rectangle
  28776. * @param height defines the height of the clear rectangle
  28777. * @param clearColor defines the clear color
  28778. */
  28779. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28780. /**
  28781. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28782. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28783. * @param y defines the y-coordinate of the corner of the clear rectangle
  28784. * @param width defines the width of the clear rectangle
  28785. * @param height defines the height of the clear rectangle
  28786. */
  28787. enableScissor(x: number, y: number, width: number, height: number): void;
  28788. /**
  28789. * Disable previously set scissor test rectangle
  28790. */
  28791. disableScissor(): void;
  28792. private _viewportCached;
  28793. /** @hidden */
  28794. _viewport(x: number, y: number, width: number, height: number): void;
  28795. /**
  28796. * Set the WebGL's viewport
  28797. * @param viewport defines the viewport element to be used
  28798. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28799. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28800. */
  28801. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28802. /**
  28803. * Directly set the WebGL Viewport
  28804. * @param x defines the x coordinate of the viewport (in screen space)
  28805. * @param y defines the y coordinate of the viewport (in screen space)
  28806. * @param width defines the width of the viewport (in screen space)
  28807. * @param height defines the height of the viewport (in screen space)
  28808. * @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
  28809. */
  28810. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28811. /**
  28812. * Begin a new frame
  28813. */
  28814. beginFrame(): void;
  28815. /**
  28816. * Enf the current frame
  28817. */
  28818. endFrame(): void;
  28819. /**
  28820. * Resize the view according to the canvas' size
  28821. */
  28822. resize(): void;
  28823. /**
  28824. * Force a specific size of the canvas
  28825. * @param width defines the new canvas' width
  28826. * @param height defines the new canvas' height
  28827. */
  28828. setSize(width: number, height: number): void;
  28829. /**
  28830. * Binds the frame buffer to the specified texture.
  28831. * @param texture The texture to render to or null for the default canvas
  28832. * @param faceIndex The face of the texture to render to in case of cube texture
  28833. * @param requiredWidth The width of the target to render to
  28834. * @param requiredHeight The height of the target to render to
  28835. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28836. * @param depthStencilTexture The depth stencil texture to use to render
  28837. * @param lodLevel defines le lod level to bind to the frame buffer
  28838. */
  28839. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28840. /** @hidden */
  28841. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28842. /**
  28843. * Unbind the current render target texture from the webGL context
  28844. * @param texture defines the render target texture to unbind
  28845. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28846. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28847. */
  28848. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28849. /**
  28850. * Force the mipmap generation for the given render target texture
  28851. * @param texture defines the render target texture to use
  28852. */
  28853. generateMipMapsForCubemap(texture: InternalTexture): void;
  28854. /**
  28855. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28856. */
  28857. flushFramebuffer(): void;
  28858. /**
  28859. * Unbind the current render target and bind the default framebuffer
  28860. */
  28861. restoreDefaultFramebuffer(): void;
  28862. /**
  28863. * Create an uniform buffer
  28864. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28865. * @param elements defines the content of the uniform buffer
  28866. * @returns the webGL uniform buffer
  28867. */
  28868. createUniformBuffer(elements: FloatArray): DataBuffer;
  28869. /**
  28870. * Create a dynamic uniform buffer
  28871. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28872. * @param elements defines the content of the uniform buffer
  28873. * @returns the webGL uniform buffer
  28874. */
  28875. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28876. /**
  28877. * Update an existing uniform buffer
  28878. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28879. * @param uniformBuffer defines the target uniform buffer
  28880. * @param elements defines the content to update
  28881. * @param offset defines the offset in the uniform buffer where update should start
  28882. * @param count defines the size of the data to update
  28883. */
  28884. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28885. private _resetVertexBufferBinding;
  28886. /**
  28887. * Creates a vertex buffer
  28888. * @param data the data for the vertex buffer
  28889. * @returns the new WebGL static buffer
  28890. */
  28891. createVertexBuffer(data: DataArray): DataBuffer;
  28892. /**
  28893. * Creates a dynamic vertex buffer
  28894. * @param data the data for the dynamic vertex buffer
  28895. * @returns the new WebGL dynamic buffer
  28896. */
  28897. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28898. /**
  28899. * Update a dynamic index buffer
  28900. * @param indexBuffer defines the target index buffer
  28901. * @param indices defines the data to update
  28902. * @param offset defines the offset in the target index buffer where update should start
  28903. */
  28904. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28905. /**
  28906. * Updates a dynamic vertex buffer.
  28907. * @param vertexBuffer the vertex buffer to update
  28908. * @param data the data used to update the vertex buffer
  28909. * @param byteOffset the byte offset of the data
  28910. * @param byteLength the byte length of the data
  28911. */
  28912. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28913. private _resetIndexBufferBinding;
  28914. /**
  28915. * Creates a new index buffer
  28916. * @param indices defines the content of the index buffer
  28917. * @param updatable defines if the index buffer must be updatable
  28918. * @returns a new webGL buffer
  28919. */
  28920. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28921. /**
  28922. * Bind a webGL buffer to the webGL context
  28923. * @param buffer defines the buffer to bind
  28924. */
  28925. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28926. /**
  28927. * Bind an uniform buffer to the current webGL context
  28928. * @param buffer defines the buffer to bind
  28929. */
  28930. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28931. /**
  28932. * Bind a buffer to the current webGL context at a given location
  28933. * @param buffer defines the buffer to bind
  28934. * @param location defines the index where to bind the buffer
  28935. */
  28936. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28937. /**
  28938. * Bind a specific block at a given index in a specific shader program
  28939. * @param pipelineContext defines the pipeline context to use
  28940. * @param blockName defines the block name
  28941. * @param index defines the index where to bind the block
  28942. */
  28943. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28944. private bindIndexBuffer;
  28945. private bindBuffer;
  28946. /**
  28947. * update the bound buffer with the given data
  28948. * @param data defines the data to update
  28949. */
  28950. updateArrayBuffer(data: Float32Array): void;
  28951. private _vertexAttribPointer;
  28952. private _bindIndexBufferWithCache;
  28953. private _bindVertexBuffersAttributes;
  28954. /**
  28955. * Records a vertex array object
  28956. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28957. * @param vertexBuffers defines the list of vertex buffers to store
  28958. * @param indexBuffer defines the index buffer to store
  28959. * @param effect defines the effect to store
  28960. * @returns the new vertex array object
  28961. */
  28962. recordVertexArrayObject(vertexBuffers: {
  28963. [key: string]: VertexBuffer;
  28964. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28965. /**
  28966. * Bind a specific vertex array object
  28967. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28968. * @param vertexArrayObject defines the vertex array object to bind
  28969. * @param indexBuffer defines the index buffer to bind
  28970. */
  28971. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28972. /**
  28973. * Bind webGl buffers directly to the webGL context
  28974. * @param vertexBuffer defines the vertex buffer to bind
  28975. * @param indexBuffer defines the index buffer to bind
  28976. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28977. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28978. * @param effect defines the effect associated with the vertex buffer
  28979. */
  28980. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28981. private _unbindVertexArrayObject;
  28982. /**
  28983. * Bind a list of vertex buffers to the webGL context
  28984. * @param vertexBuffers defines the list of vertex buffers to bind
  28985. * @param indexBuffer defines the index buffer to bind
  28986. * @param effect defines the effect associated with the vertex buffers
  28987. */
  28988. bindBuffers(vertexBuffers: {
  28989. [key: string]: Nullable<VertexBuffer>;
  28990. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28991. /**
  28992. * Unbind all instance attributes
  28993. */
  28994. unbindInstanceAttributes(): void;
  28995. /**
  28996. * Release and free the memory of a vertex array object
  28997. * @param vao defines the vertex array object to delete
  28998. */
  28999. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29000. /** @hidden */
  29001. _releaseBuffer(buffer: DataBuffer): boolean;
  29002. /**
  29003. * Creates a webGL buffer to use with instanciation
  29004. * @param capacity defines the size of the buffer
  29005. * @returns the webGL buffer
  29006. */
  29007. createInstancesBuffer(capacity: number): DataBuffer;
  29008. /**
  29009. * Delete a webGL buffer used with instanciation
  29010. * @param buffer defines the webGL buffer to delete
  29011. */
  29012. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29013. /**
  29014. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29015. * @param instancesBuffer defines the webGL buffer to update and bind
  29016. * @param data defines the data to store in the buffer
  29017. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29018. */
  29019. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29020. /**
  29021. * Apply all cached states (depth, culling, stencil and alpha)
  29022. */
  29023. applyStates(): void;
  29024. /**
  29025. * Send a draw order
  29026. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29027. * @param indexStart defines the starting index
  29028. * @param indexCount defines the number of index to draw
  29029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29030. */
  29031. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29032. /**
  29033. * Draw a list of points
  29034. * @param verticesStart defines the index of first vertex to draw
  29035. * @param verticesCount defines the count of vertices to draw
  29036. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29037. */
  29038. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29039. /**
  29040. * Draw a list of unindexed primitives
  29041. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29042. * @param verticesStart defines the index of first vertex to draw
  29043. * @param verticesCount defines the count of vertices to draw
  29044. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29045. */
  29046. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29047. /**
  29048. * Draw a list of indexed primitives
  29049. * @param fillMode defines the primitive to use
  29050. * @param indexStart defines the starting index
  29051. * @param indexCount defines the number of index to draw
  29052. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29053. */
  29054. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29055. /**
  29056. * Draw a list of unindexed primitives
  29057. * @param fillMode defines the primitive to use
  29058. * @param verticesStart defines the index of first vertex to draw
  29059. * @param verticesCount defines the count of vertices to draw
  29060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29061. */
  29062. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29063. private _drawMode;
  29064. /** @hidden */
  29065. _releaseEffect(effect: Effect): void;
  29066. /** @hidden */
  29067. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29068. /**
  29069. * Create a new effect (used to store vertex/fragment shaders)
  29070. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29071. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29072. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29073. * @param samplers defines an array of string used to represent textures
  29074. * @param defines defines the string containing the defines to use to compile the shaders
  29075. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29076. * @param onCompiled defines a function to call when the effect creation is successful
  29077. * @param onError defines a function to call when the effect creation has failed
  29078. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29079. * @returns the new Effect
  29080. */
  29081. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29082. private _compileShader;
  29083. private _compileRawShader;
  29084. /**
  29085. * Directly creates a webGL program
  29086. * @param pipelineContext defines the pipeline context to attach to
  29087. * @param vertexCode defines the vertex shader code to use
  29088. * @param fragmentCode defines the fragment shader code to use
  29089. * @param context defines the webGL context to use (if not set, the current one will be used)
  29090. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29091. * @returns the new webGL program
  29092. */
  29093. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29094. /**
  29095. * Creates a webGL program
  29096. * @param pipelineContext defines the pipeline context to attach to
  29097. * @param vertexCode defines the vertex shader code to use
  29098. * @param fragmentCode defines the fragment shader code to use
  29099. * @param defines defines the string containing the defines to use to compile the shaders
  29100. * @param context defines the webGL context to use (if not set, the current one will be used)
  29101. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29102. * @returns the new webGL program
  29103. */
  29104. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29105. /**
  29106. * Creates a new pipeline context
  29107. * @returns the new pipeline
  29108. */
  29109. createPipelineContext(): WebGLPipelineContext;
  29110. private _createShaderProgram;
  29111. private _finalizePipelineContext;
  29112. /** @hidden */
  29113. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29114. /** @hidden */
  29115. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29116. /** @hidden */
  29117. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29118. /**
  29119. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29120. * @param pipelineContext defines the pipeline context to use
  29121. * @param uniformsNames defines the list of uniform names
  29122. * @returns an array of webGL uniform locations
  29123. */
  29124. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29125. /**
  29126. * Gets the lsit of active attributes for a given webGL program
  29127. * @param pipelineContext defines the pipeline context to use
  29128. * @param attributesNames defines the list of attribute names to get
  29129. * @returns an array of indices indicating the offset of each attribute
  29130. */
  29131. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29132. /**
  29133. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29134. * @param effect defines the effect to activate
  29135. */
  29136. enableEffect(effect: Nullable<Effect>): void;
  29137. /**
  29138. * Set the value of an uniform to an array of int32
  29139. * @param uniform defines the webGL uniform location where to store the value
  29140. * @param array defines the array of int32 to store
  29141. */
  29142. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29143. /**
  29144. * Set the value of an uniform to an array of int32 (stored as vec2)
  29145. * @param uniform defines the webGL uniform location where to store the value
  29146. * @param array defines the array of int32 to store
  29147. */
  29148. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29149. /**
  29150. * Set the value of an uniform to an array of int32 (stored as vec3)
  29151. * @param uniform defines the webGL uniform location where to store the value
  29152. * @param array defines the array of int32 to store
  29153. */
  29154. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29155. /**
  29156. * Set the value of an uniform to an array of int32 (stored as vec4)
  29157. * @param uniform defines the webGL uniform location where to store the value
  29158. * @param array defines the array of int32 to store
  29159. */
  29160. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29161. /**
  29162. * Set the value of an uniform to an array of float32
  29163. * @param uniform defines the webGL uniform location where to store the value
  29164. * @param array defines the array of float32 to store
  29165. */
  29166. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29167. /**
  29168. * Set the value of an uniform to an array of float32 (stored as vec2)
  29169. * @param uniform defines the webGL uniform location where to store the value
  29170. * @param array defines the array of float32 to store
  29171. */
  29172. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29173. /**
  29174. * Set the value of an uniform to an array of float32 (stored as vec3)
  29175. * @param uniform defines the webGL uniform location where to store the value
  29176. * @param array defines the array of float32 to store
  29177. */
  29178. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29179. /**
  29180. * Set the value of an uniform to an array of float32 (stored as vec4)
  29181. * @param uniform defines the webGL uniform location where to store the value
  29182. * @param array defines the array of float32 to store
  29183. */
  29184. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29185. /**
  29186. * Set the value of an uniform to an array of number
  29187. * @param uniform defines the webGL uniform location where to store the value
  29188. * @param array defines the array of number to store
  29189. */
  29190. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29191. /**
  29192. * Set the value of an uniform to an array of number (stored as vec2)
  29193. * @param uniform defines the webGL uniform location where to store the value
  29194. * @param array defines the array of number to store
  29195. */
  29196. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29197. /**
  29198. * Set the value of an uniform to an array of number (stored as vec3)
  29199. * @param uniform defines the webGL uniform location where to store the value
  29200. * @param array defines the array of number to store
  29201. */
  29202. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29203. /**
  29204. * Set the value of an uniform to an array of number (stored as vec4)
  29205. * @param uniform defines the webGL uniform location where to store the value
  29206. * @param array defines the array of number to store
  29207. */
  29208. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29209. /**
  29210. * Set the value of an uniform to an array of float32 (stored as matrices)
  29211. * @param uniform defines the webGL uniform location where to store the value
  29212. * @param matrices defines the array of float32 to store
  29213. */
  29214. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29215. /**
  29216. * Set the value of an uniform to a matrix
  29217. * @param uniform defines the webGL uniform location where to store the value
  29218. * @param matrix defines the matrix to store
  29219. */
  29220. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29221. /**
  29222. * Set the value of an uniform to a matrix (3x3)
  29223. * @param uniform defines the webGL uniform location where to store the value
  29224. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29225. */
  29226. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29227. /**
  29228. * Set the value of an uniform to a matrix (2x2)
  29229. * @param uniform defines the webGL uniform location where to store the value
  29230. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29231. */
  29232. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29233. /**
  29234. * Set the value of an uniform to a number (int)
  29235. * @param uniform defines the webGL uniform location where to store the value
  29236. * @param value defines the int number to store
  29237. */
  29238. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29239. /**
  29240. * Set the value of an uniform to a number (float)
  29241. * @param uniform defines the webGL uniform location where to store the value
  29242. * @param value defines the float number to store
  29243. */
  29244. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29245. /**
  29246. * Set the value of an uniform to a vec2
  29247. * @param uniform defines the webGL uniform location where to store the value
  29248. * @param x defines the 1st component of the value
  29249. * @param y defines the 2nd component of the value
  29250. */
  29251. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29252. /**
  29253. * Set the value of an uniform to a vec3
  29254. * @param uniform defines the webGL uniform location where to store the value
  29255. * @param x defines the 1st component of the value
  29256. * @param y defines the 2nd component of the value
  29257. * @param z defines the 3rd component of the value
  29258. */
  29259. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29260. /**
  29261. * Set the value of an uniform to a boolean
  29262. * @param uniform defines the webGL uniform location where to store the value
  29263. * @param bool defines the boolean to store
  29264. */
  29265. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29266. /**
  29267. * Set the value of an uniform to a vec4
  29268. * @param uniform defines the webGL uniform location where to store the value
  29269. * @param x defines the 1st component of the value
  29270. * @param y defines the 2nd component of the value
  29271. * @param z defines the 3rd component of the value
  29272. * @param w defines the 4th component of the value
  29273. */
  29274. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29275. /**
  29276. * Set the value of an uniform to a Color3
  29277. * @param uniform defines the webGL uniform location where to store the value
  29278. * @param color3 defines the color to store
  29279. */
  29280. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29281. /**
  29282. * Set the value of an uniform to a Color3 and an alpha value
  29283. * @param uniform defines the webGL uniform location where to store the value
  29284. * @param color3 defines the color to store
  29285. * @param alpha defines the alpha component to store
  29286. */
  29287. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29288. /**
  29289. * Sets a Color4 on a uniform variable
  29290. * @param uniform defines the uniform location
  29291. * @param color4 defines the value to be set
  29292. */
  29293. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29294. /**
  29295. * Set various states to the webGL context
  29296. * @param culling defines backface culling state
  29297. * @param zOffset defines the value to apply to zOffset (0 by default)
  29298. * @param force defines if states must be applied even if cache is up to date
  29299. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29300. */
  29301. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29302. /**
  29303. * Set the z offset to apply to current rendering
  29304. * @param value defines the offset to apply
  29305. */
  29306. setZOffset(value: number): void;
  29307. /**
  29308. * Gets the current value of the zOffset
  29309. * @returns the current zOffset state
  29310. */
  29311. getZOffset(): number;
  29312. /**
  29313. * Enable or disable depth buffering
  29314. * @param enable defines the state to set
  29315. */
  29316. setDepthBuffer(enable: boolean): void;
  29317. /**
  29318. * Gets a boolean indicating if depth writing is enabled
  29319. * @returns the current depth writing state
  29320. */
  29321. getDepthWrite(): boolean;
  29322. /**
  29323. * Enable or disable depth writing
  29324. * @param enable defines the state to set
  29325. */
  29326. setDepthWrite(enable: boolean): void;
  29327. /**
  29328. * Enable or disable color writing
  29329. * @param enable defines the state to set
  29330. */
  29331. setColorWrite(enable: boolean): void;
  29332. /**
  29333. * Gets a boolean indicating if color writing is enabled
  29334. * @returns the current color writing state
  29335. */
  29336. getColorWrite(): boolean;
  29337. /**
  29338. * Sets alpha constants used by some alpha blending modes
  29339. * @param r defines the red component
  29340. * @param g defines the green component
  29341. * @param b defines the blue component
  29342. * @param a defines the alpha component
  29343. */
  29344. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29345. /**
  29346. * Sets the current alpha mode
  29347. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29348. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29349. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29350. */
  29351. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29352. /**
  29353. * Gets the current alpha mode
  29354. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29355. * @returns the current alpha mode
  29356. */
  29357. getAlphaMode(): number;
  29358. /**
  29359. * Clears the list of texture accessible through engine.
  29360. * This can help preventing texture load conflict due to name collision.
  29361. */
  29362. clearInternalTexturesCache(): void;
  29363. /**
  29364. * Force the entire cache to be cleared
  29365. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29366. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29367. */
  29368. wipeCaches(bruteForce?: boolean): void;
  29369. /**
  29370. * Set the compressed texture format to use, based on the formats you have, and the formats
  29371. * supported by the hardware / browser.
  29372. *
  29373. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29374. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29375. * to API arguments needed to compressed textures. This puts the burden on the container
  29376. * generator to house the arcane code for determining these for current & future formats.
  29377. *
  29378. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29379. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29380. *
  29381. * Note: The result of this call is not taken into account when a texture is base64.
  29382. *
  29383. * @param formatsAvailable defines the list of those format families you have created
  29384. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29385. *
  29386. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29387. * @returns The extension selected.
  29388. */
  29389. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29390. /** @hidden */
  29391. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29392. min: number;
  29393. mag: number;
  29394. };
  29395. /** @hidden */
  29396. _createTexture(): WebGLTexture;
  29397. /**
  29398. * Usually called from Texture.ts.
  29399. * Passed information to create a WebGLTexture
  29400. * @param urlArg defines a value which contains one of the following:
  29401. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29402. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29403. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29405. * @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)
  29406. * @param scene needed for loading to the correct scene
  29407. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29408. * @param onLoad optional callback to be called upon successful completion
  29409. * @param onError optional callback to be called upon failure
  29410. * @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
  29411. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29412. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29413. * @param forcedExtension defines the extension to use to pick the right loader
  29414. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29415. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29416. */
  29417. 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;
  29418. private _rescaleTexture;
  29419. private _unpackFlipYCached;
  29420. /**
  29421. * In case you are sharing the context with other applications, it might
  29422. * be interested to not cache the unpack flip y state to ensure a consistent
  29423. * value would be set.
  29424. */
  29425. enableUnpackFlipYCached: boolean;
  29426. /** @hidden */
  29427. _unpackFlipY(value: boolean): void;
  29428. /** @hidden */
  29429. _getUnpackAlignement(): number;
  29430. /**
  29431. * Creates a dynamic texture
  29432. * @param width defines the width of the texture
  29433. * @param height defines the height of the texture
  29434. * @param generateMipMaps defines if the engine should generate the mip levels
  29435. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29436. * @returns the dynamic texture inside an InternalTexture
  29437. */
  29438. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29439. /**
  29440. * Update the sampling mode of a given texture
  29441. * @param samplingMode defines the required sampling mode
  29442. * @param texture defines the texture to update
  29443. */
  29444. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29445. /**
  29446. * Update the content of a dynamic texture
  29447. * @param texture defines the texture to update
  29448. * @param canvas defines the canvas containing the source
  29449. * @param invertY defines if data must be stored with Y axis inverted
  29450. * @param premulAlpha defines if alpha is stored as premultiplied
  29451. * @param format defines the format of the data
  29452. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29453. */
  29454. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29455. /**
  29456. * Update a video texture
  29457. * @param texture defines the texture to update
  29458. * @param video defines the video element to use
  29459. * @param invertY defines if data must be stored with Y axis inverted
  29460. */
  29461. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29462. /**
  29463. * Updates a depth texture Comparison Mode and Function.
  29464. * If the comparison Function is equal to 0, the mode will be set to none.
  29465. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29466. * @param texture The texture to set the comparison function for
  29467. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29468. */
  29469. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29470. /** @hidden */
  29471. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29472. width: number;
  29473. height: number;
  29474. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29475. /**
  29476. * Creates a depth stencil texture.
  29477. * This is only available in WebGL 2 or with the depth texture extension available.
  29478. * @param size The size of face edge in the texture.
  29479. * @param options The options defining the texture.
  29480. * @returns The texture
  29481. */
  29482. createDepthStencilTexture(size: number | {
  29483. width: number;
  29484. height: number;
  29485. }, options: DepthTextureCreationOptions): InternalTexture;
  29486. /**
  29487. * Creates a depth stencil texture.
  29488. * This is only available in WebGL 2 or with the depth texture extension available.
  29489. * @param size The size of face edge in the texture.
  29490. * @param options The options defining the texture.
  29491. * @returns The texture
  29492. */
  29493. private _createDepthStencilTexture;
  29494. /**
  29495. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29496. * @param renderTarget The render target to set the frame buffer for
  29497. */
  29498. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29499. /**
  29500. * Creates a new render target texture
  29501. * @param size defines the size of the texture
  29502. * @param options defines the options used to create the texture
  29503. * @returns a new render target texture stored in an InternalTexture
  29504. */
  29505. createRenderTargetTexture(size: number | {
  29506. width: number;
  29507. height: number;
  29508. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29509. /** @hidden */
  29510. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29511. /**
  29512. * Updates the sample count of a render target texture
  29513. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29514. * @param texture defines the texture to update
  29515. * @param samples defines the sample count to set
  29516. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29517. */
  29518. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29519. /** @hidden */
  29520. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29521. /** @hidden */
  29522. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29523. /** @hidden */
  29524. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29525. /** @hidden */
  29526. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29527. /**
  29528. * @hidden
  29529. */
  29530. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29531. private _prepareWebGLTextureContinuation;
  29532. private _prepareWebGLTexture;
  29533. /** @hidden */
  29534. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29535. /** @hidden */
  29536. _releaseFramebufferObjects(texture: InternalTexture): void;
  29537. /** @hidden */
  29538. _releaseTexture(texture: InternalTexture): void;
  29539. private setProgram;
  29540. private _boundUniforms;
  29541. /**
  29542. * Binds an effect to the webGL context
  29543. * @param effect defines the effect to bind
  29544. */
  29545. bindSamplers(effect: Effect): void;
  29546. private _activateCurrentTexture;
  29547. /** @hidden */
  29548. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29549. /** @hidden */
  29550. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29551. /**
  29552. * Sets a texture to the webGL context from a postprocess
  29553. * @param channel defines the channel to use
  29554. * @param postProcess defines the source postprocess
  29555. */
  29556. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29557. /**
  29558. * Binds the output of the passed in post process to the texture channel specified
  29559. * @param channel The channel the texture should be bound to
  29560. * @param postProcess The post process which's output should be bound
  29561. */
  29562. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29563. /**
  29564. * Unbind all textures from the webGL context
  29565. */
  29566. unbindAllTextures(): void;
  29567. /**
  29568. * Sets a texture to the according uniform.
  29569. * @param channel The texture channel
  29570. * @param uniform The uniform to set
  29571. * @param texture The texture to apply
  29572. */
  29573. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29574. /**
  29575. * Sets a depth stencil texture from a render target to the according uniform.
  29576. * @param channel The texture channel
  29577. * @param uniform The uniform to set
  29578. * @param texture The render target texture containing the depth stencil texture to apply
  29579. */
  29580. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29581. private _bindSamplerUniformToChannel;
  29582. private _getTextureWrapMode;
  29583. private _setTexture;
  29584. /**
  29585. * Sets an array of texture to the webGL context
  29586. * @param channel defines the channel where the texture array must be set
  29587. * @param uniform defines the associated uniform location
  29588. * @param textures defines the array of textures to bind
  29589. */
  29590. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29591. /** @hidden */
  29592. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29593. private _setTextureParameterFloat;
  29594. private _setTextureParameterInteger;
  29595. /**
  29596. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29597. * @param x defines the x coordinate of the rectangle where pixels must be read
  29598. * @param y defines the y coordinate of the rectangle where pixels must be read
  29599. * @param width defines the width of the rectangle where pixels must be read
  29600. * @param height defines the height of the rectangle where pixels must be read
  29601. * @returns a Uint8Array containing RGBA colors
  29602. */
  29603. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29604. /**
  29605. * Add an externaly attached data from its key.
  29606. * This method call will fail and return false, if such key already exists.
  29607. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29608. * @param key the unique key that identifies the data
  29609. * @param data the data object to associate to the key for this Engine instance
  29610. * @return true if no such key were already present and the data was added successfully, false otherwise
  29611. */
  29612. addExternalData<T>(key: string, data: T): boolean;
  29613. /**
  29614. * Get an externaly attached data from its key
  29615. * @param key the unique key that identifies the data
  29616. * @return the associated data, if present (can be null), or undefined if not present
  29617. */
  29618. getExternalData<T>(key: string): T;
  29619. /**
  29620. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29621. * @param key the unique key that identifies the data
  29622. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29623. * @return the associated data, can be null if the factory returned null.
  29624. */
  29625. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29626. /**
  29627. * Remove an externaly attached data from the Engine instance
  29628. * @param key the unique key that identifies the data
  29629. * @return true if the data was successfully removed, false if it doesn't exist
  29630. */
  29631. removeExternalData(key: string): boolean;
  29632. /**
  29633. * Unbind all vertex attributes from the webGL context
  29634. */
  29635. unbindAllAttributes(): void;
  29636. /**
  29637. * 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
  29638. */
  29639. releaseEffects(): void;
  29640. /**
  29641. * Dispose and release all associated resources
  29642. */
  29643. dispose(): void;
  29644. /**
  29645. * Display the loading screen
  29646. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29647. */
  29648. displayLoadingUI(): void;
  29649. /**
  29650. * Hide the loading screen
  29651. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29652. */
  29653. hideLoadingUI(): void;
  29654. /**
  29655. * Gets the current loading screen object
  29656. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29657. */
  29658. /**
  29659. * Sets the current loading screen object
  29660. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29661. */
  29662. loadingScreen: ILoadingScreen;
  29663. /**
  29664. * Sets the current loading screen text
  29665. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29666. */
  29667. loadingUIText: string;
  29668. /**
  29669. * Sets the current loading screen background color
  29670. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29671. */
  29672. loadingUIBackgroundColor: string;
  29673. /**
  29674. * Attach a new callback raised when context lost event is fired
  29675. * @param callback defines the callback to call
  29676. */
  29677. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29678. /**
  29679. * Attach a new callback raised when context restored event is fired
  29680. * @param callback defines the callback to call
  29681. */
  29682. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29683. /**
  29684. * Gets the source code of the vertex shader associated with a specific webGL program
  29685. * @param program defines the program to use
  29686. * @returns a string containing the source code of the vertex shader associated with the program
  29687. */
  29688. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29689. /**
  29690. * Gets the source code of the fragment shader associated with a specific webGL program
  29691. * @param program defines the program to use
  29692. * @returns a string containing the source code of the fragment shader associated with the program
  29693. */
  29694. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29695. /**
  29696. * Get the current error code of the webGL context
  29697. * @returns the error code
  29698. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29699. */
  29700. getError(): number;
  29701. /**
  29702. * Gets the current framerate
  29703. * @returns a number representing the framerate
  29704. */
  29705. getFps(): number;
  29706. /**
  29707. * Gets the time spent between current and previous frame
  29708. * @returns a number representing the delta time in ms
  29709. */
  29710. getDeltaTime(): number;
  29711. private _measureFps;
  29712. /** @hidden */
  29713. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29714. private _canRenderToFloatFramebuffer;
  29715. private _canRenderToHalfFloatFramebuffer;
  29716. private _canRenderToFramebuffer;
  29717. /** @hidden */
  29718. _getWebGLTextureType(type: number): number;
  29719. /** @hidden */
  29720. _getInternalFormat(format: number): number;
  29721. /** @hidden */
  29722. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29723. /** @hidden */
  29724. _getRGBAMultiSampleBufferFormat(type: number): number;
  29725. /** @hidden */
  29726. _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;
  29727. /** @hidden */
  29728. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29729. /**
  29730. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29731. * @returns true if the engine can be created
  29732. * @ignorenaming
  29733. */
  29734. static isSupported(): boolean;
  29735. }
  29736. }
  29737. declare module "babylonjs/Materials/effect" {
  29738. import { Observable } from "babylonjs/Misc/observable";
  29739. import { Nullable } from "babylonjs/types";
  29740. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29741. import { IDisposable } from "babylonjs/scene";
  29742. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29743. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29744. import { Engine } from "babylonjs/Engines/engine";
  29745. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29748. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29750. /**
  29751. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29752. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29753. */
  29754. export class EffectFallbacks {
  29755. private _defines;
  29756. private _currentRank;
  29757. private _maxRank;
  29758. private _mesh;
  29759. /**
  29760. * Removes the fallback from the bound mesh.
  29761. */
  29762. unBindMesh(): void;
  29763. /**
  29764. * Adds a fallback on the specified property.
  29765. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29766. * @param define The name of the define in the shader
  29767. */
  29768. addFallback(rank: number, define: string): void;
  29769. /**
  29770. * Sets the mesh to use CPU skinning when needing to fallback.
  29771. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29772. * @param mesh The mesh to use the fallbacks.
  29773. */
  29774. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29775. /**
  29776. * Checks to see if more fallbacks are still availible.
  29777. */
  29778. readonly isMoreFallbacks: boolean;
  29779. /**
  29780. * Removes the defines that shoould be removed when falling back.
  29781. * @param currentDefines defines the current define statements for the shader.
  29782. * @param effect defines the current effect we try to compile
  29783. * @returns The resulting defines with defines of the current rank removed.
  29784. */
  29785. reduce(currentDefines: string, effect: Effect): string;
  29786. }
  29787. /**
  29788. * Options to be used when creating an effect.
  29789. */
  29790. export class EffectCreationOptions {
  29791. /**
  29792. * Atrributes that will be used in the shader.
  29793. */
  29794. attributes: string[];
  29795. /**
  29796. * Uniform varible names that will be set in the shader.
  29797. */
  29798. uniformsNames: string[];
  29799. /**
  29800. * Uniform buffer varible names that will be set in the shader.
  29801. */
  29802. uniformBuffersNames: string[];
  29803. /**
  29804. * Sampler texture variable names that will be set in the shader.
  29805. */
  29806. samplers: string[];
  29807. /**
  29808. * Define statements that will be set in the shader.
  29809. */
  29810. defines: any;
  29811. /**
  29812. * Possible fallbacks for this effect to improve performance when needed.
  29813. */
  29814. fallbacks: Nullable<EffectFallbacks>;
  29815. /**
  29816. * Callback that will be called when the shader is compiled.
  29817. */
  29818. onCompiled: Nullable<(effect: Effect) => void>;
  29819. /**
  29820. * Callback that will be called if an error occurs during shader compilation.
  29821. */
  29822. onError: Nullable<(effect: Effect, errors: string) => void>;
  29823. /**
  29824. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29825. */
  29826. indexParameters: any;
  29827. /**
  29828. * Max number of lights that can be used in the shader.
  29829. */
  29830. maxSimultaneousLights: number;
  29831. /**
  29832. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29833. */
  29834. transformFeedbackVaryings: Nullable<string[]>;
  29835. }
  29836. /**
  29837. * Effect containing vertex and fragment shader that can be executed on an object.
  29838. */
  29839. export class Effect implements IDisposable {
  29840. /**
  29841. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29842. */
  29843. static ShadersRepository: string;
  29844. /**
  29845. * Name of the effect.
  29846. */
  29847. name: any;
  29848. /**
  29849. * String container all the define statements that should be set on the shader.
  29850. */
  29851. defines: string;
  29852. /**
  29853. * Callback that will be called when the shader is compiled.
  29854. */
  29855. onCompiled: Nullable<(effect: Effect) => void>;
  29856. /**
  29857. * Callback that will be called if an error occurs during shader compilation.
  29858. */
  29859. onError: Nullable<(effect: Effect, errors: string) => void>;
  29860. /**
  29861. * Callback that will be called when effect is bound.
  29862. */
  29863. onBind: Nullable<(effect: Effect) => void>;
  29864. /**
  29865. * Unique ID of the effect.
  29866. */
  29867. uniqueId: number;
  29868. /**
  29869. * Observable that will be called when the shader is compiled.
  29870. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29871. */
  29872. onCompileObservable: Observable<Effect>;
  29873. /**
  29874. * Observable that will be called if an error occurs during shader compilation.
  29875. */
  29876. onErrorObservable: Observable<Effect>;
  29877. /** @hidden */
  29878. _onBindObservable: Nullable<Observable<Effect>>;
  29879. /**
  29880. * Observable that will be called when effect is bound.
  29881. */
  29882. readonly onBindObservable: Observable<Effect>;
  29883. /** @hidden */
  29884. _bonesComputationForcedToCPU: boolean;
  29885. private static _uniqueIdSeed;
  29886. private _engine;
  29887. private _uniformBuffersNames;
  29888. private _uniformsNames;
  29889. private _samplerList;
  29890. private _samplers;
  29891. private _isReady;
  29892. private _compilationError;
  29893. private _attributesNames;
  29894. private _attributes;
  29895. private _uniforms;
  29896. /**
  29897. * Key for the effect.
  29898. * @hidden
  29899. */
  29900. _key: string;
  29901. private _indexParameters;
  29902. private _fallbacks;
  29903. private _vertexSourceCode;
  29904. private _fragmentSourceCode;
  29905. private _vertexSourceCodeOverride;
  29906. private _fragmentSourceCodeOverride;
  29907. private _transformFeedbackVaryings;
  29908. /**
  29909. * Compiled shader to webGL program.
  29910. * @hidden
  29911. */
  29912. _pipelineContext: Nullable<IPipelineContext>;
  29913. private _valueCache;
  29914. private static _baseCache;
  29915. /**
  29916. * Instantiates an effect.
  29917. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29918. * @param baseName Name of the effect.
  29919. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29920. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29921. * @param samplers List of sampler variables that will be passed to the shader.
  29922. * @param engine Engine to be used to render the effect
  29923. * @param defines Define statements to be added to the shader.
  29924. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29925. * @param onCompiled Callback that will be called when the shader is compiled.
  29926. * @param onError Callback that will be called if an error occurs during shader compilation.
  29927. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29928. */
  29929. 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);
  29930. /**
  29931. * Unique key for this effect
  29932. */
  29933. readonly key: string;
  29934. /**
  29935. * If the effect has been compiled and prepared.
  29936. * @returns if the effect is compiled and prepared.
  29937. */
  29938. isReady(): boolean;
  29939. /**
  29940. * The engine the effect was initialized with.
  29941. * @returns the engine.
  29942. */
  29943. getEngine(): Engine;
  29944. /**
  29945. * The pipeline context for this effect
  29946. * @returns the associated pipeline context
  29947. */
  29948. getPipelineContext(): Nullable<IPipelineContext>;
  29949. /**
  29950. * The set of names of attribute variables for the shader.
  29951. * @returns An array of attribute names.
  29952. */
  29953. getAttributesNames(): string[];
  29954. /**
  29955. * Returns the attribute at the given index.
  29956. * @param index The index of the attribute.
  29957. * @returns The location of the attribute.
  29958. */
  29959. getAttributeLocation(index: number): number;
  29960. /**
  29961. * Returns the attribute based on the name of the variable.
  29962. * @param name of the attribute to look up.
  29963. * @returns the attribute location.
  29964. */
  29965. getAttributeLocationByName(name: string): number;
  29966. /**
  29967. * The number of attributes.
  29968. * @returns the numnber of attributes.
  29969. */
  29970. getAttributesCount(): number;
  29971. /**
  29972. * Gets the index of a uniform variable.
  29973. * @param uniformName of the uniform to look up.
  29974. * @returns the index.
  29975. */
  29976. getUniformIndex(uniformName: string): number;
  29977. /**
  29978. * Returns the attribute based on the name of the variable.
  29979. * @param uniformName of the uniform to look up.
  29980. * @returns the location of the uniform.
  29981. */
  29982. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29983. /**
  29984. * Returns an array of sampler variable names
  29985. * @returns The array of sampler variable neames.
  29986. */
  29987. getSamplers(): string[];
  29988. /**
  29989. * The error from the last compilation.
  29990. * @returns the error string.
  29991. */
  29992. getCompilationError(): string;
  29993. /**
  29994. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29995. * @param func The callback to be used.
  29996. */
  29997. executeWhenCompiled(func: (effect: Effect) => void): void;
  29998. private _checkIsReady;
  29999. /** @hidden */
  30000. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30001. /** @hidden */
  30002. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30003. /** @hidden */
  30004. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30005. private _processShaderConversion;
  30006. private _processIncludes;
  30007. private _processPrecision;
  30008. /**
  30009. * Recompiles the webGL program
  30010. * @param vertexSourceCode The source code for the vertex shader.
  30011. * @param fragmentSourceCode The source code for the fragment shader.
  30012. * @param onCompiled Callback called when completed.
  30013. * @param onError Callback called on error.
  30014. * @hidden
  30015. */
  30016. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30017. /**
  30018. * Prepares the effect
  30019. * @hidden
  30020. */
  30021. _prepareEffect(): void;
  30022. /**
  30023. * Checks if the effect is supported. (Must be called after compilation)
  30024. */
  30025. readonly isSupported: boolean;
  30026. /**
  30027. * Binds a texture to the engine to be used as output of the shader.
  30028. * @param channel Name of the output variable.
  30029. * @param texture Texture to bind.
  30030. * @hidden
  30031. */
  30032. _bindTexture(channel: string, texture: InternalTexture): void;
  30033. /**
  30034. * Sets a texture on the engine to be used in the shader.
  30035. * @param channel Name of the sampler variable.
  30036. * @param texture Texture to set.
  30037. */
  30038. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30039. /**
  30040. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30041. * @param channel Name of the sampler variable.
  30042. * @param texture Texture to set.
  30043. */
  30044. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30045. /**
  30046. * Sets an array of textures on the engine to be used in the shader.
  30047. * @param channel Name of the variable.
  30048. * @param textures Textures to set.
  30049. */
  30050. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30051. /**
  30052. * 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)
  30053. * @param channel Name of the sampler variable.
  30054. * @param postProcess Post process to get the input texture from.
  30055. */
  30056. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30057. /**
  30058. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30059. * 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)
  30060. * @param channel Name of the sampler variable.
  30061. * @param postProcess Post process to get the output texture from.
  30062. */
  30063. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30064. /** @hidden */
  30065. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30066. /** @hidden */
  30067. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30068. /** @hidden */
  30069. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30070. /** @hidden */
  30071. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30072. /**
  30073. * Binds a buffer to a uniform.
  30074. * @param buffer Buffer to bind.
  30075. * @param name Name of the uniform variable to bind to.
  30076. */
  30077. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30078. /**
  30079. * Binds block to a uniform.
  30080. * @param blockName Name of the block to bind.
  30081. * @param index Index to bind.
  30082. */
  30083. bindUniformBlock(blockName: string, index: number): void;
  30084. /**
  30085. * Sets an interger value on a uniform variable.
  30086. * @param uniformName Name of the variable.
  30087. * @param value Value to be set.
  30088. * @returns this effect.
  30089. */
  30090. setInt(uniformName: string, value: number): Effect;
  30091. /**
  30092. * Sets an int array on a uniform variable.
  30093. * @param uniformName Name of the variable.
  30094. * @param array array to be set.
  30095. * @returns this effect.
  30096. */
  30097. setIntArray(uniformName: string, array: Int32Array): Effect;
  30098. /**
  30099. * 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)
  30100. * @param uniformName Name of the variable.
  30101. * @param array array to be set.
  30102. * @returns this effect.
  30103. */
  30104. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30105. /**
  30106. * 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)
  30107. * @param uniformName Name of the variable.
  30108. * @param array array to be set.
  30109. * @returns this effect.
  30110. */
  30111. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30112. /**
  30113. * 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)
  30114. * @param uniformName Name of the variable.
  30115. * @param array array to be set.
  30116. * @returns this effect.
  30117. */
  30118. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30119. /**
  30120. * Sets an float array on a uniform variable.
  30121. * @param uniformName Name of the variable.
  30122. * @param array array to be set.
  30123. * @returns this effect.
  30124. */
  30125. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30126. /**
  30127. * 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)
  30128. * @param uniformName Name of the variable.
  30129. * @param array array to be set.
  30130. * @returns this effect.
  30131. */
  30132. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30133. /**
  30134. * 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)
  30135. * @param uniformName Name of the variable.
  30136. * @param array array to be set.
  30137. * @returns this effect.
  30138. */
  30139. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30140. /**
  30141. * 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)
  30142. * @param uniformName Name of the variable.
  30143. * @param array array to be set.
  30144. * @returns this effect.
  30145. */
  30146. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30147. /**
  30148. * Sets an array on a uniform variable.
  30149. * @param uniformName Name of the variable.
  30150. * @param array array to be set.
  30151. * @returns this effect.
  30152. */
  30153. setArray(uniformName: string, array: number[]): Effect;
  30154. /**
  30155. * 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)
  30156. * @param uniformName Name of the variable.
  30157. * @param array array to be set.
  30158. * @returns this effect.
  30159. */
  30160. setArray2(uniformName: string, array: number[]): Effect;
  30161. /**
  30162. * 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)
  30163. * @param uniformName Name of the variable.
  30164. * @param array array to be set.
  30165. * @returns this effect.
  30166. */
  30167. setArray3(uniformName: string, array: number[]): Effect;
  30168. /**
  30169. * 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)
  30170. * @param uniformName Name of the variable.
  30171. * @param array array to be set.
  30172. * @returns this effect.
  30173. */
  30174. setArray4(uniformName: string, array: number[]): Effect;
  30175. /**
  30176. * Sets matrices on a uniform variable.
  30177. * @param uniformName Name of the variable.
  30178. * @param matrices matrices to be set.
  30179. * @returns this effect.
  30180. */
  30181. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30182. /**
  30183. * Sets matrix on a uniform variable.
  30184. * @param uniformName Name of the variable.
  30185. * @param matrix matrix to be set.
  30186. * @returns this effect.
  30187. */
  30188. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30189. /**
  30190. * 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)
  30191. * @param uniformName Name of the variable.
  30192. * @param matrix matrix to be set.
  30193. * @returns this effect.
  30194. */
  30195. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30196. /**
  30197. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30198. * @param uniformName Name of the variable.
  30199. * @param matrix matrix to be set.
  30200. * @returns this effect.
  30201. */
  30202. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30203. /**
  30204. * Sets a float on a uniform variable.
  30205. * @param uniformName Name of the variable.
  30206. * @param value value to be set.
  30207. * @returns this effect.
  30208. */
  30209. setFloat(uniformName: string, value: number): Effect;
  30210. /**
  30211. * Sets a boolean on a uniform variable.
  30212. * @param uniformName Name of the variable.
  30213. * @param bool value to be set.
  30214. * @returns this effect.
  30215. */
  30216. setBool(uniformName: string, bool: boolean): Effect;
  30217. /**
  30218. * Sets a Vector2 on a uniform variable.
  30219. * @param uniformName Name of the variable.
  30220. * @param vector2 vector2 to be set.
  30221. * @returns this effect.
  30222. */
  30223. setVector2(uniformName: string, vector2: Vector2): Effect;
  30224. /**
  30225. * Sets a float2 on a uniform variable.
  30226. * @param uniformName Name of the variable.
  30227. * @param x First float in float2.
  30228. * @param y Second float in float2.
  30229. * @returns this effect.
  30230. */
  30231. setFloat2(uniformName: string, x: number, y: number): Effect;
  30232. /**
  30233. * Sets a Vector3 on a uniform variable.
  30234. * @param uniformName Name of the variable.
  30235. * @param vector3 Value to be set.
  30236. * @returns this effect.
  30237. */
  30238. setVector3(uniformName: string, vector3: Vector3): Effect;
  30239. /**
  30240. * Sets a float3 on a uniform variable.
  30241. * @param uniformName Name of the variable.
  30242. * @param x First float in float3.
  30243. * @param y Second float in float3.
  30244. * @param z Third float in float3.
  30245. * @returns this effect.
  30246. */
  30247. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30248. /**
  30249. * Sets a Vector4 on a uniform variable.
  30250. * @param uniformName Name of the variable.
  30251. * @param vector4 Value to be set.
  30252. * @returns this effect.
  30253. */
  30254. setVector4(uniformName: string, vector4: Vector4): Effect;
  30255. /**
  30256. * Sets a float4 on a uniform variable.
  30257. * @param uniformName Name of the variable.
  30258. * @param x First float in float4.
  30259. * @param y Second float in float4.
  30260. * @param z Third float in float4.
  30261. * @param w Fourth float in float4.
  30262. * @returns this effect.
  30263. */
  30264. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30265. /**
  30266. * Sets a Color3 on a uniform variable.
  30267. * @param uniformName Name of the variable.
  30268. * @param color3 Value to be set.
  30269. * @returns this effect.
  30270. */
  30271. setColor3(uniformName: string, color3: Color3): Effect;
  30272. /**
  30273. * Sets a Color4 on a uniform variable.
  30274. * @param uniformName Name of the variable.
  30275. * @param color3 Value to be set.
  30276. * @param alpha Alpha value to be set.
  30277. * @returns this effect.
  30278. */
  30279. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30280. /**
  30281. * Sets a Color4 on a uniform variable
  30282. * @param uniformName defines the name of the variable
  30283. * @param color4 defines the value to be set
  30284. * @returns this effect.
  30285. */
  30286. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30287. /** Release all associated resources */
  30288. dispose(): void;
  30289. /**
  30290. * This function will add a new shader to the shader store
  30291. * @param name the name of the shader
  30292. * @param pixelShader optional pixel shader content
  30293. * @param vertexShader optional vertex shader content
  30294. */
  30295. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30296. /**
  30297. * Store of each shader (The can be looked up using effect.key)
  30298. */
  30299. static ShadersStore: {
  30300. [key: string]: string;
  30301. };
  30302. /**
  30303. * Store of each included file for a shader (The can be looked up using effect.key)
  30304. */
  30305. static IncludesShadersStore: {
  30306. [key: string]: string;
  30307. };
  30308. /**
  30309. * Resets the cache of effects.
  30310. */
  30311. static ResetCache(): void;
  30312. }
  30313. }
  30314. declare module "babylonjs/Materials/colorCurves" {
  30315. import { Effect } from "babylonjs/Materials/effect";
  30316. /**
  30317. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30318. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30319. * 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;
  30320. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30321. */
  30322. export class ColorCurves {
  30323. private _dirty;
  30324. private _tempColor;
  30325. private _globalCurve;
  30326. private _highlightsCurve;
  30327. private _midtonesCurve;
  30328. private _shadowsCurve;
  30329. private _positiveCurve;
  30330. private _negativeCurve;
  30331. private _globalHue;
  30332. private _globalDensity;
  30333. private _globalSaturation;
  30334. private _globalExposure;
  30335. /**
  30336. * Gets the global Hue value.
  30337. * 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).
  30338. */
  30339. /**
  30340. * Sets the global Hue value.
  30341. * 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).
  30342. */
  30343. globalHue: number;
  30344. /**
  30345. * Gets the global Density value.
  30346. * 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.
  30347. * Values less than zero provide a filter of opposite hue.
  30348. */
  30349. /**
  30350. * Sets the global Density value.
  30351. * 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.
  30352. * Values less than zero provide a filter of opposite hue.
  30353. */
  30354. globalDensity: number;
  30355. /**
  30356. * Gets the global Saturation value.
  30357. * 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.
  30358. */
  30359. /**
  30360. * Sets the global Saturation value.
  30361. * 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.
  30362. */
  30363. globalSaturation: number;
  30364. /**
  30365. * Gets the global Exposure value.
  30366. * 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.
  30367. */
  30368. /**
  30369. * Sets the global Exposure value.
  30370. * 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.
  30371. */
  30372. globalExposure: number;
  30373. private _highlightsHue;
  30374. private _highlightsDensity;
  30375. private _highlightsSaturation;
  30376. private _highlightsExposure;
  30377. /**
  30378. * Gets the highlights Hue value.
  30379. * 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).
  30380. */
  30381. /**
  30382. * Sets the highlights Hue value.
  30383. * 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).
  30384. */
  30385. highlightsHue: number;
  30386. /**
  30387. * Gets the highlights Density value.
  30388. * 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.
  30389. * Values less than zero provide a filter of opposite hue.
  30390. */
  30391. /**
  30392. * Sets the highlights Density value.
  30393. * 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.
  30394. * Values less than zero provide a filter of opposite hue.
  30395. */
  30396. highlightsDensity: number;
  30397. /**
  30398. * Gets the highlights Saturation value.
  30399. * 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.
  30400. */
  30401. /**
  30402. * Sets the highlights Saturation value.
  30403. * 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.
  30404. */
  30405. highlightsSaturation: number;
  30406. /**
  30407. * Gets the highlights Exposure value.
  30408. * 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.
  30409. */
  30410. /**
  30411. * Sets the highlights Exposure value.
  30412. * 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.
  30413. */
  30414. highlightsExposure: number;
  30415. private _midtonesHue;
  30416. private _midtonesDensity;
  30417. private _midtonesSaturation;
  30418. private _midtonesExposure;
  30419. /**
  30420. * Gets the midtones Hue value.
  30421. * 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).
  30422. */
  30423. /**
  30424. * Sets the midtones Hue value.
  30425. * 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).
  30426. */
  30427. midtonesHue: number;
  30428. /**
  30429. * Gets the midtones Density value.
  30430. * 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.
  30431. * Values less than zero provide a filter of opposite hue.
  30432. */
  30433. /**
  30434. * Sets the midtones Density value.
  30435. * 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.
  30436. * Values less than zero provide a filter of opposite hue.
  30437. */
  30438. midtonesDensity: number;
  30439. /**
  30440. * Gets the midtones Saturation value.
  30441. * 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.
  30442. */
  30443. /**
  30444. * Sets the midtones Saturation value.
  30445. * 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.
  30446. */
  30447. midtonesSaturation: number;
  30448. /**
  30449. * Gets the midtones Exposure value.
  30450. * 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.
  30451. */
  30452. /**
  30453. * Sets the midtones Exposure value.
  30454. * 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.
  30455. */
  30456. midtonesExposure: number;
  30457. private _shadowsHue;
  30458. private _shadowsDensity;
  30459. private _shadowsSaturation;
  30460. private _shadowsExposure;
  30461. /**
  30462. * Gets the shadows Hue value.
  30463. * 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).
  30464. */
  30465. /**
  30466. * Sets the shadows Hue value.
  30467. * 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).
  30468. */
  30469. shadowsHue: number;
  30470. /**
  30471. * Gets the shadows Density value.
  30472. * 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.
  30473. * Values less than zero provide a filter of opposite hue.
  30474. */
  30475. /**
  30476. * Sets the shadows Density value.
  30477. * 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.
  30478. * Values less than zero provide a filter of opposite hue.
  30479. */
  30480. shadowsDensity: number;
  30481. /**
  30482. * Gets the shadows Saturation value.
  30483. * 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.
  30484. */
  30485. /**
  30486. * Sets the shadows Saturation value.
  30487. * 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.
  30488. */
  30489. shadowsSaturation: number;
  30490. /**
  30491. * Gets the shadows Exposure value.
  30492. * 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.
  30493. */
  30494. /**
  30495. * Sets the shadows Exposure value.
  30496. * 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.
  30497. */
  30498. shadowsExposure: number;
  30499. /**
  30500. * Returns the class name
  30501. * @returns The class name
  30502. */
  30503. getClassName(): string;
  30504. /**
  30505. * Binds the color curves to the shader.
  30506. * @param colorCurves The color curve to bind
  30507. * @param effect The effect to bind to
  30508. * @param positiveUniform The positive uniform shader parameter
  30509. * @param neutralUniform The neutral uniform shader parameter
  30510. * @param negativeUniform The negative uniform shader parameter
  30511. */
  30512. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30513. /**
  30514. * Prepare the list of uniforms associated with the ColorCurves effects.
  30515. * @param uniformsList The list of uniforms used in the effect
  30516. */
  30517. static PrepareUniforms(uniformsList: string[]): void;
  30518. /**
  30519. * Returns color grading data based on a hue, density, saturation and exposure value.
  30520. * @param filterHue The hue of the color filter.
  30521. * @param filterDensity The density of the color filter.
  30522. * @param saturation The saturation.
  30523. * @param exposure The exposure.
  30524. * @param result The result data container.
  30525. */
  30526. private getColorGradingDataToRef;
  30527. /**
  30528. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30529. * @param value The input slider value in range [-100,100].
  30530. * @returns Adjusted value.
  30531. */
  30532. private static applyColorGradingSliderNonlinear;
  30533. /**
  30534. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30535. * @param hue The hue (H) input.
  30536. * @param saturation The saturation (S) input.
  30537. * @param brightness The brightness (B) input.
  30538. * @result An RGBA color represented as Vector4.
  30539. */
  30540. private static fromHSBToRef;
  30541. /**
  30542. * Returns a value clamped between min and max
  30543. * @param value The value to clamp
  30544. * @param min The minimum of value
  30545. * @param max The maximum of value
  30546. * @returns The clamped value.
  30547. */
  30548. private static clamp;
  30549. /**
  30550. * Clones the current color curve instance.
  30551. * @return The cloned curves
  30552. */
  30553. clone(): ColorCurves;
  30554. /**
  30555. * Serializes the current color curve instance to a json representation.
  30556. * @return a JSON representation
  30557. */
  30558. serialize(): any;
  30559. /**
  30560. * Parses the color curve from a json representation.
  30561. * @param source the JSON source to parse
  30562. * @return The parsed curves
  30563. */
  30564. static Parse(source: any): ColorCurves;
  30565. }
  30566. }
  30567. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30568. import { Observable } from "babylonjs/Misc/observable";
  30569. import { Nullable } from "babylonjs/types";
  30570. import { Color4 } from "babylonjs/Maths/math";
  30571. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30572. import { Effect } from "babylonjs/Materials/effect";
  30573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30574. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30575. /**
  30576. * Interface to follow in your material defines to integrate easily the
  30577. * Image proccessing functions.
  30578. * @hidden
  30579. */
  30580. export interface IImageProcessingConfigurationDefines {
  30581. IMAGEPROCESSING: boolean;
  30582. VIGNETTE: boolean;
  30583. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30584. VIGNETTEBLENDMODEOPAQUE: boolean;
  30585. TONEMAPPING: boolean;
  30586. TONEMAPPING_ACES: boolean;
  30587. CONTRAST: boolean;
  30588. EXPOSURE: boolean;
  30589. COLORCURVES: boolean;
  30590. COLORGRADING: boolean;
  30591. COLORGRADING3D: boolean;
  30592. SAMPLER3DGREENDEPTH: boolean;
  30593. SAMPLER3DBGRMAP: boolean;
  30594. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30595. }
  30596. /**
  30597. * @hidden
  30598. */
  30599. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30600. IMAGEPROCESSING: boolean;
  30601. VIGNETTE: boolean;
  30602. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30603. VIGNETTEBLENDMODEOPAQUE: boolean;
  30604. TONEMAPPING: boolean;
  30605. TONEMAPPING_ACES: boolean;
  30606. CONTRAST: boolean;
  30607. COLORCURVES: boolean;
  30608. COLORGRADING: boolean;
  30609. COLORGRADING3D: boolean;
  30610. SAMPLER3DGREENDEPTH: boolean;
  30611. SAMPLER3DBGRMAP: boolean;
  30612. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30613. EXPOSURE: boolean;
  30614. constructor();
  30615. }
  30616. /**
  30617. * This groups together the common properties used for image processing either in direct forward pass
  30618. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30619. * or not.
  30620. */
  30621. export class ImageProcessingConfiguration {
  30622. /**
  30623. * Default tone mapping applied in BabylonJS.
  30624. */
  30625. static readonly TONEMAPPING_STANDARD: number;
  30626. /**
  30627. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30628. * to other engines rendering to increase portability.
  30629. */
  30630. static readonly TONEMAPPING_ACES: number;
  30631. /**
  30632. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30633. */
  30634. colorCurves: Nullable<ColorCurves>;
  30635. private _colorCurvesEnabled;
  30636. /**
  30637. * Gets wether the color curves effect is enabled.
  30638. */
  30639. /**
  30640. * Sets wether the color curves effect is enabled.
  30641. */
  30642. colorCurvesEnabled: boolean;
  30643. private _colorGradingTexture;
  30644. /**
  30645. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30646. */
  30647. /**
  30648. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30649. */
  30650. colorGradingTexture: Nullable<BaseTexture>;
  30651. private _colorGradingEnabled;
  30652. /**
  30653. * Gets wether the color grading effect is enabled.
  30654. */
  30655. /**
  30656. * Sets wether the color grading effect is enabled.
  30657. */
  30658. colorGradingEnabled: boolean;
  30659. private _colorGradingWithGreenDepth;
  30660. /**
  30661. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30662. */
  30663. /**
  30664. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30665. */
  30666. colorGradingWithGreenDepth: boolean;
  30667. private _colorGradingBGR;
  30668. /**
  30669. * Gets wether the color grading texture contains BGR values.
  30670. */
  30671. /**
  30672. * Sets wether the color grading texture contains BGR values.
  30673. */
  30674. colorGradingBGR: boolean;
  30675. /** @hidden */
  30676. _exposure: number;
  30677. /**
  30678. * Gets the Exposure used in the effect.
  30679. */
  30680. /**
  30681. * Sets the Exposure used in the effect.
  30682. */
  30683. exposure: number;
  30684. private _toneMappingEnabled;
  30685. /**
  30686. * Gets wether the tone mapping effect is enabled.
  30687. */
  30688. /**
  30689. * Sets wether the tone mapping effect is enabled.
  30690. */
  30691. toneMappingEnabled: boolean;
  30692. private _toneMappingType;
  30693. /**
  30694. * Gets the type of tone mapping effect.
  30695. */
  30696. /**
  30697. * Sets the type of tone mapping effect used in BabylonJS.
  30698. */
  30699. toneMappingType: number;
  30700. protected _contrast: number;
  30701. /**
  30702. * Gets the contrast used in the effect.
  30703. */
  30704. /**
  30705. * Sets the contrast used in the effect.
  30706. */
  30707. contrast: number;
  30708. /**
  30709. * Vignette stretch size.
  30710. */
  30711. vignetteStretch: number;
  30712. /**
  30713. * Vignette centre X Offset.
  30714. */
  30715. vignetteCentreX: number;
  30716. /**
  30717. * Vignette centre Y Offset.
  30718. */
  30719. vignetteCentreY: number;
  30720. /**
  30721. * Vignette weight or intensity of the vignette effect.
  30722. */
  30723. vignetteWeight: number;
  30724. /**
  30725. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30726. * if vignetteEnabled is set to true.
  30727. */
  30728. vignetteColor: Color4;
  30729. /**
  30730. * Camera field of view used by the Vignette effect.
  30731. */
  30732. vignetteCameraFov: number;
  30733. private _vignetteBlendMode;
  30734. /**
  30735. * Gets the vignette blend mode allowing different kind of effect.
  30736. */
  30737. /**
  30738. * Sets the vignette blend mode allowing different kind of effect.
  30739. */
  30740. vignetteBlendMode: number;
  30741. private _vignetteEnabled;
  30742. /**
  30743. * Gets wether the vignette effect is enabled.
  30744. */
  30745. /**
  30746. * Sets wether the vignette effect is enabled.
  30747. */
  30748. vignetteEnabled: boolean;
  30749. private _applyByPostProcess;
  30750. /**
  30751. * Gets wether the image processing is applied through a post process or not.
  30752. */
  30753. /**
  30754. * Sets wether the image processing is applied through a post process or not.
  30755. */
  30756. applyByPostProcess: boolean;
  30757. private _isEnabled;
  30758. /**
  30759. * Gets wether the image processing is enabled or not.
  30760. */
  30761. /**
  30762. * Sets wether the image processing is enabled or not.
  30763. */
  30764. isEnabled: boolean;
  30765. /**
  30766. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30767. */
  30768. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30769. /**
  30770. * Method called each time the image processing information changes requires to recompile the effect.
  30771. */
  30772. protected _updateParameters(): void;
  30773. /**
  30774. * Gets the current class name.
  30775. * @return "ImageProcessingConfiguration"
  30776. */
  30777. getClassName(): string;
  30778. /**
  30779. * Prepare the list of uniforms associated with the Image Processing effects.
  30780. * @param uniforms The list of uniforms used in the effect
  30781. * @param defines the list of defines currently in use
  30782. */
  30783. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30784. /**
  30785. * Prepare the list of samplers associated with the Image Processing effects.
  30786. * @param samplersList The list of uniforms used in the effect
  30787. * @param defines the list of defines currently in use
  30788. */
  30789. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30790. /**
  30791. * Prepare the list of defines associated to the shader.
  30792. * @param defines the list of defines to complete
  30793. * @param forPostProcess Define if we are currently in post process mode or not
  30794. */
  30795. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30796. /**
  30797. * Returns true if all the image processing information are ready.
  30798. * @returns True if ready, otherwise, false
  30799. */
  30800. isReady(): boolean;
  30801. /**
  30802. * Binds the image processing to the shader.
  30803. * @param effect The effect to bind to
  30804. * @param aspectRatio Define the current aspect ratio of the effect
  30805. */
  30806. bind(effect: Effect, aspectRatio?: number): void;
  30807. /**
  30808. * Clones the current image processing instance.
  30809. * @return The cloned image processing
  30810. */
  30811. clone(): ImageProcessingConfiguration;
  30812. /**
  30813. * Serializes the current image processing instance to a json representation.
  30814. * @return a JSON representation
  30815. */
  30816. serialize(): any;
  30817. /**
  30818. * Parses the image processing from a json representation.
  30819. * @param source the JSON source to parse
  30820. * @return The parsed image processing
  30821. */
  30822. static Parse(source: any): ImageProcessingConfiguration;
  30823. private static _VIGNETTEMODE_MULTIPLY;
  30824. private static _VIGNETTEMODE_OPAQUE;
  30825. /**
  30826. * Used to apply the vignette as a mix with the pixel color.
  30827. */
  30828. static readonly VIGNETTEMODE_MULTIPLY: number;
  30829. /**
  30830. * Used to apply the vignette as a replacement of the pixel color.
  30831. */
  30832. static readonly VIGNETTEMODE_OPAQUE: number;
  30833. }
  30834. }
  30835. declare module "babylonjs/Materials/fresnelParameters" {
  30836. import { Color3 } from "babylonjs/Maths/math";
  30837. /**
  30838. * This represents all the required information to add a fresnel effect on a material:
  30839. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30840. */
  30841. export class FresnelParameters {
  30842. private _isEnabled;
  30843. /**
  30844. * Define if the fresnel effect is enable or not.
  30845. */
  30846. isEnabled: boolean;
  30847. /**
  30848. * Define the color used on edges (grazing angle)
  30849. */
  30850. leftColor: Color3;
  30851. /**
  30852. * Define the color used on center
  30853. */
  30854. rightColor: Color3;
  30855. /**
  30856. * Define bias applied to computed fresnel term
  30857. */
  30858. bias: number;
  30859. /**
  30860. * Defined the power exponent applied to fresnel term
  30861. */
  30862. power: number;
  30863. /**
  30864. * Clones the current fresnel and its valuues
  30865. * @returns a clone fresnel configuration
  30866. */
  30867. clone(): FresnelParameters;
  30868. /**
  30869. * Serializes the current fresnel parameters to a JSON representation.
  30870. * @return the JSON serialization
  30871. */
  30872. serialize(): any;
  30873. /**
  30874. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30875. * @param parsedFresnelParameters Define the JSON representation
  30876. * @returns the parsed parameters
  30877. */
  30878. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30879. }
  30880. }
  30881. declare module "babylonjs/Misc/decorators" {
  30882. import { Nullable } from "babylonjs/types";
  30883. import { Scene } from "babylonjs/scene";
  30884. import { IAnimatable } from "babylonjs/Misc/tools";
  30885. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30886. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30887. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30888. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30889. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30890. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30891. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30892. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30893. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30894. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30895. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30896. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30897. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30898. /**
  30899. * Decorator used to define property that can be serialized as reference to a camera
  30900. * @param sourceName defines the name of the property to decorate
  30901. */
  30902. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30903. /**
  30904. * Class used to help serialization objects
  30905. */
  30906. export class SerializationHelper {
  30907. /** hidden */
  30908. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30909. /** hidden */
  30910. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30911. /** hidden */
  30912. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30913. /** hidden */
  30914. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30915. /**
  30916. * Appends the serialized animations from the source animations
  30917. * @param source Source containing the animations
  30918. * @param destination Target to store the animations
  30919. */
  30920. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30921. /**
  30922. * Static function used to serialized a specific entity
  30923. * @param entity defines the entity to serialize
  30924. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30925. * @returns a JSON compatible object representing the serialization of the entity
  30926. */
  30927. static Serialize<T>(entity: T, serializationObject?: any): any;
  30928. /**
  30929. * Creates a new entity from a serialization data object
  30930. * @param creationFunction defines a function used to instanciated the new entity
  30931. * @param source defines the source serialization data
  30932. * @param scene defines the hosting scene
  30933. * @param rootUrl defines the root url for resources
  30934. * @returns a new entity
  30935. */
  30936. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30937. /**
  30938. * Clones an object
  30939. * @param creationFunction defines the function used to instanciate the new object
  30940. * @param source defines the source object
  30941. * @returns the cloned object
  30942. */
  30943. static Clone<T>(creationFunction: () => T, source: T): T;
  30944. /**
  30945. * Instanciates a new object based on a source one (some data will be shared between both object)
  30946. * @param creationFunction defines the function used to instanciate the new object
  30947. * @param source defines the source object
  30948. * @returns the new object
  30949. */
  30950. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30951. }
  30952. }
  30953. declare module "babylonjs/Cameras/camera" {
  30954. import { SmartArray } from "babylonjs/Misc/smartArray";
  30955. import { Observable } from "babylonjs/Misc/observable";
  30956. import { Nullable } from "babylonjs/types";
  30957. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30958. import { Scene } from "babylonjs/scene";
  30959. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30960. import { Node } from "babylonjs/node";
  30961. import { Mesh } from "babylonjs/Meshes/mesh";
  30962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30963. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30964. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30966. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30967. import { Ray } from "babylonjs/Culling/ray";
  30968. /**
  30969. * This is the base class of all the camera used in the application.
  30970. * @see http://doc.babylonjs.com/features/cameras
  30971. */
  30972. export class Camera extends Node {
  30973. /** @hidden */
  30974. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30975. /**
  30976. * This is the default projection mode used by the cameras.
  30977. * It helps recreating a feeling of perspective and better appreciate depth.
  30978. * This is the best way to simulate real life cameras.
  30979. */
  30980. static readonly PERSPECTIVE_CAMERA: number;
  30981. /**
  30982. * This helps creating camera with an orthographic mode.
  30983. * 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.
  30984. */
  30985. static readonly ORTHOGRAPHIC_CAMERA: number;
  30986. /**
  30987. * This is the default FOV mode for perspective cameras.
  30988. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30989. */
  30990. static readonly FOVMODE_VERTICAL_FIXED: number;
  30991. /**
  30992. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30993. */
  30994. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30995. /**
  30996. * This specifies ther is no need for a camera rig.
  30997. * Basically only one eye is rendered corresponding to the camera.
  30998. */
  30999. static readonly RIG_MODE_NONE: number;
  31000. /**
  31001. * Simulates a camera Rig with one blue eye and one red eye.
  31002. * This can be use with 3d blue and red glasses.
  31003. */
  31004. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31005. /**
  31006. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31007. */
  31008. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31009. /**
  31010. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31011. */
  31012. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31013. /**
  31014. * Defines that both eyes of the camera will be rendered over under each other.
  31015. */
  31016. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31017. /**
  31018. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31019. */
  31020. static readonly RIG_MODE_VR: number;
  31021. /**
  31022. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31023. */
  31024. static readonly RIG_MODE_WEBVR: number;
  31025. /**
  31026. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31027. */
  31028. static readonly RIG_MODE_CUSTOM: number;
  31029. /**
  31030. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31031. */
  31032. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31033. /**
  31034. * Define the input manager associated with the camera.
  31035. */
  31036. inputs: CameraInputsManager<Camera>;
  31037. /** @hidden */
  31038. _position: Vector3;
  31039. /**
  31040. * Define the current local position of the camera in the scene
  31041. */
  31042. position: Vector3;
  31043. /**
  31044. * The vector the camera should consider as up.
  31045. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31046. */
  31047. upVector: Vector3;
  31048. /**
  31049. * Define the current limit on the left side for an orthographic camera
  31050. * In scene unit
  31051. */
  31052. orthoLeft: Nullable<number>;
  31053. /**
  31054. * Define the current limit on the right side for an orthographic camera
  31055. * In scene unit
  31056. */
  31057. orthoRight: Nullable<number>;
  31058. /**
  31059. * Define the current limit on the bottom side for an orthographic camera
  31060. * In scene unit
  31061. */
  31062. orthoBottom: Nullable<number>;
  31063. /**
  31064. * Define the current limit on the top side for an orthographic camera
  31065. * In scene unit
  31066. */
  31067. orthoTop: Nullable<number>;
  31068. /**
  31069. * Field Of View is set in Radians. (default is 0.8)
  31070. */
  31071. fov: number;
  31072. /**
  31073. * Define the minimum distance the camera can see from.
  31074. * This is important to note that the depth buffer are not infinite and the closer it starts
  31075. * the more your scene might encounter depth fighting issue.
  31076. */
  31077. minZ: number;
  31078. /**
  31079. * Define the maximum distance the camera can see to.
  31080. * This is important to note that the depth buffer are not infinite and the further it end
  31081. * the more your scene might encounter depth fighting issue.
  31082. */
  31083. maxZ: number;
  31084. /**
  31085. * Define the default inertia of the camera.
  31086. * This helps giving a smooth feeling to the camera movement.
  31087. */
  31088. inertia: number;
  31089. /**
  31090. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31091. */
  31092. mode: number;
  31093. /**
  31094. * Define wether the camera is intermediate.
  31095. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31096. */
  31097. isIntermediate: boolean;
  31098. /**
  31099. * Define the viewport of the camera.
  31100. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31101. */
  31102. viewport: Viewport;
  31103. /**
  31104. * Restricts the camera to viewing objects with the same layerMask.
  31105. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31106. */
  31107. layerMask: number;
  31108. /**
  31109. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31110. */
  31111. fovMode: number;
  31112. /**
  31113. * Rig mode of the camera.
  31114. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31115. * This is normally controlled byt the camera themselves as internal use.
  31116. */
  31117. cameraRigMode: number;
  31118. /**
  31119. * Defines the distance between both "eyes" in case of a RIG
  31120. */
  31121. interaxialDistance: number;
  31122. /**
  31123. * Defines if stereoscopic rendering is done side by side or over under.
  31124. */
  31125. isStereoscopicSideBySide: boolean;
  31126. /**
  31127. * 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
  31128. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31129. * else in the scene.
  31130. */
  31131. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31132. /**
  31133. * When set, the camera will render to this render target instead of the default canvas
  31134. */
  31135. outputRenderTarget: Nullable<RenderTargetTexture>;
  31136. /**
  31137. * Observable triggered when the camera view matrix has changed.
  31138. */
  31139. onViewMatrixChangedObservable: Observable<Camera>;
  31140. /**
  31141. * Observable triggered when the camera Projection matrix has changed.
  31142. */
  31143. onProjectionMatrixChangedObservable: Observable<Camera>;
  31144. /**
  31145. * Observable triggered when the inputs have been processed.
  31146. */
  31147. onAfterCheckInputsObservable: Observable<Camera>;
  31148. /**
  31149. * Observable triggered when reset has been called and applied to the camera.
  31150. */
  31151. onRestoreStateObservable: Observable<Camera>;
  31152. /** @hidden */
  31153. _cameraRigParams: any;
  31154. /** @hidden */
  31155. _rigCameras: Camera[];
  31156. /** @hidden */
  31157. _rigPostProcess: Nullable<PostProcess>;
  31158. protected _webvrViewMatrix: Matrix;
  31159. /** @hidden */
  31160. _skipRendering: boolean;
  31161. /** @hidden */
  31162. _projectionMatrix: Matrix;
  31163. /** @hidden */
  31164. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31165. /** @hidden */
  31166. _activeMeshes: SmartArray<AbstractMesh>;
  31167. protected _globalPosition: Vector3;
  31168. /** hidden */
  31169. _computedViewMatrix: Matrix;
  31170. private _doNotComputeProjectionMatrix;
  31171. private _transformMatrix;
  31172. private _frustumPlanes;
  31173. private _refreshFrustumPlanes;
  31174. private _storedFov;
  31175. private _stateStored;
  31176. /**
  31177. * Instantiates a new camera object.
  31178. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31179. * @see http://doc.babylonjs.com/features/cameras
  31180. * @param name Defines the name of the camera in the scene
  31181. * @param position Defines the position of the camera
  31182. * @param scene Defines the scene the camera belongs too
  31183. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31184. */
  31185. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31186. /**
  31187. * Store current camera state (fov, position, etc..)
  31188. * @returns the camera
  31189. */
  31190. storeState(): Camera;
  31191. /**
  31192. * Restores the camera state values if it has been stored. You must call storeState() first
  31193. */
  31194. protected _restoreStateValues(): boolean;
  31195. /**
  31196. * Restored camera state. You must call storeState() first.
  31197. * @returns true if restored and false otherwise
  31198. */
  31199. restoreState(): boolean;
  31200. /**
  31201. * Gets the class name of the camera.
  31202. * @returns the class name
  31203. */
  31204. getClassName(): string;
  31205. /** @hidden */
  31206. readonly _isCamera: boolean;
  31207. /**
  31208. * Gets a string representation of the camera useful for debug purpose.
  31209. * @param fullDetails Defines that a more verboe level of logging is required
  31210. * @returns the string representation
  31211. */
  31212. toString(fullDetails?: boolean): string;
  31213. /**
  31214. * Gets the current world space position of the camera.
  31215. */
  31216. readonly globalPosition: Vector3;
  31217. /**
  31218. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31219. * @returns the active meshe list
  31220. */
  31221. getActiveMeshes(): SmartArray<AbstractMesh>;
  31222. /**
  31223. * Check wether a mesh is part of the current active mesh list of the camera
  31224. * @param mesh Defines the mesh to check
  31225. * @returns true if active, false otherwise
  31226. */
  31227. isActiveMesh(mesh: Mesh): boolean;
  31228. /**
  31229. * Is this camera ready to be used/rendered
  31230. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31231. * @return true if the camera is ready
  31232. */
  31233. isReady(completeCheck?: boolean): boolean;
  31234. /** @hidden */
  31235. _initCache(): void;
  31236. /** @hidden */
  31237. _updateCache(ignoreParentClass?: boolean): void;
  31238. /** @hidden */
  31239. _isSynchronized(): boolean;
  31240. /** @hidden */
  31241. _isSynchronizedViewMatrix(): boolean;
  31242. /** @hidden */
  31243. _isSynchronizedProjectionMatrix(): boolean;
  31244. /**
  31245. * Attach the input controls to a specific dom element to get the input from.
  31246. * @param element Defines the element the controls should be listened from
  31247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31248. */
  31249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31250. /**
  31251. * Detach the current controls from the specified dom element.
  31252. * @param element Defines the element to stop listening the inputs from
  31253. */
  31254. detachControl(element: HTMLElement): void;
  31255. /**
  31256. * Update the camera state according to the different inputs gathered during the frame.
  31257. */
  31258. update(): void;
  31259. /** @hidden */
  31260. _checkInputs(): void;
  31261. /** @hidden */
  31262. readonly rigCameras: Camera[];
  31263. /**
  31264. * Gets the post process used by the rig cameras
  31265. */
  31266. readonly rigPostProcess: Nullable<PostProcess>;
  31267. /**
  31268. * Internal, gets the first post proces.
  31269. * @returns the first post process to be run on this camera.
  31270. */
  31271. _getFirstPostProcess(): Nullable<PostProcess>;
  31272. private _cascadePostProcessesToRigCams;
  31273. /**
  31274. * Attach a post process to the camera.
  31275. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31276. * @param postProcess The post process to attach to the camera
  31277. * @param insertAt The position of the post process in case several of them are in use in the scene
  31278. * @returns the position the post process has been inserted at
  31279. */
  31280. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31281. /**
  31282. * Detach a post process to the camera.
  31283. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31284. * @param postProcess The post process to detach from the camera
  31285. */
  31286. detachPostProcess(postProcess: PostProcess): void;
  31287. /**
  31288. * Gets the current world matrix of the camera
  31289. */
  31290. getWorldMatrix(): Matrix;
  31291. /** @hidden */
  31292. _getViewMatrix(): Matrix;
  31293. /**
  31294. * Gets the current view matrix of the camera.
  31295. * @param force forces the camera to recompute the matrix without looking at the cached state
  31296. * @returns the view matrix
  31297. */
  31298. getViewMatrix(force?: boolean): Matrix;
  31299. /**
  31300. * Freeze the projection matrix.
  31301. * It will prevent the cache check of the camera projection compute and can speed up perf
  31302. * if no parameter of the camera are meant to change
  31303. * @param projection Defines manually a projection if necessary
  31304. */
  31305. freezeProjectionMatrix(projection?: Matrix): void;
  31306. /**
  31307. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31308. */
  31309. unfreezeProjectionMatrix(): void;
  31310. /**
  31311. * Gets the current projection matrix of the camera.
  31312. * @param force forces the camera to recompute the matrix without looking at the cached state
  31313. * @returns the projection matrix
  31314. */
  31315. getProjectionMatrix(force?: boolean): Matrix;
  31316. /**
  31317. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31318. * @returns a Matrix
  31319. */
  31320. getTransformationMatrix(): Matrix;
  31321. private _updateFrustumPlanes;
  31322. /**
  31323. * Checks if a cullable object (mesh...) is in the camera frustum
  31324. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31325. * @param target The object to check
  31326. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31327. * @returns true if the object is in frustum otherwise false
  31328. */
  31329. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31330. /**
  31331. * Checks if a cullable object (mesh...) is in the camera frustum
  31332. * Unlike isInFrustum this cheks the full bounding box
  31333. * @param target The object to check
  31334. * @returns true if the object is in frustum otherwise false
  31335. */
  31336. isCompletelyInFrustum(target: ICullable): boolean;
  31337. /**
  31338. * Gets a ray in the forward direction from the camera.
  31339. * @param length Defines the length of the ray to create
  31340. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31341. * @param origin Defines the start point of the ray which defaults to the camera position
  31342. * @returns the forward ray
  31343. */
  31344. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31345. /**
  31346. * Releases resources associated with this node.
  31347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31349. */
  31350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31351. /** @hidden */
  31352. _isLeftCamera: boolean;
  31353. /**
  31354. * Gets the left camera of a rig setup in case of Rigged Camera
  31355. */
  31356. readonly isLeftCamera: boolean;
  31357. /** @hidden */
  31358. _isRightCamera: boolean;
  31359. /**
  31360. * Gets the right camera of a rig setup in case of Rigged Camera
  31361. */
  31362. readonly isRightCamera: boolean;
  31363. /**
  31364. * Gets the left camera of a rig setup in case of Rigged Camera
  31365. */
  31366. readonly leftCamera: Nullable<FreeCamera>;
  31367. /**
  31368. * Gets the right camera of a rig setup in case of Rigged Camera
  31369. */
  31370. readonly rightCamera: Nullable<FreeCamera>;
  31371. /**
  31372. * Gets the left camera target of a rig setup in case of Rigged Camera
  31373. * @returns the target position
  31374. */
  31375. getLeftTarget(): Nullable<Vector3>;
  31376. /**
  31377. * Gets the right camera target of a rig setup in case of Rigged Camera
  31378. * @returns the target position
  31379. */
  31380. getRightTarget(): Nullable<Vector3>;
  31381. /**
  31382. * @hidden
  31383. */
  31384. setCameraRigMode(mode: number, rigParams: any): void;
  31385. /** @hidden */
  31386. static _setStereoscopicRigMode(camera: Camera): void;
  31387. /** @hidden */
  31388. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31389. /** @hidden */
  31390. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31391. /** @hidden */
  31392. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31393. /** @hidden */
  31394. _getVRProjectionMatrix(): Matrix;
  31395. protected _updateCameraRotationMatrix(): void;
  31396. protected _updateWebVRCameraRotationMatrix(): void;
  31397. /**
  31398. * This function MUST be overwritten by the different WebVR cameras available.
  31399. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31400. * @hidden
  31401. */
  31402. _getWebVRProjectionMatrix(): Matrix;
  31403. /**
  31404. * This function MUST be overwritten by the different WebVR cameras available.
  31405. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31406. * @hidden
  31407. */
  31408. _getWebVRViewMatrix(): Matrix;
  31409. /** @hidden */
  31410. setCameraRigParameter(name: string, value: any): void;
  31411. /**
  31412. * needs to be overridden by children so sub has required properties to be copied
  31413. * @hidden
  31414. */
  31415. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31416. /**
  31417. * May need to be overridden by children
  31418. * @hidden
  31419. */
  31420. _updateRigCameras(): void;
  31421. /** @hidden */
  31422. _setupInputs(): void;
  31423. /**
  31424. * Serialiaze the camera setup to a json represention
  31425. * @returns the JSON representation
  31426. */
  31427. serialize(): any;
  31428. /**
  31429. * Clones the current camera.
  31430. * @param name The cloned camera name
  31431. * @returns the cloned camera
  31432. */
  31433. clone(name: string): Camera;
  31434. /**
  31435. * Gets the direction of the camera relative to a given local axis.
  31436. * @param localAxis Defines the reference axis to provide a relative direction.
  31437. * @return the direction
  31438. */
  31439. getDirection(localAxis: Vector3): Vector3;
  31440. /**
  31441. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31442. * @param localAxis Defines the reference axis to provide a relative direction.
  31443. * @param result Defines the vector to store the result in
  31444. */
  31445. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31446. /**
  31447. * Gets a camera constructor for a given camera type
  31448. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31449. * @param name The name of the camera the result will be able to instantiate
  31450. * @param scene The scene the result will construct the camera in
  31451. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31452. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31453. * @returns a factory method to construc the camera
  31454. */
  31455. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31456. /**
  31457. * Compute the world matrix of the camera.
  31458. * @returns the camera workd matrix
  31459. */
  31460. computeWorldMatrix(): Matrix;
  31461. /**
  31462. * Parse a JSON and creates the camera from the parsed information
  31463. * @param parsedCamera The JSON to parse
  31464. * @param scene The scene to instantiate the camera in
  31465. * @returns the newly constructed camera
  31466. */
  31467. static Parse(parsedCamera: any, scene: Scene): Camera;
  31468. }
  31469. }
  31470. declare module "babylonjs/Misc/tools" {
  31471. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31472. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31473. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31474. import { Observable } from "babylonjs/Misc/observable";
  31475. import { DomManagement } from "babylonjs/Misc/domManagement";
  31476. import { WebRequest } from "babylonjs/Misc/webRequest";
  31477. import { Camera } from "babylonjs/Cameras/camera";
  31478. import { Engine } from "babylonjs/Engines/engine";
  31479. import { Animation } from "babylonjs/Animations/animation";
  31480. /**
  31481. * Interface for any object that can request an animation frame
  31482. */
  31483. export interface ICustomAnimationFrameRequester {
  31484. /**
  31485. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31486. */
  31487. renderFunction?: Function;
  31488. /**
  31489. * Called to request the next frame to render to
  31490. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31491. */
  31492. requestAnimationFrame: Function;
  31493. /**
  31494. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31495. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31496. */
  31497. requestID?: number;
  31498. }
  31499. /**
  31500. * Interface containing an array of animations
  31501. */
  31502. export interface IAnimatable {
  31503. /**
  31504. * Array of animations
  31505. */
  31506. animations: Nullable<Array<Animation>>;
  31507. }
  31508. /** Interface used by value gradients (color, factor, ...) */
  31509. export interface IValueGradient {
  31510. /**
  31511. * Gets or sets the gradient value (between 0 and 1)
  31512. */
  31513. gradient: number;
  31514. }
  31515. /** Class used to store color4 gradient */
  31516. export class ColorGradient implements IValueGradient {
  31517. /**
  31518. * Gets or sets the gradient value (between 0 and 1)
  31519. */
  31520. gradient: number;
  31521. /**
  31522. * Gets or sets first associated color
  31523. */
  31524. color1: Color4;
  31525. /**
  31526. * Gets or sets second associated color
  31527. */
  31528. color2?: Color4;
  31529. /**
  31530. * Will get a color picked randomly between color1 and color2.
  31531. * If color2 is undefined then color1 will be used
  31532. * @param result defines the target Color4 to store the result in
  31533. */
  31534. getColorToRef(result: Color4): void;
  31535. }
  31536. /** Class used to store color 3 gradient */
  31537. export class Color3Gradient implements IValueGradient {
  31538. /**
  31539. * Gets or sets the gradient value (between 0 and 1)
  31540. */
  31541. gradient: number;
  31542. /**
  31543. * Gets or sets the associated color
  31544. */
  31545. color: Color3;
  31546. }
  31547. /** Class used to store factor gradient */
  31548. export class FactorGradient implements IValueGradient {
  31549. /**
  31550. * Gets or sets the gradient value (between 0 and 1)
  31551. */
  31552. gradient: number;
  31553. /**
  31554. * Gets or sets first associated factor
  31555. */
  31556. factor1: number;
  31557. /**
  31558. * Gets or sets second associated factor
  31559. */
  31560. factor2?: number;
  31561. /**
  31562. * Will get a number picked randomly between factor1 and factor2.
  31563. * If factor2 is undefined then factor1 will be used
  31564. * @returns the picked number
  31565. */
  31566. getFactor(): number;
  31567. }
  31568. /**
  31569. * @ignore
  31570. * Application error to support additional information when loading a file
  31571. */
  31572. export class LoadFileError extends Error {
  31573. /** defines the optional web request */
  31574. request?: WebRequest | undefined;
  31575. private static _setPrototypeOf;
  31576. /**
  31577. * Creates a new LoadFileError
  31578. * @param message defines the message of the error
  31579. * @param request defines the optional web request
  31580. */
  31581. constructor(message: string,
  31582. /** defines the optional web request */
  31583. request?: WebRequest | undefined);
  31584. }
  31585. /**
  31586. * Class used to define a retry strategy when error happens while loading assets
  31587. */
  31588. export class RetryStrategy {
  31589. /**
  31590. * Function used to defines an exponential back off strategy
  31591. * @param maxRetries defines the maximum number of retries (3 by default)
  31592. * @param baseInterval defines the interval between retries
  31593. * @returns the strategy function to use
  31594. */
  31595. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31596. }
  31597. /**
  31598. * File request interface
  31599. */
  31600. export interface IFileRequest {
  31601. /**
  31602. * Raised when the request is complete (success or error).
  31603. */
  31604. onCompleteObservable: Observable<IFileRequest>;
  31605. /**
  31606. * Aborts the request for a file.
  31607. */
  31608. abort: () => void;
  31609. }
  31610. /**
  31611. * Class containing a set of static utilities functions
  31612. */
  31613. export class Tools {
  31614. /**
  31615. * Gets or sets the base URL to use to load assets
  31616. */
  31617. static BaseUrl: string;
  31618. /**
  31619. * Enable/Disable Custom HTTP Request Headers globally.
  31620. * default = false
  31621. * @see CustomRequestHeaders
  31622. */
  31623. static UseCustomRequestHeaders: boolean;
  31624. /**
  31625. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31626. * i.e. when loading files, where the server/service expects an Authorization header
  31627. */
  31628. static CustomRequestHeaders: {
  31629. [key: string]: string;
  31630. };
  31631. /**
  31632. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31633. */
  31634. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31635. /**
  31636. * Default behaviour for cors in the application.
  31637. * It can be a string if the expected behavior is identical in the entire app.
  31638. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31639. */
  31640. static CorsBehavior: string | ((url: string | string[]) => string);
  31641. /**
  31642. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31643. * @ignorenaming
  31644. */
  31645. static UseFallbackTexture: boolean;
  31646. /**
  31647. * Use this object to register external classes like custom textures or material
  31648. * to allow the laoders to instantiate them
  31649. */
  31650. static RegisteredExternalClasses: {
  31651. [key: string]: Object;
  31652. };
  31653. /**
  31654. * Texture content used if a texture cannot loaded
  31655. * @ignorenaming
  31656. */
  31657. static fallbackTexture: string;
  31658. /**
  31659. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31660. * @param u defines the coordinate on X axis
  31661. * @param v defines the coordinate on Y axis
  31662. * @param width defines the width of the source data
  31663. * @param height defines the height of the source data
  31664. * @param pixels defines the source byte array
  31665. * @param color defines the output color
  31666. */
  31667. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31668. /**
  31669. * Interpolates between a and b via alpha
  31670. * @param a The lower value (returned when alpha = 0)
  31671. * @param b The upper value (returned when alpha = 1)
  31672. * @param alpha The interpolation-factor
  31673. * @return The mixed value
  31674. */
  31675. static Mix(a: number, b: number, alpha: number): number;
  31676. /**
  31677. * Tries to instantiate a new object from a given class name
  31678. * @param className defines the class name to instantiate
  31679. * @returns the new object or null if the system was not able to do the instantiation
  31680. */
  31681. static Instantiate(className: string): any;
  31682. /**
  31683. * Provides a slice function that will work even on IE
  31684. * @param data defines the array to slice
  31685. * @param start defines the start of the data (optional)
  31686. * @param end defines the end of the data (optional)
  31687. * @returns the new sliced array
  31688. */
  31689. static Slice<T>(data: T, start?: number, end?: number): T;
  31690. /**
  31691. * Polyfill for setImmediate
  31692. * @param action defines the action to execute after the current execution block
  31693. */
  31694. static SetImmediate(action: () => void): void;
  31695. /**
  31696. * Function indicating if a number is an exponent of 2
  31697. * @param value defines the value to test
  31698. * @returns true if the value is an exponent of 2
  31699. */
  31700. static IsExponentOfTwo(value: number): boolean;
  31701. private static _tmpFloatArray;
  31702. /**
  31703. * Returns the nearest 32-bit single precision float representation of a Number
  31704. * @param value A Number. If the parameter is of a different type, it will get converted
  31705. * to a number or to NaN if it cannot be converted
  31706. * @returns number
  31707. */
  31708. static FloatRound(value: number): number;
  31709. /**
  31710. * Find the next highest power of two.
  31711. * @param x Number to start search from.
  31712. * @return Next highest power of two.
  31713. */
  31714. static CeilingPOT(x: number): number;
  31715. /**
  31716. * Find the next lowest power of two.
  31717. * @param x Number to start search from.
  31718. * @return Next lowest power of two.
  31719. */
  31720. static FloorPOT(x: number): number;
  31721. /**
  31722. * Find the nearest power of two.
  31723. * @param x Number to start search from.
  31724. * @return Next nearest power of two.
  31725. */
  31726. static NearestPOT(x: number): number;
  31727. /**
  31728. * Get the closest exponent of two
  31729. * @param value defines the value to approximate
  31730. * @param max defines the maximum value to return
  31731. * @param mode defines how to define the closest value
  31732. * @returns closest exponent of two of the given value
  31733. */
  31734. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31735. /**
  31736. * Extracts the filename from a path
  31737. * @param path defines the path to use
  31738. * @returns the filename
  31739. */
  31740. static GetFilename(path: string): string;
  31741. /**
  31742. * Extracts the "folder" part of a path (everything before the filename).
  31743. * @param uri The URI to extract the info from
  31744. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31745. * @returns The "folder" part of the path
  31746. */
  31747. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31748. /**
  31749. * Extracts text content from a DOM element hierarchy
  31750. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31751. */
  31752. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31753. /**
  31754. * Convert an angle in radians to degrees
  31755. * @param angle defines the angle to convert
  31756. * @returns the angle in degrees
  31757. */
  31758. static ToDegrees(angle: number): number;
  31759. /**
  31760. * Convert an angle in degrees to radians
  31761. * @param angle defines the angle to convert
  31762. * @returns the angle in radians
  31763. */
  31764. static ToRadians(angle: number): number;
  31765. /**
  31766. * Encode a buffer to a base64 string
  31767. * @param buffer defines the buffer to encode
  31768. * @returns the encoded string
  31769. */
  31770. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31771. /**
  31772. * Extracts minimum and maximum values from a list of indexed positions
  31773. * @param positions defines the positions to use
  31774. * @param indices defines the indices to the positions
  31775. * @param indexStart defines the start index
  31776. * @param indexCount defines the end index
  31777. * @param bias defines bias value to add to the result
  31778. * @return minimum and maximum values
  31779. */
  31780. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31781. minimum: Vector3;
  31782. maximum: Vector3;
  31783. };
  31784. /**
  31785. * Extracts minimum and maximum values from a list of positions
  31786. * @param positions defines the positions to use
  31787. * @param start defines the start index in the positions array
  31788. * @param count defines the number of positions to handle
  31789. * @param bias defines bias value to add to the result
  31790. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31791. * @return minimum and maximum values
  31792. */
  31793. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31794. minimum: Vector3;
  31795. maximum: Vector3;
  31796. };
  31797. /**
  31798. * Returns an array if obj is not an array
  31799. * @param obj defines the object to evaluate as an array
  31800. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31801. * @returns either obj directly if obj is an array or a new array containing obj
  31802. */
  31803. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31804. /**
  31805. * Gets the pointer prefix to use
  31806. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31807. */
  31808. static GetPointerPrefix(): string;
  31809. /**
  31810. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31811. * @param func - the function to be called
  31812. * @param requester - the object that will request the next frame. Falls back to window.
  31813. * @returns frame number
  31814. */
  31815. static QueueNewFrame(func: () => void, requester?: any): number;
  31816. /**
  31817. * Ask the browser to promote the current element to fullscreen rendering mode
  31818. * @param element defines the DOM element to promote
  31819. */
  31820. static RequestFullscreen(element: HTMLElement): void;
  31821. /**
  31822. * Asks the browser to exit fullscreen mode
  31823. */
  31824. static ExitFullscreen(): void;
  31825. /**
  31826. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31827. * @param url define the url we are trying
  31828. * @param element define the dom element where to configure the cors policy
  31829. */
  31830. static SetCorsBehavior(url: string | string[], element: {
  31831. crossOrigin: string | null;
  31832. }): void;
  31833. /**
  31834. * Removes unwanted characters from an url
  31835. * @param url defines the url to clean
  31836. * @returns the cleaned url
  31837. */
  31838. static CleanUrl(url: string): string;
  31839. /**
  31840. * Gets or sets a function used to pre-process url before using them to load assets
  31841. */
  31842. static PreprocessUrl: (url: string) => string;
  31843. /**
  31844. * Loads an image as an HTMLImageElement.
  31845. * @param input url string, ArrayBuffer, or Blob to load
  31846. * @param onLoad callback called when the image successfully loads
  31847. * @param onError callback called when the image fails to load
  31848. * @param offlineProvider offline provider for caching
  31849. * @returns the HTMLImageElement of the loaded image
  31850. */
  31851. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31852. /**
  31853. * Loads a file
  31854. * @param url url string, ArrayBuffer, or Blob to load
  31855. * @param onSuccess callback called when the file successfully loads
  31856. * @param onProgress callback called while file is loading (if the server supports this mode)
  31857. * @param offlineProvider defines the offline provider for caching
  31858. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31859. * @param onError callback called when the file fails to load
  31860. * @returns a file request object
  31861. */
  31862. 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;
  31863. /**
  31864. * Load a script (identified by an url). When the url returns, the
  31865. * content of this file is added into a new script element, attached to the DOM (body element)
  31866. * @param scriptUrl defines the url of the script to laod
  31867. * @param onSuccess defines the callback called when the script is loaded
  31868. * @param onError defines the callback to call if an error occurs
  31869. * @param scriptId defines the id of the script element
  31870. */
  31871. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31872. /**
  31873. * Load an asynchronous script (identified by an url). When the url returns, the
  31874. * content of this file is added into a new script element, attached to the DOM (body element)
  31875. * @param scriptUrl defines the url of the script to laod
  31876. * @param scriptId defines the id of the script element
  31877. * @returns a promise request object
  31878. */
  31879. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31880. /**
  31881. * Loads a file from a blob
  31882. * @param fileToLoad defines the blob to use
  31883. * @param callback defines the callback to call when data is loaded
  31884. * @param progressCallback defines the callback to call during loading process
  31885. * @returns a file request object
  31886. */
  31887. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31888. /**
  31889. * Loads a file
  31890. * @param fileToLoad defines the file to load
  31891. * @param callback defines the callback to call when data is loaded
  31892. * @param progressCallBack defines the callback to call during loading process
  31893. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31894. * @returns a file request object
  31895. */
  31896. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31897. /**
  31898. * Creates a data url from a given string content
  31899. * @param content defines the content to convert
  31900. * @returns the new data url link
  31901. */
  31902. static FileAsURL(content: string): string;
  31903. /**
  31904. * Format the given number to a specific decimal format
  31905. * @param value defines the number to format
  31906. * @param decimals defines the number of decimals to use
  31907. * @returns the formatted string
  31908. */
  31909. static Format(value: number, decimals?: number): string;
  31910. /**
  31911. * Checks if a given vector is inside a specific range
  31912. * @param v defines the vector to test
  31913. * @param min defines the minimum range
  31914. * @param max defines the maximum range
  31915. */
  31916. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31917. /**
  31918. * Tries to copy an object by duplicating every property
  31919. * @param source defines the source object
  31920. * @param destination defines the target object
  31921. * @param doNotCopyList defines a list of properties to avoid
  31922. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31923. */
  31924. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31925. /**
  31926. * Gets a boolean indicating if the given object has no own property
  31927. * @param obj defines the object to test
  31928. * @returns true if object has no own property
  31929. */
  31930. static IsEmpty(obj: any): boolean;
  31931. /**
  31932. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31933. * @param str Source string
  31934. * @param suffix Suffix to search for in the source string
  31935. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31936. */
  31937. static EndsWith(str: string, suffix: string): boolean;
  31938. /**
  31939. * Function used to register events at window level
  31940. * @param events defines the events to register
  31941. */
  31942. static RegisterTopRootEvents(events: {
  31943. name: string;
  31944. handler: Nullable<(e: FocusEvent) => any>;
  31945. }[]): void;
  31946. /**
  31947. * Function used to unregister events from window level
  31948. * @param events defines the events to unregister
  31949. */
  31950. static UnregisterTopRootEvents(events: {
  31951. name: string;
  31952. handler: Nullable<(e: FocusEvent) => any>;
  31953. }[]): void;
  31954. /**
  31955. * @ignore
  31956. */
  31957. static _ScreenshotCanvas: HTMLCanvasElement;
  31958. /**
  31959. * Dumps the current bound framebuffer
  31960. * @param width defines the rendering width
  31961. * @param height defines the rendering height
  31962. * @param engine defines the hosting engine
  31963. * @param successCallback defines the callback triggered once the data are available
  31964. * @param mimeType defines the mime type of the result
  31965. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31966. */
  31967. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31968. /**
  31969. * Converts the canvas data to blob.
  31970. * This acts as a polyfill for browsers not supporting the to blob function.
  31971. * @param canvas Defines the canvas to extract the data from
  31972. * @param successCallback Defines the callback triggered once the data are available
  31973. * @param mimeType Defines the mime type of the result
  31974. */
  31975. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31976. /**
  31977. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31978. * @param successCallback defines the callback triggered once the data are available
  31979. * @param mimeType defines the mime type of the result
  31980. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31981. */
  31982. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31983. /**
  31984. * Downloads a blob in the browser
  31985. * @param blob defines the blob to download
  31986. * @param fileName defines the name of the downloaded file
  31987. */
  31988. static Download(blob: Blob, fileName: string): void;
  31989. /**
  31990. * Captures a screenshot of the current rendering
  31991. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31992. * @param engine defines the rendering engine
  31993. * @param camera defines the source camera
  31994. * @param size This parameter can be set to a single number or to an object with the
  31995. * following (optional) properties: precision, width, height. If a single number is passed,
  31996. * it will be used for both width and height. If an object is passed, the screenshot size
  31997. * will be derived from the parameters. The precision property is a multiplier allowing
  31998. * rendering at a higher or lower resolution
  31999. * @param successCallback defines the callback receives a single parameter which contains the
  32000. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32001. * src parameter of an <img> to display it
  32002. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32003. * Check your browser for supported MIME types
  32004. */
  32005. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32006. /**
  32007. * Generates an image screenshot from the specified camera.
  32008. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32009. * @param engine The engine to use for rendering
  32010. * @param camera The camera to use for rendering
  32011. * @param size This parameter can be set to a single number or to an object with the
  32012. * following (optional) properties: precision, width, height. If a single number is passed,
  32013. * it will be used for both width and height. If an object is passed, the screenshot size
  32014. * will be derived from the parameters. The precision property is a multiplier allowing
  32015. * rendering at a higher or lower resolution
  32016. * @param successCallback The callback receives a single parameter which contains the
  32017. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32018. * src parameter of an <img> to display it
  32019. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32020. * Check your browser for supported MIME types
  32021. * @param samples Texture samples (default: 1)
  32022. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32023. * @param fileName A name for for the downloaded file.
  32024. */
  32025. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32026. /**
  32027. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32028. * Be aware Math.random() could cause collisions, but:
  32029. * "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"
  32030. * @returns a pseudo random id
  32031. */
  32032. static RandomId(): string;
  32033. /**
  32034. * Test if the given uri is a base64 string
  32035. * @param uri The uri to test
  32036. * @return True if the uri is a base64 string or false otherwise
  32037. */
  32038. static IsBase64(uri: string): boolean;
  32039. /**
  32040. * Decode the given base64 uri.
  32041. * @param uri The uri to decode
  32042. * @return The decoded base64 data.
  32043. */
  32044. static DecodeBase64(uri: string): ArrayBuffer;
  32045. /**
  32046. * Gets the absolute url.
  32047. * @param url the input url
  32048. * @return the absolute url
  32049. */
  32050. static GetAbsoluteUrl(url: string): string;
  32051. /**
  32052. * No log
  32053. */
  32054. static readonly NoneLogLevel: number;
  32055. /**
  32056. * Only message logs
  32057. */
  32058. static readonly MessageLogLevel: number;
  32059. /**
  32060. * Only warning logs
  32061. */
  32062. static readonly WarningLogLevel: number;
  32063. /**
  32064. * Only error logs
  32065. */
  32066. static readonly ErrorLogLevel: number;
  32067. /**
  32068. * All logs
  32069. */
  32070. static readonly AllLogLevel: number;
  32071. /**
  32072. * Gets a value indicating the number of loading errors
  32073. * @ignorenaming
  32074. */
  32075. static readonly errorsCount: number;
  32076. /**
  32077. * Callback called when a new log is added
  32078. */
  32079. static OnNewCacheEntry: (entry: string) => void;
  32080. /**
  32081. * Log a message to the console
  32082. * @param message defines the message to log
  32083. */
  32084. static Log(message: string): void;
  32085. /**
  32086. * Write a warning message to the console
  32087. * @param message defines the message to log
  32088. */
  32089. static Warn(message: string): void;
  32090. /**
  32091. * Write an error message to the console
  32092. * @param message defines the message to log
  32093. */
  32094. static Error(message: string): void;
  32095. /**
  32096. * Gets current log cache (list of logs)
  32097. */
  32098. static readonly LogCache: string;
  32099. /**
  32100. * Clears the log cache
  32101. */
  32102. static ClearLogCache(): void;
  32103. /**
  32104. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32105. */
  32106. static LogLevels: number;
  32107. /**
  32108. * Checks if the loaded document was accessed via `file:`-Protocol.
  32109. * @returns boolean
  32110. */
  32111. static IsFileURL(): boolean;
  32112. /**
  32113. * Checks if the window object exists
  32114. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32115. */
  32116. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32117. /**
  32118. * No performance log
  32119. */
  32120. static readonly PerformanceNoneLogLevel: number;
  32121. /**
  32122. * Use user marks to log performance
  32123. */
  32124. static readonly PerformanceUserMarkLogLevel: number;
  32125. /**
  32126. * Log performance to the console
  32127. */
  32128. static readonly PerformanceConsoleLogLevel: number;
  32129. private static _performance;
  32130. /**
  32131. * Sets the current performance log level
  32132. */
  32133. static PerformanceLogLevel: number;
  32134. private static _StartPerformanceCounterDisabled;
  32135. private static _EndPerformanceCounterDisabled;
  32136. private static _StartUserMark;
  32137. private static _EndUserMark;
  32138. private static _StartPerformanceConsole;
  32139. private static _EndPerformanceConsole;
  32140. /**
  32141. * Starts a performance counter
  32142. */
  32143. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32144. /**
  32145. * Ends a specific performance coutner
  32146. */
  32147. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32148. /**
  32149. * Gets either window.performance.now() if supported or Date.now() else
  32150. */
  32151. static readonly Now: number;
  32152. /**
  32153. * This method will return the name of the class used to create the instance of the given object.
  32154. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32155. * @param object the object to get the class name from
  32156. * @param isType defines if the object is actually a type
  32157. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32158. */
  32159. static GetClassName(object: any, isType?: boolean): string;
  32160. /**
  32161. * Gets the first element of an array satisfying a given predicate
  32162. * @param array defines the array to browse
  32163. * @param predicate defines the predicate to use
  32164. * @returns null if not found or the element
  32165. */
  32166. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32167. /**
  32168. * This method will return the name of the full name of the class, including its owning module (if any).
  32169. * 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).
  32170. * @param object the object to get the class name from
  32171. * @param isType defines if the object is actually a type
  32172. * @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.
  32173. * @ignorenaming
  32174. */
  32175. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32176. /**
  32177. * Returns a promise that resolves after the given amount of time.
  32178. * @param delay Number of milliseconds to delay
  32179. * @returns Promise that resolves after the given amount of time
  32180. */
  32181. static DelayAsync(delay: number): Promise<void>;
  32182. /**
  32183. * Gets the current gradient from an array of IValueGradient
  32184. * @param ratio defines the current ratio to get
  32185. * @param gradients defines the array of IValueGradient
  32186. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32187. */
  32188. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32189. }
  32190. /**
  32191. * This class is used to track a performance counter which is number based.
  32192. * The user has access to many properties which give statistics of different nature.
  32193. *
  32194. * The implementer can track two kinds of Performance Counter: time and count.
  32195. * 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.
  32196. * 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.
  32197. */
  32198. export class PerfCounter {
  32199. /**
  32200. * Gets or sets a global boolean to turn on and off all the counters
  32201. */
  32202. static Enabled: boolean;
  32203. /**
  32204. * Returns the smallest value ever
  32205. */
  32206. readonly min: number;
  32207. /**
  32208. * Returns the biggest value ever
  32209. */
  32210. readonly max: number;
  32211. /**
  32212. * Returns the average value since the performance counter is running
  32213. */
  32214. readonly average: number;
  32215. /**
  32216. * Returns the average value of the last second the counter was monitored
  32217. */
  32218. readonly lastSecAverage: number;
  32219. /**
  32220. * Returns the current value
  32221. */
  32222. readonly current: number;
  32223. /**
  32224. * Gets the accumulated total
  32225. */
  32226. readonly total: number;
  32227. /**
  32228. * Gets the total value count
  32229. */
  32230. readonly count: number;
  32231. /**
  32232. * Creates a new counter
  32233. */
  32234. constructor();
  32235. /**
  32236. * Call this method to start monitoring a new frame.
  32237. * 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.
  32238. */
  32239. fetchNewFrame(): void;
  32240. /**
  32241. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32242. * @param newCount the count value to add to the monitored count
  32243. * @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.
  32244. */
  32245. addCount(newCount: number, fetchResult: boolean): void;
  32246. /**
  32247. * Start monitoring this performance counter
  32248. */
  32249. beginMonitoring(): void;
  32250. /**
  32251. * Compute the time lapsed since the previous beginMonitoring() call.
  32252. * @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
  32253. */
  32254. endMonitoring(newFrame?: boolean): void;
  32255. private _fetchResult;
  32256. private _startMonitoringTime;
  32257. private _min;
  32258. private _max;
  32259. private _average;
  32260. private _current;
  32261. private _totalValueCount;
  32262. private _totalAccumulated;
  32263. private _lastSecAverage;
  32264. private _lastSecAccumulated;
  32265. private _lastSecTime;
  32266. private _lastSecValueCount;
  32267. }
  32268. /**
  32269. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32270. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32271. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32272. * @param name The name of the class, case should be preserved
  32273. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32274. */
  32275. export function className(name: string, module?: string): (target: Object) => void;
  32276. /**
  32277. * An implementation of a loop for asynchronous functions.
  32278. */
  32279. export class AsyncLoop {
  32280. /**
  32281. * Defines the number of iterations for the loop
  32282. */
  32283. iterations: number;
  32284. /**
  32285. * Defines the current index of the loop.
  32286. */
  32287. index: number;
  32288. private _done;
  32289. private _fn;
  32290. private _successCallback;
  32291. /**
  32292. * Constructor.
  32293. * @param iterations the number of iterations.
  32294. * @param func the function to run each iteration
  32295. * @param successCallback the callback that will be called upon succesful execution
  32296. * @param offset starting offset.
  32297. */
  32298. constructor(
  32299. /**
  32300. * Defines the number of iterations for the loop
  32301. */
  32302. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32303. /**
  32304. * Execute the next iteration. Must be called after the last iteration was finished.
  32305. */
  32306. executeNext(): void;
  32307. /**
  32308. * Break the loop and run the success callback.
  32309. */
  32310. breakLoop(): void;
  32311. /**
  32312. * Create and run an async loop.
  32313. * @param iterations the number of iterations.
  32314. * @param fn the function to run each iteration
  32315. * @param successCallback the callback that will be called upon succesful execution
  32316. * @param offset starting offset.
  32317. * @returns the created async loop object
  32318. */
  32319. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32320. /**
  32321. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32322. * @param iterations total number of iterations
  32323. * @param syncedIterations number of synchronous iterations in each async iteration.
  32324. * @param fn the function to call each iteration.
  32325. * @param callback a success call back that will be called when iterating stops.
  32326. * @param breakFunction a break condition (optional)
  32327. * @param timeout timeout settings for the setTimeout function. default - 0.
  32328. * @returns the created async loop object
  32329. */
  32330. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32331. }
  32332. }
  32333. declare module "babylonjs/Collisions/collisionCoordinator" {
  32334. import { Nullable } from "babylonjs/types";
  32335. import { Scene } from "babylonjs/scene";
  32336. import { Vector3 } from "babylonjs/Maths/math";
  32337. import { Collider } from "babylonjs/Collisions/collider";
  32338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32339. /** @hidden */
  32340. export interface ICollisionCoordinator {
  32341. createCollider(): Collider;
  32342. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32343. init(scene: Scene): void;
  32344. }
  32345. /** @hidden */
  32346. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32347. private _scene;
  32348. private _scaledPosition;
  32349. private _scaledVelocity;
  32350. private _finalPosition;
  32351. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32352. createCollider(): Collider;
  32353. init(scene: Scene): void;
  32354. private _collideWithWorld;
  32355. }
  32356. }
  32357. declare module "babylonjs/Inputs/scene.inputManager" {
  32358. import { Nullable } from "babylonjs/types";
  32359. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32360. import { Vector2 } from "babylonjs/Maths/math";
  32361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32362. import { Scene } from "babylonjs/scene";
  32363. /**
  32364. * Class used to manage all inputs for the scene.
  32365. */
  32366. export class InputManager {
  32367. /** The distance in pixel that you have to move to prevent some events */
  32368. static DragMovementThreshold: number;
  32369. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32370. static LongPressDelay: number;
  32371. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32372. static DoubleClickDelay: number;
  32373. /** If you need to check double click without raising a single click at first click, enable this flag */
  32374. static ExclusiveDoubleClickMode: boolean;
  32375. private _wheelEventName;
  32376. private _onPointerMove;
  32377. private _onPointerDown;
  32378. private _onPointerUp;
  32379. private _initClickEvent;
  32380. private _initActionManager;
  32381. private _delayedSimpleClick;
  32382. private _delayedSimpleClickTimeout;
  32383. private _previousDelayedSimpleClickTimeout;
  32384. private _meshPickProceed;
  32385. private _previousButtonPressed;
  32386. private _currentPickResult;
  32387. private _previousPickResult;
  32388. private _totalPointersPressed;
  32389. private _doubleClickOccured;
  32390. private _pointerOverMesh;
  32391. private _pickedDownMesh;
  32392. private _pickedUpMesh;
  32393. private _pointerX;
  32394. private _pointerY;
  32395. private _unTranslatedPointerX;
  32396. private _unTranslatedPointerY;
  32397. private _startingPointerPosition;
  32398. private _previousStartingPointerPosition;
  32399. private _startingPointerTime;
  32400. private _previousStartingPointerTime;
  32401. private _pointerCaptures;
  32402. private _onKeyDown;
  32403. private _onKeyUp;
  32404. private _onCanvasFocusObserver;
  32405. private _onCanvasBlurObserver;
  32406. private _scene;
  32407. /**
  32408. * Creates a new InputManager
  32409. * @param scene defines the hosting scene
  32410. */
  32411. constructor(scene: Scene);
  32412. /**
  32413. * Gets the mesh that is currently under the pointer
  32414. */
  32415. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32416. /**
  32417. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32418. */
  32419. readonly unTranslatedPointer: Vector2;
  32420. /**
  32421. * Gets or sets the current on-screen X position of the pointer
  32422. */
  32423. pointerX: number;
  32424. /**
  32425. * Gets or sets the current on-screen Y position of the pointer
  32426. */
  32427. pointerY: number;
  32428. private _updatePointerPosition;
  32429. private _processPointerMove;
  32430. private _setRayOnPointerInfo;
  32431. private _checkPrePointerObservable;
  32432. /**
  32433. * Use this method to simulate a pointer move on a mesh
  32434. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32435. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32436. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32437. */
  32438. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32439. /**
  32440. * Use this method to simulate a pointer down on a mesh
  32441. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32442. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32443. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32444. */
  32445. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32446. private _processPointerDown;
  32447. /** @hidden */
  32448. _isPointerSwiping(): boolean;
  32449. /**
  32450. * Use this method to simulate a pointer up on a mesh
  32451. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32452. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32453. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32454. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32455. */
  32456. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32457. private _processPointerUp;
  32458. /**
  32459. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32460. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32461. * @returns true if the pointer was captured
  32462. */
  32463. isPointerCaptured(pointerId?: number): boolean;
  32464. /**
  32465. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32466. * @param attachUp defines if you want to attach events to pointerup
  32467. * @param attachDown defines if you want to attach events to pointerdown
  32468. * @param attachMove defines if you want to attach events to pointermove
  32469. */
  32470. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32471. /**
  32472. * Detaches all event handlers
  32473. */
  32474. detachControl(): void;
  32475. /**
  32476. * Force the value of meshUnderPointer
  32477. * @param mesh defines the mesh to use
  32478. */
  32479. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32480. /**
  32481. * Gets the mesh under the pointer
  32482. * @returns a Mesh or null if no mesh is under the pointer
  32483. */
  32484. getPointerOverMesh(): Nullable<AbstractMesh>;
  32485. }
  32486. }
  32487. declare module "babylonjs/Animations/animationGroup" {
  32488. import { Animatable } from "babylonjs/Animations/animatable";
  32489. import { Animation } from "babylonjs/Animations/animation";
  32490. import { Scene, IDisposable } from "babylonjs/scene";
  32491. import { Observable } from "babylonjs/Misc/observable";
  32492. import { Nullable } from "babylonjs/types";
  32493. /**
  32494. * This class defines the direct association between an animation and a target
  32495. */
  32496. export class TargetedAnimation {
  32497. /**
  32498. * Animation to perform
  32499. */
  32500. animation: Animation;
  32501. /**
  32502. * Target to animate
  32503. */
  32504. target: any;
  32505. }
  32506. /**
  32507. * Use this class to create coordinated animations on multiple targets
  32508. */
  32509. export class AnimationGroup implements IDisposable {
  32510. /** The name of the animation group */
  32511. name: string;
  32512. private _scene;
  32513. private _targetedAnimations;
  32514. private _animatables;
  32515. private _from;
  32516. private _to;
  32517. private _isStarted;
  32518. private _isPaused;
  32519. private _speedRatio;
  32520. /**
  32521. * Gets or sets the unique id of the node
  32522. */
  32523. uniqueId: number;
  32524. /**
  32525. * This observable will notify when one animation have ended
  32526. */
  32527. onAnimationEndObservable: Observable<TargetedAnimation>;
  32528. /**
  32529. * Observer raised when one animation loops
  32530. */
  32531. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32532. /**
  32533. * This observable will notify when all animations have ended.
  32534. */
  32535. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32536. /**
  32537. * This observable will notify when all animations have paused.
  32538. */
  32539. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32540. /**
  32541. * This observable will notify when all animations are playing.
  32542. */
  32543. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32544. /**
  32545. * Gets the first frame
  32546. */
  32547. readonly from: number;
  32548. /**
  32549. * Gets the last frame
  32550. */
  32551. readonly to: number;
  32552. /**
  32553. * Define if the animations are started
  32554. */
  32555. readonly isStarted: boolean;
  32556. /**
  32557. * Gets a value indicating that the current group is playing
  32558. */
  32559. readonly isPlaying: boolean;
  32560. /**
  32561. * Gets or sets the speed ratio to use for all animations
  32562. */
  32563. /**
  32564. * Gets or sets the speed ratio to use for all animations
  32565. */
  32566. speedRatio: number;
  32567. /**
  32568. * Gets the targeted animations for this animation group
  32569. */
  32570. readonly targetedAnimations: Array<TargetedAnimation>;
  32571. /**
  32572. * returning the list of animatables controlled by this animation group.
  32573. */
  32574. readonly animatables: Array<Animatable>;
  32575. /**
  32576. * Instantiates a new Animation Group.
  32577. * This helps managing several animations at once.
  32578. * @see http://doc.babylonjs.com/how_to/group
  32579. * @param name Defines the name of the group
  32580. * @param scene Defines the scene the group belongs to
  32581. */
  32582. constructor(
  32583. /** The name of the animation group */
  32584. name: string, scene?: Nullable<Scene>);
  32585. /**
  32586. * Add an animation (with its target) in the group
  32587. * @param animation defines the animation we want to add
  32588. * @param target defines the target of the animation
  32589. * @returns the TargetedAnimation object
  32590. */
  32591. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32592. /**
  32593. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32594. * It can add constant keys at begin or end
  32595. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32596. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32597. * @returns the animation group
  32598. */
  32599. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32600. /**
  32601. * Start all animations on given targets
  32602. * @param loop defines if animations must loop
  32603. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32604. * @param from defines the from key (optional)
  32605. * @param to defines the to key (optional)
  32606. * @returns the current animation group
  32607. */
  32608. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32609. /**
  32610. * Pause all animations
  32611. * @returns the animation group
  32612. */
  32613. pause(): AnimationGroup;
  32614. /**
  32615. * Play all animations to initial state
  32616. * This function will start() the animations if they were not started or will restart() them if they were paused
  32617. * @param loop defines if animations must loop
  32618. * @returns the animation group
  32619. */
  32620. play(loop?: boolean): AnimationGroup;
  32621. /**
  32622. * Reset all animations to initial state
  32623. * @returns the animation group
  32624. */
  32625. reset(): AnimationGroup;
  32626. /**
  32627. * Restart animations from key 0
  32628. * @returns the animation group
  32629. */
  32630. restart(): AnimationGroup;
  32631. /**
  32632. * Stop all animations
  32633. * @returns the animation group
  32634. */
  32635. stop(): AnimationGroup;
  32636. /**
  32637. * Set animation weight for all animatables
  32638. * @param weight defines the weight to use
  32639. * @return the animationGroup
  32640. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32641. */
  32642. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32643. /**
  32644. * Synchronize and normalize all animatables with a source animatable
  32645. * @param root defines the root animatable to synchronize with
  32646. * @return the animationGroup
  32647. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32648. */
  32649. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32650. /**
  32651. * Goes to a specific frame in this animation group
  32652. * @param frame the frame number to go to
  32653. * @return the animationGroup
  32654. */
  32655. goToFrame(frame: number): AnimationGroup;
  32656. /**
  32657. * Dispose all associated resources
  32658. */
  32659. dispose(): void;
  32660. private _checkAnimationGroupEnded;
  32661. /**
  32662. * Clone the current animation group and returns a copy
  32663. * @param newName defines the name of the new group
  32664. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32665. * @returns the new aniamtion group
  32666. */
  32667. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32668. /**
  32669. * Returns a new AnimationGroup object parsed from the source provided.
  32670. * @param parsedAnimationGroup defines the source
  32671. * @param scene defines the scene that will receive the animationGroup
  32672. * @returns a new AnimationGroup
  32673. */
  32674. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32675. /**
  32676. * Returns the string "AnimationGroup"
  32677. * @returns "AnimationGroup"
  32678. */
  32679. getClassName(): string;
  32680. /**
  32681. * Creates a detailled string about the object
  32682. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32683. * @returns a string representing the object
  32684. */
  32685. toString(fullDetails?: boolean): string;
  32686. }
  32687. }
  32688. declare module "babylonjs/scene" {
  32689. import { Nullable } from "babylonjs/types";
  32690. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32691. import { Observable } from "babylonjs/Misc/observable";
  32692. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32693. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32694. import { Geometry } from "babylonjs/Meshes/geometry";
  32695. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32696. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32698. import { Mesh } from "babylonjs/Meshes/mesh";
  32699. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32700. import { Bone } from "babylonjs/Bones/bone";
  32701. import { Skeleton } from "babylonjs/Bones/skeleton";
  32702. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32703. import { Camera } from "babylonjs/Cameras/camera";
  32704. import { AbstractScene } from "babylonjs/abstractScene";
  32705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32706. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32707. import { Material } from "babylonjs/Materials/material";
  32708. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32709. import { Effect } from "babylonjs/Materials/effect";
  32710. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32711. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32712. import { Light } from "babylonjs/Lights/light";
  32713. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32714. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32715. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32716. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32717. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32718. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32719. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32720. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32721. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32722. import { Engine } from "babylonjs/Engines/engine";
  32723. import { Node } from "babylonjs/node";
  32724. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32725. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32726. import { WebRequest } from "babylonjs/Misc/webRequest";
  32727. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32728. import { Ray } from "babylonjs/Culling/ray";
  32729. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32730. import { Animation } from "babylonjs/Animations/animation";
  32731. import { Animatable } from "babylonjs/Animations/animatable";
  32732. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32733. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32734. import { Collider } from "babylonjs/Collisions/collider";
  32735. /**
  32736. * Define an interface for all classes that will hold resources
  32737. */
  32738. export interface IDisposable {
  32739. /**
  32740. * Releases all held resources
  32741. */
  32742. dispose(): void;
  32743. }
  32744. /** Interface defining initialization parameters for Scene class */
  32745. export interface SceneOptions {
  32746. /**
  32747. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32748. * It will improve performance when the number of geometries becomes important.
  32749. */
  32750. useGeometryUniqueIdsMap?: boolean;
  32751. /**
  32752. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32753. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32754. */
  32755. useMaterialMeshMap?: boolean;
  32756. /**
  32757. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32758. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32759. */
  32760. useClonedMeshhMap?: boolean;
  32761. }
  32762. /**
  32763. * Represents a scene to be rendered by the engine.
  32764. * @see http://doc.babylonjs.com/features/scene
  32765. */
  32766. export class Scene extends AbstractScene implements IAnimatable {
  32767. private static _uniqueIdCounter;
  32768. /** The fog is deactivated */
  32769. static readonly FOGMODE_NONE: number;
  32770. /** The fog density is following an exponential function */
  32771. static readonly FOGMODE_EXP: number;
  32772. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32773. static readonly FOGMODE_EXP2: number;
  32774. /** The fog density is following a linear function. */
  32775. static readonly FOGMODE_LINEAR: number;
  32776. /**
  32777. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32778. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32779. */
  32780. static MinDeltaTime: number;
  32781. /**
  32782. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32783. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32784. */
  32785. static MaxDeltaTime: number;
  32786. /**
  32787. * Factory used to create the default material.
  32788. * @param name The name of the material to create
  32789. * @param scene The scene to create the material for
  32790. * @returns The default material
  32791. */
  32792. static DefaultMaterialFactory(scene: Scene): Material;
  32793. /**
  32794. * Factory used to create the a collision coordinator.
  32795. * @returns The collision coordinator
  32796. */
  32797. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32798. /** @hidden */
  32799. _inputManager: InputManager;
  32800. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32801. cameraToUseForPointers: Nullable<Camera>;
  32802. /** @hidden */
  32803. readonly _isScene: boolean;
  32804. /**
  32805. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32806. */
  32807. autoClear: boolean;
  32808. /**
  32809. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32810. */
  32811. autoClearDepthAndStencil: boolean;
  32812. /**
  32813. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32814. */
  32815. clearColor: Color4;
  32816. /**
  32817. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32818. */
  32819. ambientColor: Color3;
  32820. /**
  32821. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32822. * It should only be one of the following (if not the default embedded one):
  32823. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32824. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32825. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32826. * The material properties need to be setup according to the type of texture in use.
  32827. */
  32828. environmentBRDFTexture: BaseTexture;
  32829. /** @hidden */
  32830. protected _environmentTexture: Nullable<BaseTexture>;
  32831. /**
  32832. * Texture used in all pbr material as the reflection texture.
  32833. * As in the majority of the scene they are the same (exception for multi room and so on),
  32834. * this is easier to reference from here than from all the materials.
  32835. */
  32836. /**
  32837. * Texture used in all pbr material as the reflection texture.
  32838. * As in the majority of the scene they are the same (exception for multi room and so on),
  32839. * this is easier to set here than in all the materials.
  32840. */
  32841. environmentTexture: Nullable<BaseTexture>;
  32842. /** @hidden */
  32843. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32844. /**
  32845. * Default image processing configuration used either in the rendering
  32846. * Forward main pass or through the imageProcessingPostProcess if present.
  32847. * As in the majority of the scene they are the same (exception for multi camera),
  32848. * this is easier to reference from here than from all the materials and post process.
  32849. *
  32850. * No setter as we it is a shared configuration, you can set the values instead.
  32851. */
  32852. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32853. private _forceWireframe;
  32854. /**
  32855. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32856. */
  32857. forceWireframe: boolean;
  32858. private _forcePointsCloud;
  32859. /**
  32860. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32861. */
  32862. forcePointsCloud: boolean;
  32863. /**
  32864. * Gets or sets the active clipplane 1
  32865. */
  32866. clipPlane: Nullable<Plane>;
  32867. /**
  32868. * Gets or sets the active clipplane 2
  32869. */
  32870. clipPlane2: Nullable<Plane>;
  32871. /**
  32872. * Gets or sets the active clipplane 3
  32873. */
  32874. clipPlane3: Nullable<Plane>;
  32875. /**
  32876. * Gets or sets the active clipplane 4
  32877. */
  32878. clipPlane4: Nullable<Plane>;
  32879. /**
  32880. * Gets or sets a boolean indicating if animations are enabled
  32881. */
  32882. animationsEnabled: boolean;
  32883. private _animationPropertiesOverride;
  32884. /**
  32885. * Gets or sets the animation properties override
  32886. */
  32887. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32888. /**
  32889. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32890. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32891. */
  32892. useConstantAnimationDeltaTime: boolean;
  32893. /**
  32894. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32895. * Please note that it requires to run a ray cast through the scene on every frame
  32896. */
  32897. constantlyUpdateMeshUnderPointer: boolean;
  32898. /**
  32899. * Defines the HTML cursor to use when hovering over interactive elements
  32900. */
  32901. hoverCursor: string;
  32902. /**
  32903. * Defines the HTML default cursor to use (empty by default)
  32904. */
  32905. defaultCursor: string;
  32906. /**
  32907. * This is used to call preventDefault() on pointer down
  32908. * in order to block unwanted artifacts like system double clicks
  32909. */
  32910. preventDefaultOnPointerDown: boolean;
  32911. /**
  32912. * This is used to call preventDefault() on pointer up
  32913. * in order to block unwanted artifacts like system double clicks
  32914. */
  32915. preventDefaultOnPointerUp: boolean;
  32916. /**
  32917. * Gets or sets user defined metadata
  32918. */
  32919. metadata: any;
  32920. /**
  32921. * For internal use only. Please do not use.
  32922. */
  32923. reservedDataStore: any;
  32924. /**
  32925. * Gets the name of the plugin used to load this scene (null by default)
  32926. */
  32927. loadingPluginName: string;
  32928. /**
  32929. * Use this array to add regular expressions used to disable offline support for specific urls
  32930. */
  32931. disableOfflineSupportExceptionRules: RegExp[];
  32932. /**
  32933. * An event triggered when the scene is disposed.
  32934. */
  32935. onDisposeObservable: Observable<Scene>;
  32936. private _onDisposeObserver;
  32937. /** Sets a function to be executed when this scene is disposed. */
  32938. onDispose: () => void;
  32939. /**
  32940. * An event triggered before rendering the scene (right after animations and physics)
  32941. */
  32942. onBeforeRenderObservable: Observable<Scene>;
  32943. private _onBeforeRenderObserver;
  32944. /** Sets a function to be executed before rendering this scene */
  32945. beforeRender: Nullable<() => void>;
  32946. /**
  32947. * An event triggered after rendering the scene
  32948. */
  32949. onAfterRenderObservable: Observable<Scene>;
  32950. private _onAfterRenderObserver;
  32951. /** Sets a function to be executed after rendering this scene */
  32952. afterRender: Nullable<() => void>;
  32953. /**
  32954. * An event triggered before animating the scene
  32955. */
  32956. onBeforeAnimationsObservable: Observable<Scene>;
  32957. /**
  32958. * An event triggered after animations processing
  32959. */
  32960. onAfterAnimationsObservable: Observable<Scene>;
  32961. /**
  32962. * An event triggered before draw calls are ready to be sent
  32963. */
  32964. onBeforeDrawPhaseObservable: Observable<Scene>;
  32965. /**
  32966. * An event triggered after draw calls have been sent
  32967. */
  32968. onAfterDrawPhaseObservable: Observable<Scene>;
  32969. /**
  32970. * An event triggered when the scene is ready
  32971. */
  32972. onReadyObservable: Observable<Scene>;
  32973. /**
  32974. * An event triggered before rendering a camera
  32975. */
  32976. onBeforeCameraRenderObservable: Observable<Camera>;
  32977. private _onBeforeCameraRenderObserver;
  32978. /** Sets a function to be executed before rendering a camera*/
  32979. beforeCameraRender: () => void;
  32980. /**
  32981. * An event triggered after rendering a camera
  32982. */
  32983. onAfterCameraRenderObservable: Observable<Camera>;
  32984. private _onAfterCameraRenderObserver;
  32985. /** Sets a function to be executed after rendering a camera*/
  32986. afterCameraRender: () => void;
  32987. /**
  32988. * An event triggered when active meshes evaluation is about to start
  32989. */
  32990. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32991. /**
  32992. * An event triggered when active meshes evaluation is done
  32993. */
  32994. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32995. /**
  32996. * An event triggered when particles rendering is about to start
  32997. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32998. */
  32999. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33000. /**
  33001. * An event triggered when particles rendering is done
  33002. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33003. */
  33004. onAfterParticlesRenderingObservable: Observable<Scene>;
  33005. /**
  33006. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33007. */
  33008. onDataLoadedObservable: Observable<Scene>;
  33009. /**
  33010. * An event triggered when a camera is created
  33011. */
  33012. onNewCameraAddedObservable: Observable<Camera>;
  33013. /**
  33014. * An event triggered when a camera is removed
  33015. */
  33016. onCameraRemovedObservable: Observable<Camera>;
  33017. /**
  33018. * An event triggered when a light is created
  33019. */
  33020. onNewLightAddedObservable: Observable<Light>;
  33021. /**
  33022. * An event triggered when a light is removed
  33023. */
  33024. onLightRemovedObservable: Observable<Light>;
  33025. /**
  33026. * An event triggered when a geometry is created
  33027. */
  33028. onNewGeometryAddedObservable: Observable<Geometry>;
  33029. /**
  33030. * An event triggered when a geometry is removed
  33031. */
  33032. onGeometryRemovedObservable: Observable<Geometry>;
  33033. /**
  33034. * An event triggered when a transform node is created
  33035. */
  33036. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33037. /**
  33038. * An event triggered when a transform node is removed
  33039. */
  33040. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33041. /**
  33042. * An event triggered when a mesh is created
  33043. */
  33044. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33045. /**
  33046. * An event triggered when a mesh is removed
  33047. */
  33048. onMeshRemovedObservable: Observable<AbstractMesh>;
  33049. /**
  33050. * An event triggered when a skeleton is created
  33051. */
  33052. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33053. /**
  33054. * An event triggered when a skeleton is removed
  33055. */
  33056. onSkeletonRemovedObservable: Observable<Skeleton>;
  33057. /**
  33058. * An event triggered when a material is created
  33059. */
  33060. onNewMaterialAddedObservable: Observable<Material>;
  33061. /**
  33062. * An event triggered when a material is removed
  33063. */
  33064. onMaterialRemovedObservable: Observable<Material>;
  33065. /**
  33066. * An event triggered when a texture is created
  33067. */
  33068. onNewTextureAddedObservable: Observable<BaseTexture>;
  33069. /**
  33070. * An event triggered when a texture is removed
  33071. */
  33072. onTextureRemovedObservable: Observable<BaseTexture>;
  33073. /**
  33074. * An event triggered when render targets are about to be rendered
  33075. * Can happen multiple times per frame.
  33076. */
  33077. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33078. /**
  33079. * An event triggered when render targets were rendered.
  33080. * Can happen multiple times per frame.
  33081. */
  33082. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33083. /**
  33084. * An event triggered before calculating deterministic simulation step
  33085. */
  33086. onBeforeStepObservable: Observable<Scene>;
  33087. /**
  33088. * An event triggered after calculating deterministic simulation step
  33089. */
  33090. onAfterStepObservable: Observable<Scene>;
  33091. /**
  33092. * An event triggered when the activeCamera property is updated
  33093. */
  33094. onActiveCameraChanged: Observable<Scene>;
  33095. /**
  33096. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33097. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33098. * 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)
  33099. */
  33100. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33101. /**
  33102. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33103. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33104. * 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)
  33105. */
  33106. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33107. /**
  33108. * This Observable will when a mesh has been imported into the scene.
  33109. */
  33110. onMeshImportedObservable: Observable<AbstractMesh>;
  33111. /**
  33112. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33113. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33114. */
  33115. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33116. /** @hidden */
  33117. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33118. /**
  33119. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33120. */
  33121. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33122. /**
  33123. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33124. */
  33125. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33126. /**
  33127. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33128. */
  33129. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33130. /** Callback called when a pointer move is detected */
  33131. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33132. /** Callback called when a pointer down is detected */
  33133. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33134. /** Callback called when a pointer up is detected */
  33135. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33136. /** Callback called when a pointer pick is detected */
  33137. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33138. /**
  33139. * 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).
  33140. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33141. */
  33142. onPrePointerObservable: Observable<PointerInfoPre>;
  33143. /**
  33144. * Observable event triggered each time an input event is received from the rendering canvas
  33145. */
  33146. onPointerObservable: Observable<PointerInfo>;
  33147. /**
  33148. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33149. */
  33150. readonly unTranslatedPointer: Vector2;
  33151. /**
  33152. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33153. */
  33154. static DragMovementThreshold: number;
  33155. /**
  33156. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33157. */
  33158. static LongPressDelay: number;
  33159. /**
  33160. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33161. */
  33162. static DoubleClickDelay: number;
  33163. /** If you need to check double click without raising a single click at first click, enable this flag */
  33164. static ExclusiveDoubleClickMode: boolean;
  33165. /** @hidden */
  33166. _mirroredCameraPosition: Nullable<Vector3>;
  33167. /**
  33168. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33169. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33170. */
  33171. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33172. /**
  33173. * Observable event triggered each time an keyboard event is received from the hosting window
  33174. */
  33175. onKeyboardObservable: Observable<KeyboardInfo>;
  33176. private _useRightHandedSystem;
  33177. /**
  33178. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33179. */
  33180. useRightHandedSystem: boolean;
  33181. private _timeAccumulator;
  33182. private _currentStepId;
  33183. private _currentInternalStep;
  33184. /**
  33185. * Sets the step Id used by deterministic lock step
  33186. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33187. * @param newStepId defines the step Id
  33188. */
  33189. setStepId(newStepId: number): void;
  33190. /**
  33191. * Gets the step Id used by deterministic lock step
  33192. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33193. * @returns the step Id
  33194. */
  33195. getStepId(): number;
  33196. /**
  33197. * Gets the internal step used by deterministic lock step
  33198. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33199. * @returns the internal step
  33200. */
  33201. getInternalStep(): number;
  33202. private _fogEnabled;
  33203. /**
  33204. * Gets or sets a boolean indicating if fog is enabled on this scene
  33205. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33206. * (Default is true)
  33207. */
  33208. fogEnabled: boolean;
  33209. private _fogMode;
  33210. /**
  33211. * Gets or sets the fog mode to use
  33212. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33213. * | mode | value |
  33214. * | --- | --- |
  33215. * | FOGMODE_NONE | 0 |
  33216. * | FOGMODE_EXP | 1 |
  33217. * | FOGMODE_EXP2 | 2 |
  33218. * | FOGMODE_LINEAR | 3 |
  33219. */
  33220. fogMode: number;
  33221. /**
  33222. * Gets or sets the fog color to use
  33223. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33224. * (Default is Color3(0.2, 0.2, 0.3))
  33225. */
  33226. fogColor: Color3;
  33227. /**
  33228. * Gets or sets the fog density to use
  33229. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33230. * (Default is 0.1)
  33231. */
  33232. fogDensity: number;
  33233. /**
  33234. * Gets or sets the fog start distance to use
  33235. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33236. * (Default is 0)
  33237. */
  33238. fogStart: number;
  33239. /**
  33240. * Gets or sets the fog end distance to use
  33241. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33242. * (Default is 1000)
  33243. */
  33244. fogEnd: number;
  33245. private _shadowsEnabled;
  33246. /**
  33247. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33248. */
  33249. shadowsEnabled: boolean;
  33250. private _lightsEnabled;
  33251. /**
  33252. * Gets or sets a boolean indicating if lights are enabled on this scene
  33253. */
  33254. lightsEnabled: boolean;
  33255. /** All of the active cameras added to this scene. */
  33256. activeCameras: Camera[];
  33257. /** @hidden */
  33258. _activeCamera: Nullable<Camera>;
  33259. /** Gets or sets the current active camera */
  33260. activeCamera: Nullable<Camera>;
  33261. private _defaultMaterial;
  33262. /** The default material used on meshes when no material is affected */
  33263. /** The default material used on meshes when no material is affected */
  33264. defaultMaterial: Material;
  33265. private _texturesEnabled;
  33266. /**
  33267. * Gets or sets a boolean indicating if textures are enabled on this scene
  33268. */
  33269. texturesEnabled: boolean;
  33270. /**
  33271. * Gets or sets a boolean indicating if particles are enabled on this scene
  33272. */
  33273. particlesEnabled: boolean;
  33274. /**
  33275. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33276. */
  33277. spritesEnabled: boolean;
  33278. private _skeletonsEnabled;
  33279. /**
  33280. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33281. */
  33282. skeletonsEnabled: boolean;
  33283. /**
  33284. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33285. */
  33286. lensFlaresEnabled: boolean;
  33287. /**
  33288. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33290. */
  33291. collisionsEnabled: boolean;
  33292. private _collisionCoordinator;
  33293. /** @hidden */
  33294. readonly collisionCoordinator: ICollisionCoordinator;
  33295. /**
  33296. * Defines the gravity applied to this scene (used only for collisions)
  33297. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33298. */
  33299. gravity: Vector3;
  33300. /**
  33301. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33302. */
  33303. postProcessesEnabled: boolean;
  33304. /**
  33305. * The list of postprocesses added to the scene
  33306. */
  33307. postProcesses: PostProcess[];
  33308. /**
  33309. * Gets the current postprocess manager
  33310. */
  33311. postProcessManager: PostProcessManager;
  33312. /**
  33313. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33314. */
  33315. renderTargetsEnabled: boolean;
  33316. /**
  33317. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33318. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33319. */
  33320. dumpNextRenderTargets: boolean;
  33321. /**
  33322. * The list of user defined render targets added to the scene
  33323. */
  33324. customRenderTargets: RenderTargetTexture[];
  33325. /**
  33326. * Defines if texture loading must be delayed
  33327. * If true, textures will only be loaded when they need to be rendered
  33328. */
  33329. useDelayedTextureLoading: boolean;
  33330. /**
  33331. * Gets the list of meshes imported to the scene through SceneLoader
  33332. */
  33333. importedMeshesFiles: String[];
  33334. /**
  33335. * Gets or sets a boolean indicating if probes are enabled on this scene
  33336. */
  33337. probesEnabled: boolean;
  33338. /**
  33339. * Gets or sets the current offline provider to use to store scene data
  33340. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33341. */
  33342. offlineProvider: IOfflineProvider;
  33343. /**
  33344. * Gets or sets the action manager associated with the scene
  33345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33346. */
  33347. actionManager: AbstractActionManager;
  33348. private _meshesForIntersections;
  33349. /**
  33350. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33351. */
  33352. proceduralTexturesEnabled: boolean;
  33353. private _engine;
  33354. private _totalVertices;
  33355. /** @hidden */
  33356. _activeIndices: PerfCounter;
  33357. /** @hidden */
  33358. _activeParticles: PerfCounter;
  33359. /** @hidden */
  33360. _activeBones: PerfCounter;
  33361. private _animationRatio;
  33362. /** @hidden */
  33363. _animationTimeLast: number;
  33364. /** @hidden */
  33365. _animationTime: number;
  33366. /**
  33367. * Gets or sets a general scale for animation speed
  33368. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33369. */
  33370. animationTimeScale: number;
  33371. /** @hidden */
  33372. _cachedMaterial: Nullable<Material>;
  33373. /** @hidden */
  33374. _cachedEffect: Nullable<Effect>;
  33375. /** @hidden */
  33376. _cachedVisibility: Nullable<number>;
  33377. private _renderId;
  33378. private _frameId;
  33379. private _executeWhenReadyTimeoutId;
  33380. private _intermediateRendering;
  33381. private _viewUpdateFlag;
  33382. private _projectionUpdateFlag;
  33383. /** @hidden */
  33384. _toBeDisposed: Nullable<IDisposable>[];
  33385. private _activeRequests;
  33386. /** @hidden */
  33387. _pendingData: any[];
  33388. private _isDisposed;
  33389. /**
  33390. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33391. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33392. */
  33393. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33394. private _activeMeshes;
  33395. private _processedMaterials;
  33396. private _renderTargets;
  33397. /** @hidden */
  33398. _activeParticleSystems: SmartArray<IParticleSystem>;
  33399. private _activeSkeletons;
  33400. private _softwareSkinnedMeshes;
  33401. private _renderingManager;
  33402. /** @hidden */
  33403. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33404. private _transformMatrix;
  33405. private _sceneUbo;
  33406. /** @hidden */
  33407. _viewMatrix: Matrix;
  33408. private _projectionMatrix;
  33409. /** @hidden */
  33410. _forcedViewPosition: Nullable<Vector3>;
  33411. /** @hidden */
  33412. _frustumPlanes: Plane[];
  33413. /**
  33414. * Gets the list of frustum planes (built from the active camera)
  33415. */
  33416. readonly frustumPlanes: Plane[];
  33417. /**
  33418. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33419. * This is useful if there are more lights that the maximum simulteanous authorized
  33420. */
  33421. requireLightSorting: boolean;
  33422. /** @hidden */
  33423. readonly useMaterialMeshMap: boolean;
  33424. /** @hidden */
  33425. readonly useClonedMeshhMap: boolean;
  33426. private _externalData;
  33427. private _uid;
  33428. /**
  33429. * @hidden
  33430. * Backing store of defined scene components.
  33431. */
  33432. _components: ISceneComponent[];
  33433. /**
  33434. * @hidden
  33435. * Backing store of defined scene components.
  33436. */
  33437. _serializableComponents: ISceneSerializableComponent[];
  33438. /**
  33439. * List of components to register on the next registration step.
  33440. */
  33441. private _transientComponents;
  33442. /**
  33443. * Registers the transient components if needed.
  33444. */
  33445. private _registerTransientComponents;
  33446. /**
  33447. * @hidden
  33448. * Add a component to the scene.
  33449. * Note that the ccomponent could be registered on th next frame if this is called after
  33450. * the register component stage.
  33451. * @param component Defines the component to add to the scene
  33452. */
  33453. _addComponent(component: ISceneComponent): void;
  33454. /**
  33455. * @hidden
  33456. * Gets a component from the scene.
  33457. * @param name defines the name of the component to retrieve
  33458. * @returns the component or null if not present
  33459. */
  33460. _getComponent(name: string): Nullable<ISceneComponent>;
  33461. /**
  33462. * @hidden
  33463. * Defines the actions happening before camera updates.
  33464. */
  33465. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33466. /**
  33467. * @hidden
  33468. * Defines the actions happening before clear the canvas.
  33469. */
  33470. _beforeClearStage: Stage<SimpleStageAction>;
  33471. /**
  33472. * @hidden
  33473. * Defines the actions when collecting render targets for the frame.
  33474. */
  33475. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33476. /**
  33477. * @hidden
  33478. * Defines the actions happening for one camera in the frame.
  33479. */
  33480. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33481. /**
  33482. * @hidden
  33483. * Defines the actions happening during the per mesh ready checks.
  33484. */
  33485. _isReadyForMeshStage: Stage<MeshStageAction>;
  33486. /**
  33487. * @hidden
  33488. * Defines the actions happening before evaluate active mesh checks.
  33489. */
  33490. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33491. /**
  33492. * @hidden
  33493. * Defines the actions happening during the evaluate sub mesh checks.
  33494. */
  33495. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33496. /**
  33497. * @hidden
  33498. * Defines the actions happening during the active mesh stage.
  33499. */
  33500. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33501. /**
  33502. * @hidden
  33503. * Defines the actions happening during the per camera render target step.
  33504. */
  33505. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33506. /**
  33507. * @hidden
  33508. * Defines the actions happening just before the active camera is drawing.
  33509. */
  33510. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33511. /**
  33512. * @hidden
  33513. * Defines the actions happening just before a render target is drawing.
  33514. */
  33515. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33516. /**
  33517. * @hidden
  33518. * Defines the actions happening just before a rendering group is drawing.
  33519. */
  33520. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33521. /**
  33522. * @hidden
  33523. * Defines the actions happening just before a mesh is drawing.
  33524. */
  33525. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33526. /**
  33527. * @hidden
  33528. * Defines the actions happening just after a mesh has been drawn.
  33529. */
  33530. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33531. /**
  33532. * @hidden
  33533. * Defines the actions happening just after a rendering group has been drawn.
  33534. */
  33535. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33536. /**
  33537. * @hidden
  33538. * Defines the actions happening just after the active camera has been drawn.
  33539. */
  33540. _afterCameraDrawStage: Stage<CameraStageAction>;
  33541. /**
  33542. * @hidden
  33543. * Defines the actions happening just after a render target has been drawn.
  33544. */
  33545. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33546. /**
  33547. * @hidden
  33548. * Defines the actions happening just after rendering all cameras and computing intersections.
  33549. */
  33550. _afterRenderStage: Stage<SimpleStageAction>;
  33551. /**
  33552. * @hidden
  33553. * Defines the actions happening when a pointer move event happens.
  33554. */
  33555. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33556. /**
  33557. * @hidden
  33558. * Defines the actions happening when a pointer down event happens.
  33559. */
  33560. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33561. /**
  33562. * @hidden
  33563. * Defines the actions happening when a pointer up event happens.
  33564. */
  33565. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33566. /**
  33567. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33568. */
  33569. private geometriesByUniqueId;
  33570. /**
  33571. * Creates a new Scene
  33572. * @param engine defines the engine to use to render this scene
  33573. * @param options defines the scene options
  33574. */
  33575. constructor(engine: Engine, options?: SceneOptions);
  33576. /**
  33577. * Gets a string idenfifying the name of the class
  33578. * @returns "Scene" string
  33579. */
  33580. getClassName(): string;
  33581. private _defaultMeshCandidates;
  33582. /**
  33583. * @hidden
  33584. */
  33585. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33586. private _defaultSubMeshCandidates;
  33587. /**
  33588. * @hidden
  33589. */
  33590. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33591. /**
  33592. * Sets the default candidate providers for the scene.
  33593. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33594. * and getCollidingSubMeshCandidates to their default function
  33595. */
  33596. setDefaultCandidateProviders(): void;
  33597. /**
  33598. * Gets the mesh that is currently under the pointer
  33599. */
  33600. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33601. /**
  33602. * Gets or sets the current on-screen X position of the pointer
  33603. */
  33604. pointerX: number;
  33605. /**
  33606. * Gets or sets the current on-screen Y position of the pointer
  33607. */
  33608. pointerY: number;
  33609. /**
  33610. * Gets the cached material (ie. the latest rendered one)
  33611. * @returns the cached material
  33612. */
  33613. getCachedMaterial(): Nullable<Material>;
  33614. /**
  33615. * Gets the cached effect (ie. the latest rendered one)
  33616. * @returns the cached effect
  33617. */
  33618. getCachedEffect(): Nullable<Effect>;
  33619. /**
  33620. * Gets the cached visibility state (ie. the latest rendered one)
  33621. * @returns the cached visibility state
  33622. */
  33623. getCachedVisibility(): Nullable<number>;
  33624. /**
  33625. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33626. * @param material defines the current material
  33627. * @param effect defines the current effect
  33628. * @param visibility defines the current visibility state
  33629. * @returns true if one parameter is not cached
  33630. */
  33631. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33632. /**
  33633. * Gets the engine associated with the scene
  33634. * @returns an Engine
  33635. */
  33636. getEngine(): Engine;
  33637. /**
  33638. * Gets the total number of vertices rendered per frame
  33639. * @returns the total number of vertices rendered per frame
  33640. */
  33641. getTotalVertices(): number;
  33642. /**
  33643. * Gets the performance counter for total vertices
  33644. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33645. */
  33646. readonly totalVerticesPerfCounter: PerfCounter;
  33647. /**
  33648. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33649. * @returns the total number of active indices rendered per frame
  33650. */
  33651. getActiveIndices(): number;
  33652. /**
  33653. * Gets the performance counter for active indices
  33654. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33655. */
  33656. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33657. /**
  33658. * Gets the total number of active particles rendered per frame
  33659. * @returns the total number of active particles rendered per frame
  33660. */
  33661. getActiveParticles(): number;
  33662. /**
  33663. * Gets the performance counter for active particles
  33664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33665. */
  33666. readonly activeParticlesPerfCounter: PerfCounter;
  33667. /**
  33668. * Gets the total number of active bones rendered per frame
  33669. * @returns the total number of active bones rendered per frame
  33670. */
  33671. getActiveBones(): number;
  33672. /**
  33673. * Gets the performance counter for active bones
  33674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33675. */
  33676. readonly activeBonesPerfCounter: PerfCounter;
  33677. /**
  33678. * Gets the array of active meshes
  33679. * @returns an array of AbstractMesh
  33680. */
  33681. getActiveMeshes(): SmartArray<AbstractMesh>;
  33682. /**
  33683. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33684. * @returns a number
  33685. */
  33686. getAnimationRatio(): number;
  33687. /**
  33688. * Gets an unique Id for the current render phase
  33689. * @returns a number
  33690. */
  33691. getRenderId(): number;
  33692. /**
  33693. * Gets an unique Id for the current frame
  33694. * @returns a number
  33695. */
  33696. getFrameId(): number;
  33697. /** Call this function if you want to manually increment the render Id*/
  33698. incrementRenderId(): void;
  33699. private _createUbo;
  33700. /**
  33701. * Use this method to simulate a pointer move on a mesh
  33702. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33703. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33704. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33705. * @returns the current scene
  33706. */
  33707. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33708. /**
  33709. * Use this method to simulate a pointer down on a mesh
  33710. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33711. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33712. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33713. * @returns the current scene
  33714. */
  33715. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33716. /**
  33717. * Use this method to simulate a pointer up on a mesh
  33718. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33719. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33720. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33721. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33722. * @returns the current scene
  33723. */
  33724. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33725. /**
  33726. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33727. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33728. * @returns true if the pointer was captured
  33729. */
  33730. isPointerCaptured(pointerId?: number): boolean;
  33731. /**
  33732. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33733. * @param attachUp defines if you want to attach events to pointerup
  33734. * @param attachDown defines if you want to attach events to pointerdown
  33735. * @param attachMove defines if you want to attach events to pointermove
  33736. */
  33737. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33738. /** Detaches all event handlers*/
  33739. detachControl(): void;
  33740. /**
  33741. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33742. * Delay loaded resources are not taking in account
  33743. * @return true if all required resources are ready
  33744. */
  33745. isReady(): boolean;
  33746. /** Resets all cached information relative to material (including effect and visibility) */
  33747. resetCachedMaterial(): void;
  33748. /**
  33749. * Registers a function to be called before every frame render
  33750. * @param func defines the function to register
  33751. */
  33752. registerBeforeRender(func: () => void): void;
  33753. /**
  33754. * Unregisters a function called before every frame render
  33755. * @param func defines the function to unregister
  33756. */
  33757. unregisterBeforeRender(func: () => void): void;
  33758. /**
  33759. * Registers a function to be called after every frame render
  33760. * @param func defines the function to register
  33761. */
  33762. registerAfterRender(func: () => void): void;
  33763. /**
  33764. * Unregisters a function called after every frame render
  33765. * @param func defines the function to unregister
  33766. */
  33767. unregisterAfterRender(func: () => void): void;
  33768. private _executeOnceBeforeRender;
  33769. /**
  33770. * The provided function will run before render once and will be disposed afterwards.
  33771. * A timeout delay can be provided so that the function will be executed in N ms.
  33772. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33773. * @param func The function to be executed.
  33774. * @param timeout optional delay in ms
  33775. */
  33776. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33777. /** @hidden */
  33778. _addPendingData(data: any): void;
  33779. /** @hidden */
  33780. _removePendingData(data: any): void;
  33781. /**
  33782. * Returns the number of items waiting to be loaded
  33783. * @returns the number of items waiting to be loaded
  33784. */
  33785. getWaitingItemsCount(): number;
  33786. /**
  33787. * Returns a boolean indicating if the scene is still loading data
  33788. */
  33789. readonly isLoading: boolean;
  33790. /**
  33791. * Registers a function to be executed when the scene is ready
  33792. * @param {Function} func - the function to be executed
  33793. */
  33794. executeWhenReady(func: () => void): void;
  33795. /**
  33796. * Returns a promise that resolves when the scene is ready
  33797. * @returns A promise that resolves when the scene is ready
  33798. */
  33799. whenReadyAsync(): Promise<void>;
  33800. /** @hidden */
  33801. _checkIsReady(): void;
  33802. /**
  33803. * Gets all animatable attached to the scene
  33804. */
  33805. readonly animatables: Animatable[];
  33806. /**
  33807. * Resets the last animation time frame.
  33808. * Useful to override when animations start running when loading a scene for the first time.
  33809. */
  33810. resetLastAnimationTimeFrame(): void;
  33811. /**
  33812. * Gets the current view matrix
  33813. * @returns a Matrix
  33814. */
  33815. getViewMatrix(): Matrix;
  33816. /**
  33817. * Gets the current projection matrix
  33818. * @returns a Matrix
  33819. */
  33820. getProjectionMatrix(): Matrix;
  33821. /**
  33822. * Gets the current transform matrix
  33823. * @returns a Matrix made of View * Projection
  33824. */
  33825. getTransformMatrix(): Matrix;
  33826. /**
  33827. * Sets the current transform matrix
  33828. * @param viewL defines the View matrix to use
  33829. * @param projectionL defines the Projection matrix to use
  33830. * @param viewR defines the right View matrix to use (if provided)
  33831. * @param projectionR defines the right Projection matrix to use (if provided)
  33832. */
  33833. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33834. /**
  33835. * Gets the uniform buffer used to store scene data
  33836. * @returns a UniformBuffer
  33837. */
  33838. getSceneUniformBuffer(): UniformBuffer;
  33839. /**
  33840. * Gets an unique (relatively to the current scene) Id
  33841. * @returns an unique number for the scene
  33842. */
  33843. getUniqueId(): number;
  33844. /**
  33845. * Add a mesh to the list of scene's meshes
  33846. * @param newMesh defines the mesh to add
  33847. * @param recursive if all child meshes should also be added to the scene
  33848. */
  33849. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33850. /**
  33851. * Remove a mesh for the list of scene's meshes
  33852. * @param toRemove defines the mesh to remove
  33853. * @param recursive if all child meshes should also be removed from the scene
  33854. * @returns the index where the mesh was in the mesh list
  33855. */
  33856. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33857. /**
  33858. * Add a transform node to the list of scene's transform nodes
  33859. * @param newTransformNode defines the transform node to add
  33860. */
  33861. addTransformNode(newTransformNode: TransformNode): void;
  33862. /**
  33863. * Remove a transform node for the list of scene's transform nodes
  33864. * @param toRemove defines the transform node to remove
  33865. * @returns the index where the transform node was in the transform node list
  33866. */
  33867. removeTransformNode(toRemove: TransformNode): number;
  33868. /**
  33869. * Remove a skeleton for the list of scene's skeletons
  33870. * @param toRemove defines the skeleton to remove
  33871. * @returns the index where the skeleton was in the skeleton list
  33872. */
  33873. removeSkeleton(toRemove: Skeleton): number;
  33874. /**
  33875. * Remove a morph target for the list of scene's morph targets
  33876. * @param toRemove defines the morph target to remove
  33877. * @returns the index where the morph target was in the morph target list
  33878. */
  33879. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33880. /**
  33881. * Remove a light for the list of scene's lights
  33882. * @param toRemove defines the light to remove
  33883. * @returns the index where the light was in the light list
  33884. */
  33885. removeLight(toRemove: Light): number;
  33886. /**
  33887. * Remove a camera for the list of scene's cameras
  33888. * @param toRemove defines the camera to remove
  33889. * @returns the index where the camera was in the camera list
  33890. */
  33891. removeCamera(toRemove: Camera): number;
  33892. /**
  33893. * Remove a particle system for the list of scene's particle systems
  33894. * @param toRemove defines the particle system to remove
  33895. * @returns the index where the particle system was in the particle system list
  33896. */
  33897. removeParticleSystem(toRemove: IParticleSystem): number;
  33898. /**
  33899. * Remove a animation for the list of scene's animations
  33900. * @param toRemove defines the animation to remove
  33901. * @returns the index where the animation was in the animation list
  33902. */
  33903. removeAnimation(toRemove: Animation): number;
  33904. /**
  33905. * Will stop the animation of the given target
  33906. * @param target - the target
  33907. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33908. * @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)
  33909. */
  33910. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33911. /**
  33912. * Removes the given animation group from this scene.
  33913. * @param toRemove The animation group to remove
  33914. * @returns The index of the removed animation group
  33915. */
  33916. removeAnimationGroup(toRemove: AnimationGroup): number;
  33917. /**
  33918. * Removes the given multi-material from this scene.
  33919. * @param toRemove The multi-material to remove
  33920. * @returns The index of the removed multi-material
  33921. */
  33922. removeMultiMaterial(toRemove: MultiMaterial): number;
  33923. /**
  33924. * Removes the given material from this scene.
  33925. * @param toRemove The material to remove
  33926. * @returns The index of the removed material
  33927. */
  33928. removeMaterial(toRemove: Material): number;
  33929. /**
  33930. * Removes the given action manager from this scene.
  33931. * @param toRemove The action manager to remove
  33932. * @returns The index of the removed action manager
  33933. */
  33934. removeActionManager(toRemove: AbstractActionManager): number;
  33935. /**
  33936. * Removes the given texture from this scene.
  33937. * @param toRemove The texture to remove
  33938. * @returns The index of the removed texture
  33939. */
  33940. removeTexture(toRemove: BaseTexture): number;
  33941. /**
  33942. * Adds the given light to this scene
  33943. * @param newLight The light to add
  33944. */
  33945. addLight(newLight: Light): void;
  33946. /**
  33947. * Sorts the list list based on light priorities
  33948. */
  33949. sortLightsByPriority(): void;
  33950. /**
  33951. * Adds the given camera to this scene
  33952. * @param newCamera The camera to add
  33953. */
  33954. addCamera(newCamera: Camera): void;
  33955. /**
  33956. * Adds the given skeleton to this scene
  33957. * @param newSkeleton The skeleton to add
  33958. */
  33959. addSkeleton(newSkeleton: Skeleton): void;
  33960. /**
  33961. * Adds the given particle system to this scene
  33962. * @param newParticleSystem The particle system to add
  33963. */
  33964. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33965. /**
  33966. * Adds the given animation to this scene
  33967. * @param newAnimation The animation to add
  33968. */
  33969. addAnimation(newAnimation: Animation): void;
  33970. /**
  33971. * Adds the given animation group to this scene.
  33972. * @param newAnimationGroup The animation group to add
  33973. */
  33974. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33975. /**
  33976. * Adds the given multi-material to this scene
  33977. * @param newMultiMaterial The multi-material to add
  33978. */
  33979. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33980. /**
  33981. * Adds the given material to this scene
  33982. * @param newMaterial The material to add
  33983. */
  33984. addMaterial(newMaterial: Material): void;
  33985. /**
  33986. * Adds the given morph target to this scene
  33987. * @param newMorphTargetManager The morph target to add
  33988. */
  33989. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33990. /**
  33991. * Adds the given geometry to this scene
  33992. * @param newGeometry The geometry to add
  33993. */
  33994. addGeometry(newGeometry: Geometry): void;
  33995. /**
  33996. * Adds the given action manager to this scene
  33997. * @param newActionManager The action manager to add
  33998. */
  33999. addActionManager(newActionManager: AbstractActionManager): void;
  34000. /**
  34001. * Adds the given texture to this scene.
  34002. * @param newTexture The texture to add
  34003. */
  34004. addTexture(newTexture: BaseTexture): void;
  34005. /**
  34006. * Switch active camera
  34007. * @param newCamera defines the new active camera
  34008. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34009. */
  34010. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34011. /**
  34012. * sets the active camera of the scene using its ID
  34013. * @param id defines the camera's ID
  34014. * @return the new active camera or null if none found.
  34015. */
  34016. setActiveCameraByID(id: string): Nullable<Camera>;
  34017. /**
  34018. * sets the active camera of the scene using its name
  34019. * @param name defines the camera's name
  34020. * @returns the new active camera or null if none found.
  34021. */
  34022. setActiveCameraByName(name: string): Nullable<Camera>;
  34023. /**
  34024. * get an animation group using its name
  34025. * @param name defines the material's name
  34026. * @return the animation group or null if none found.
  34027. */
  34028. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34029. /**
  34030. * Get a material using its unique id
  34031. * @param uniqueId defines the material's unique id
  34032. * @return the material or null if none found.
  34033. */
  34034. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34035. /**
  34036. * get a material using its id
  34037. * @param id defines the material's ID
  34038. * @return the material or null if none found.
  34039. */
  34040. getMaterialByID(id: string): Nullable<Material>;
  34041. /**
  34042. * Gets a material using its name
  34043. * @param name defines the material's name
  34044. * @return the material or null if none found.
  34045. */
  34046. getMaterialByName(name: string): Nullable<Material>;
  34047. /**
  34048. * Gets a camera using its id
  34049. * @param id defines the id to look for
  34050. * @returns the camera or null if not found
  34051. */
  34052. getCameraByID(id: string): Nullable<Camera>;
  34053. /**
  34054. * Gets a camera using its unique id
  34055. * @param uniqueId defines the unique id to look for
  34056. * @returns the camera or null if not found
  34057. */
  34058. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34059. /**
  34060. * Gets a camera using its name
  34061. * @param name defines the camera's name
  34062. * @return the camera or null if none found.
  34063. */
  34064. getCameraByName(name: string): Nullable<Camera>;
  34065. /**
  34066. * Gets a bone using its id
  34067. * @param id defines the bone's id
  34068. * @return the bone or null if not found
  34069. */
  34070. getBoneByID(id: string): Nullable<Bone>;
  34071. /**
  34072. * Gets a bone using its id
  34073. * @param name defines the bone's name
  34074. * @return the bone or null if not found
  34075. */
  34076. getBoneByName(name: string): Nullable<Bone>;
  34077. /**
  34078. * Gets a light node using its name
  34079. * @param name defines the the light's name
  34080. * @return the light or null if none found.
  34081. */
  34082. getLightByName(name: string): Nullable<Light>;
  34083. /**
  34084. * Gets a light node using its id
  34085. * @param id defines the light's id
  34086. * @return the light or null if none found.
  34087. */
  34088. getLightByID(id: string): Nullable<Light>;
  34089. /**
  34090. * Gets a light node using its scene-generated unique ID
  34091. * @param uniqueId defines the light's unique id
  34092. * @return the light or null if none found.
  34093. */
  34094. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34095. /**
  34096. * Gets a particle system by id
  34097. * @param id defines the particle system id
  34098. * @return the corresponding system or null if none found
  34099. */
  34100. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34101. /**
  34102. * Gets a geometry using its ID
  34103. * @param id defines the geometry's id
  34104. * @return the geometry or null if none found.
  34105. */
  34106. getGeometryByID(id: string): Nullable<Geometry>;
  34107. private _getGeometryByUniqueID;
  34108. /**
  34109. * Add a new geometry to this scene
  34110. * @param geometry defines the geometry to be added to the scene.
  34111. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34112. * @return a boolean defining if the geometry was added or not
  34113. */
  34114. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34115. /**
  34116. * Removes an existing geometry
  34117. * @param geometry defines the geometry to be removed from the scene
  34118. * @return a boolean defining if the geometry was removed or not
  34119. */
  34120. removeGeometry(geometry: Geometry): boolean;
  34121. /**
  34122. * Gets the list of geometries attached to the scene
  34123. * @returns an array of Geometry
  34124. */
  34125. getGeometries(): Geometry[];
  34126. /**
  34127. * Gets the first added mesh found of a given ID
  34128. * @param id defines the id to search for
  34129. * @return the mesh found or null if not found at all
  34130. */
  34131. getMeshByID(id: string): Nullable<AbstractMesh>;
  34132. /**
  34133. * Gets a list of meshes using their id
  34134. * @param id defines the id to search for
  34135. * @returns a list of meshes
  34136. */
  34137. getMeshesByID(id: string): Array<AbstractMesh>;
  34138. /**
  34139. * Gets the first added transform node found of a given ID
  34140. * @param id defines the id to search for
  34141. * @return the found transform node or null if not found at all.
  34142. */
  34143. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34144. /**
  34145. * Gets a transform node with its auto-generated unique id
  34146. * @param uniqueId efines the unique id to search for
  34147. * @return the found transform node or null if not found at all.
  34148. */
  34149. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34150. /**
  34151. * Gets a list of transform nodes using their id
  34152. * @param id defines the id to search for
  34153. * @returns a list of transform nodes
  34154. */
  34155. getTransformNodesByID(id: string): Array<TransformNode>;
  34156. /**
  34157. * Gets a mesh with its auto-generated unique id
  34158. * @param uniqueId defines the unique id to search for
  34159. * @return the found mesh or null if not found at all.
  34160. */
  34161. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34162. /**
  34163. * Gets a the last added mesh using a given id
  34164. * @param id defines the id to search for
  34165. * @return the found mesh or null if not found at all.
  34166. */
  34167. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34168. /**
  34169. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34170. * @param id defines the id to search for
  34171. * @return the found node or null if not found at all
  34172. */
  34173. getLastEntryByID(id: string): Nullable<Node>;
  34174. /**
  34175. * Gets a node (Mesh, Camera, Light) using a given id
  34176. * @param id defines the id to search for
  34177. * @return the found node or null if not found at all
  34178. */
  34179. getNodeByID(id: string): Nullable<Node>;
  34180. /**
  34181. * Gets a node (Mesh, Camera, Light) using a given name
  34182. * @param name defines the name to search for
  34183. * @return the found node or null if not found at all.
  34184. */
  34185. getNodeByName(name: string): Nullable<Node>;
  34186. /**
  34187. * Gets a mesh using a given name
  34188. * @param name defines the name to search for
  34189. * @return the found mesh or null if not found at all.
  34190. */
  34191. getMeshByName(name: string): Nullable<AbstractMesh>;
  34192. /**
  34193. * Gets a transform node using a given name
  34194. * @param name defines the name to search for
  34195. * @return the found transform node or null if not found at all.
  34196. */
  34197. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34198. /**
  34199. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34200. * @param id defines the id to search for
  34201. * @return the found skeleton or null if not found at all.
  34202. */
  34203. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34204. /**
  34205. * Gets a skeleton using a given auto generated unique id
  34206. * @param uniqueId defines the unique id to search for
  34207. * @return the found skeleton or null if not found at all.
  34208. */
  34209. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34210. /**
  34211. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34212. * @param id defines the id to search for
  34213. * @return the found skeleton or null if not found at all.
  34214. */
  34215. getSkeletonById(id: string): Nullable<Skeleton>;
  34216. /**
  34217. * Gets a skeleton using a given name
  34218. * @param name defines the name to search for
  34219. * @return the found skeleton or null if not found at all.
  34220. */
  34221. getSkeletonByName(name: string): Nullable<Skeleton>;
  34222. /**
  34223. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34224. * @param id defines the id to search for
  34225. * @return the found morph target manager or null if not found at all.
  34226. */
  34227. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34228. /**
  34229. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34230. * @param id defines the id to search for
  34231. * @return the found morph target or null if not found at all.
  34232. */
  34233. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34234. /**
  34235. * Gets a boolean indicating if the given mesh is active
  34236. * @param mesh defines the mesh to look for
  34237. * @returns true if the mesh is in the active list
  34238. */
  34239. isActiveMesh(mesh: AbstractMesh): boolean;
  34240. /**
  34241. * Return a unique id as a string which can serve as an identifier for the scene
  34242. */
  34243. readonly uid: string;
  34244. /**
  34245. * Add an externaly attached data from its key.
  34246. * This method call will fail and return false, if such key already exists.
  34247. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34248. * @param key the unique key that identifies the data
  34249. * @param data the data object to associate to the key for this Engine instance
  34250. * @return true if no such key were already present and the data was added successfully, false otherwise
  34251. */
  34252. addExternalData<T>(key: string, data: T): boolean;
  34253. /**
  34254. * Get an externaly attached data from its key
  34255. * @param key the unique key that identifies the data
  34256. * @return the associated data, if present (can be null), or undefined if not present
  34257. */
  34258. getExternalData<T>(key: string): Nullable<T>;
  34259. /**
  34260. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34261. * @param key the unique key that identifies the data
  34262. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34263. * @return the associated data, can be null if the factory returned null.
  34264. */
  34265. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34266. /**
  34267. * Remove an externaly attached data from the Engine instance
  34268. * @param key the unique key that identifies the data
  34269. * @return true if the data was successfully removed, false if it doesn't exist
  34270. */
  34271. removeExternalData(key: string): boolean;
  34272. private _evaluateSubMesh;
  34273. /**
  34274. * Clear the processed materials smart array preventing retention point in material dispose.
  34275. */
  34276. freeProcessedMaterials(): void;
  34277. private _preventFreeActiveMeshesAndRenderingGroups;
  34278. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34279. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34280. * when disposing several meshes in a row or a hierarchy of meshes.
  34281. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34282. */
  34283. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34284. /**
  34285. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34286. */
  34287. freeActiveMeshes(): void;
  34288. /**
  34289. * Clear the info related to rendering groups preventing retention points during dispose.
  34290. */
  34291. freeRenderingGroups(): void;
  34292. /** @hidden */
  34293. _isInIntermediateRendering(): boolean;
  34294. /**
  34295. * Lambda returning the list of potentially active meshes.
  34296. */
  34297. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34298. /**
  34299. * Lambda returning the list of potentially active sub meshes.
  34300. */
  34301. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34302. /**
  34303. * Lambda returning the list of potentially intersecting sub meshes.
  34304. */
  34305. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34306. /**
  34307. * Lambda returning the list of potentially colliding sub meshes.
  34308. */
  34309. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34310. private _activeMeshesFrozen;
  34311. /**
  34312. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34313. * @returns the current scene
  34314. */
  34315. freezeActiveMeshes(): Scene;
  34316. /**
  34317. * Use this function to restart evaluating active meshes on every frame
  34318. * @returns the current scene
  34319. */
  34320. unfreezeActiveMeshes(): Scene;
  34321. private _evaluateActiveMeshes;
  34322. private _activeMesh;
  34323. /**
  34324. * Update the transform matrix to update from the current active camera
  34325. * @param force defines a boolean used to force the update even if cache is up to date
  34326. */
  34327. updateTransformMatrix(force?: boolean): void;
  34328. private _bindFrameBuffer;
  34329. /** @hidden */
  34330. _allowPostProcessClearColor: boolean;
  34331. /** @hidden */
  34332. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34333. private _processSubCameras;
  34334. private _checkIntersections;
  34335. /** @hidden */
  34336. _advancePhysicsEngineStep(step: number): void;
  34337. /**
  34338. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34339. */
  34340. getDeterministicFrameTime: () => number;
  34341. /** @hidden */
  34342. _animate(): void;
  34343. /** Execute all animations (for a frame) */
  34344. animate(): void;
  34345. /**
  34346. * Render the scene
  34347. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34348. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34349. */
  34350. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34351. /**
  34352. * Freeze all materials
  34353. * A frozen material will not be updatable but should be faster to render
  34354. */
  34355. freezeMaterials(): void;
  34356. /**
  34357. * Unfreeze all materials
  34358. * A frozen material will not be updatable but should be faster to render
  34359. */
  34360. unfreezeMaterials(): void;
  34361. /**
  34362. * Releases all held ressources
  34363. */
  34364. dispose(): void;
  34365. /**
  34366. * Gets if the scene is already disposed
  34367. */
  34368. readonly isDisposed: boolean;
  34369. /**
  34370. * Call this function to reduce memory footprint of the scene.
  34371. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34372. */
  34373. clearCachedVertexData(): void;
  34374. /**
  34375. * This function will remove the local cached buffer data from texture.
  34376. * It will save memory but will prevent the texture from being rebuilt
  34377. */
  34378. cleanCachedTextureBuffer(): void;
  34379. /**
  34380. * Get the world extend vectors with an optional filter
  34381. *
  34382. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34383. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34384. */
  34385. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34386. min: Vector3;
  34387. max: Vector3;
  34388. };
  34389. /**
  34390. * Creates a ray that can be used to pick in the scene
  34391. * @param x defines the x coordinate of the origin (on-screen)
  34392. * @param y defines the y coordinate of the origin (on-screen)
  34393. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34394. * @param camera defines the camera to use for the picking
  34395. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34396. * @returns a Ray
  34397. */
  34398. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34399. /**
  34400. * Creates a ray that can be used to pick in the scene
  34401. * @param x defines the x coordinate of the origin (on-screen)
  34402. * @param y defines the y coordinate of the origin (on-screen)
  34403. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34404. * @param result defines the ray where to store the picking ray
  34405. * @param camera defines the camera to use for the picking
  34406. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34407. * @returns the current scene
  34408. */
  34409. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34410. /**
  34411. * Creates a ray that can be used to pick in the scene
  34412. * @param x defines the x coordinate of the origin (on-screen)
  34413. * @param y defines the y coordinate of the origin (on-screen)
  34414. * @param camera defines the camera to use for the picking
  34415. * @returns a Ray
  34416. */
  34417. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34418. /**
  34419. * Creates a ray that can be used to pick in the scene
  34420. * @param x defines the x coordinate of the origin (on-screen)
  34421. * @param y defines the y coordinate of the origin (on-screen)
  34422. * @param result defines the ray where to store the picking ray
  34423. * @param camera defines the camera to use for the picking
  34424. * @returns the current scene
  34425. */
  34426. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34427. /** Launch a ray to try to pick a mesh in the scene
  34428. * @param x position on screen
  34429. * @param y position on screen
  34430. * @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
  34431. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34432. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34433. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34434. * @returns a PickingInfo
  34435. */
  34436. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34437. /** Use the given ray to pick a mesh in the scene
  34438. * @param ray The ray to use to pick meshes
  34439. * @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
  34440. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34441. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34442. * @returns a PickingInfo
  34443. */
  34444. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34445. /**
  34446. * Launch a ray to try to pick a mesh in the scene
  34447. * @param x X position on screen
  34448. * @param y Y position on screen
  34449. * @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
  34450. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34451. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34452. * @returns an array of PickingInfo
  34453. */
  34454. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34455. /**
  34456. * Launch a ray to try to pick a mesh in the scene
  34457. * @param ray Ray to use
  34458. * @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
  34459. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34460. * @returns an array of PickingInfo
  34461. */
  34462. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34463. /**
  34464. * Force the value of meshUnderPointer
  34465. * @param mesh defines the mesh to use
  34466. */
  34467. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34468. /**
  34469. * Gets the mesh under the pointer
  34470. * @returns a Mesh or null if no mesh is under the pointer
  34471. */
  34472. getPointerOverMesh(): Nullable<AbstractMesh>;
  34473. /** @hidden */
  34474. _rebuildGeometries(): void;
  34475. /** @hidden */
  34476. _rebuildTextures(): void;
  34477. private _getByTags;
  34478. /**
  34479. * Get a list of meshes by tags
  34480. * @param tagsQuery defines the tags query to use
  34481. * @param forEach defines a predicate used to filter results
  34482. * @returns an array of Mesh
  34483. */
  34484. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34485. /**
  34486. * Get a list of cameras by tags
  34487. * @param tagsQuery defines the tags query to use
  34488. * @param forEach defines a predicate used to filter results
  34489. * @returns an array of Camera
  34490. */
  34491. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34492. /**
  34493. * Get a list of lights by tags
  34494. * @param tagsQuery defines the tags query to use
  34495. * @param forEach defines a predicate used to filter results
  34496. * @returns an array of Light
  34497. */
  34498. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34499. /**
  34500. * Get a list of materials by tags
  34501. * @param tagsQuery defines the tags query to use
  34502. * @param forEach defines a predicate used to filter results
  34503. * @returns an array of Material
  34504. */
  34505. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34506. /**
  34507. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34508. * This allowed control for front to back rendering or reversly depending of the special needs.
  34509. *
  34510. * @param renderingGroupId The rendering group id corresponding to its index
  34511. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34512. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34513. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34514. */
  34515. 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;
  34516. /**
  34517. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34518. *
  34519. * @param renderingGroupId The rendering group id corresponding to its index
  34520. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34521. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34522. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34523. */
  34524. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34525. /**
  34526. * Gets the current auto clear configuration for one rendering group of the rendering
  34527. * manager.
  34528. * @param index the rendering group index to get the information for
  34529. * @returns The auto clear setup for the requested rendering group
  34530. */
  34531. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34532. private _blockMaterialDirtyMechanism;
  34533. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34534. blockMaterialDirtyMechanism: boolean;
  34535. /**
  34536. * Will flag all materials as dirty to trigger new shader compilation
  34537. * @param flag defines the flag used to specify which material part must be marked as dirty
  34538. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34539. */
  34540. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34541. /** @hidden */
  34542. _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;
  34543. /** @hidden */
  34544. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34545. }
  34546. }
  34547. declare module "babylonjs/assetContainer" {
  34548. import { AbstractScene } from "babylonjs/abstractScene";
  34549. import { Scene } from "babylonjs/scene";
  34550. import { Mesh } from "babylonjs/Meshes/mesh";
  34551. /**
  34552. * Set of assets to keep when moving a scene into an asset container.
  34553. */
  34554. export class KeepAssets extends AbstractScene {
  34555. }
  34556. /**
  34557. * Container with a set of assets that can be added or removed from a scene.
  34558. */
  34559. export class AssetContainer extends AbstractScene {
  34560. /**
  34561. * The scene the AssetContainer belongs to.
  34562. */
  34563. scene: Scene;
  34564. /**
  34565. * Instantiates an AssetContainer.
  34566. * @param scene The scene the AssetContainer belongs to.
  34567. */
  34568. constructor(scene: Scene);
  34569. /**
  34570. * Adds all the assets from the container to the scene.
  34571. */
  34572. addAllToScene(): void;
  34573. /**
  34574. * Removes all the assets in the container from the scene
  34575. */
  34576. removeAllFromScene(): void;
  34577. /**
  34578. * Disposes all the assets in the container
  34579. */
  34580. dispose(): void;
  34581. private _moveAssets;
  34582. /**
  34583. * Removes all the assets contained in the scene and adds them to the container.
  34584. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34585. */
  34586. moveAllFromScene(keepAssets?: KeepAssets): void;
  34587. /**
  34588. * 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.
  34589. * @returns the root mesh
  34590. */
  34591. createRootMesh(): Mesh;
  34592. }
  34593. }
  34594. declare module "babylonjs/abstractScene" {
  34595. import { Scene } from "babylonjs/scene";
  34596. import { Nullable } from "babylonjs/types";
  34597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34599. import { Geometry } from "babylonjs/Meshes/geometry";
  34600. import { Skeleton } from "babylonjs/Bones/skeleton";
  34601. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34602. import { AssetContainer } from "babylonjs/assetContainer";
  34603. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34604. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34606. import { Material } from "babylonjs/Materials/material";
  34607. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34608. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34609. import { Camera } from "babylonjs/Cameras/camera";
  34610. import { Light } from "babylonjs/Lights/light";
  34611. import { Node } from "babylonjs/node";
  34612. import { Animation } from "babylonjs/Animations/animation";
  34613. /**
  34614. * Defines how the parser contract is defined.
  34615. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34616. */
  34617. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34618. /**
  34619. * Defines how the individual parser contract is defined.
  34620. * These parser can parse an individual asset
  34621. */
  34622. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34623. /**
  34624. * Base class of the scene acting as a container for the different elements composing a scene.
  34625. * This class is dynamically extended by the different components of the scene increasing
  34626. * flexibility and reducing coupling
  34627. */
  34628. export abstract class AbstractScene {
  34629. /**
  34630. * Stores the list of available parsers in the application.
  34631. */
  34632. private static _BabylonFileParsers;
  34633. /**
  34634. * Stores the list of available individual parsers in the application.
  34635. */
  34636. private static _IndividualBabylonFileParsers;
  34637. /**
  34638. * Adds a parser in the list of available ones
  34639. * @param name Defines the name of the parser
  34640. * @param parser Defines the parser to add
  34641. */
  34642. static AddParser(name: string, parser: BabylonFileParser): void;
  34643. /**
  34644. * Gets a general parser from the list of avaialble ones
  34645. * @param name Defines the name of the parser
  34646. * @returns the requested parser or null
  34647. */
  34648. static GetParser(name: string): Nullable<BabylonFileParser>;
  34649. /**
  34650. * Adds n individual parser in the list of available ones
  34651. * @param name Defines the name of the parser
  34652. * @param parser Defines the parser to add
  34653. */
  34654. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34655. /**
  34656. * Gets an individual parser from the list of avaialble ones
  34657. * @param name Defines the name of the parser
  34658. * @returns the requested parser or null
  34659. */
  34660. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34661. /**
  34662. * Parser json data and populate both a scene and its associated container object
  34663. * @param jsonData Defines the data to parse
  34664. * @param scene Defines the scene to parse the data for
  34665. * @param container Defines the container attached to the parsing sequence
  34666. * @param rootUrl Defines the root url of the data
  34667. */
  34668. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34669. /**
  34670. * Gets the list of root nodes (ie. nodes with no parent)
  34671. */
  34672. rootNodes: Node[];
  34673. /** All of the cameras added to this scene
  34674. * @see http://doc.babylonjs.com/babylon101/cameras
  34675. */
  34676. cameras: Camera[];
  34677. /**
  34678. * All of the lights added to this scene
  34679. * @see http://doc.babylonjs.com/babylon101/lights
  34680. */
  34681. lights: Light[];
  34682. /**
  34683. * All of the (abstract) meshes added to this scene
  34684. */
  34685. meshes: AbstractMesh[];
  34686. /**
  34687. * The list of skeletons added to the scene
  34688. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34689. */
  34690. skeletons: Skeleton[];
  34691. /**
  34692. * All of the particle systems added to this scene
  34693. * @see http://doc.babylonjs.com/babylon101/particles
  34694. */
  34695. particleSystems: IParticleSystem[];
  34696. /**
  34697. * Gets a list of Animations associated with the scene
  34698. */
  34699. animations: Animation[];
  34700. /**
  34701. * All of the animation groups added to this scene
  34702. * @see http://doc.babylonjs.com/how_to/group
  34703. */
  34704. animationGroups: AnimationGroup[];
  34705. /**
  34706. * All of the multi-materials added to this scene
  34707. * @see http://doc.babylonjs.com/how_to/multi_materials
  34708. */
  34709. multiMaterials: MultiMaterial[];
  34710. /**
  34711. * All of the materials added to this scene
  34712. * In the context of a Scene, it is not supposed to be modified manually.
  34713. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34714. * Note also that the order of the Material wihin the array is not significant and might change.
  34715. * @see http://doc.babylonjs.com/babylon101/materials
  34716. */
  34717. materials: Material[];
  34718. /**
  34719. * The list of morph target managers added to the scene
  34720. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34721. */
  34722. morphTargetManagers: MorphTargetManager[];
  34723. /**
  34724. * The list of geometries used in the scene.
  34725. */
  34726. geometries: Geometry[];
  34727. /**
  34728. * All of the tranform nodes added to this scene
  34729. * In the context of a Scene, it is not supposed to be modified manually.
  34730. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34731. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34732. * @see http://doc.babylonjs.com/how_to/transformnode
  34733. */
  34734. transformNodes: TransformNode[];
  34735. /**
  34736. * ActionManagers available on the scene.
  34737. */
  34738. actionManagers: AbstractActionManager[];
  34739. /**
  34740. * Textures to keep.
  34741. */
  34742. textures: BaseTexture[];
  34743. /**
  34744. * Environment texture for the scene
  34745. */
  34746. environmentTexture: Nullable<BaseTexture>;
  34747. }
  34748. }
  34749. declare module "babylonjs/Audio/sound" {
  34750. import { Observable } from "babylonjs/Misc/observable";
  34751. import { Vector3 } from "babylonjs/Maths/math";
  34752. import { Nullable } from "babylonjs/types";
  34753. import { Scene } from "babylonjs/scene";
  34754. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34755. /**
  34756. * Defines a sound that can be played in the application.
  34757. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34759. */
  34760. export class Sound {
  34761. /**
  34762. * The name of the sound in the scene.
  34763. */
  34764. name: string;
  34765. /**
  34766. * Does the sound autoplay once loaded.
  34767. */
  34768. autoplay: boolean;
  34769. /**
  34770. * Does the sound loop after it finishes playing once.
  34771. */
  34772. loop: boolean;
  34773. /**
  34774. * Does the sound use a custom attenuation curve to simulate the falloff
  34775. * happening when the source gets further away from the camera.
  34776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34777. */
  34778. useCustomAttenuation: boolean;
  34779. /**
  34780. * The sound track id this sound belongs to.
  34781. */
  34782. soundTrackId: number;
  34783. /**
  34784. * Is this sound currently played.
  34785. */
  34786. isPlaying: boolean;
  34787. /**
  34788. * Is this sound currently paused.
  34789. */
  34790. isPaused: boolean;
  34791. /**
  34792. * Does this sound enables spatial sound.
  34793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34794. */
  34795. spatialSound: boolean;
  34796. /**
  34797. * Define the reference distance the sound should be heard perfectly.
  34798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34799. */
  34800. refDistance: number;
  34801. /**
  34802. * Define the roll off factor of spatial sounds.
  34803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34804. */
  34805. rolloffFactor: number;
  34806. /**
  34807. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34809. */
  34810. maxDistance: number;
  34811. /**
  34812. * Define the distance attenuation model the sound will follow.
  34813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34814. */
  34815. distanceModel: string;
  34816. /**
  34817. * @hidden
  34818. * Back Compat
  34819. **/
  34820. onended: () => any;
  34821. /**
  34822. * Observable event when the current playing sound finishes.
  34823. */
  34824. onEndedObservable: Observable<Sound>;
  34825. private _panningModel;
  34826. private _playbackRate;
  34827. private _streaming;
  34828. private _startTime;
  34829. private _startOffset;
  34830. private _position;
  34831. /** @hidden */
  34832. _positionInEmitterSpace: boolean;
  34833. private _localDirection;
  34834. private _volume;
  34835. private _isReadyToPlay;
  34836. private _isDirectional;
  34837. private _readyToPlayCallback;
  34838. private _audioBuffer;
  34839. private _soundSource;
  34840. private _streamingSource;
  34841. private _soundPanner;
  34842. private _soundGain;
  34843. private _inputAudioNode;
  34844. private _outputAudioNode;
  34845. private _coneInnerAngle;
  34846. private _coneOuterAngle;
  34847. private _coneOuterGain;
  34848. private _scene;
  34849. private _connectedTransformNode;
  34850. private _customAttenuationFunction;
  34851. private _registerFunc;
  34852. private _isOutputConnected;
  34853. private _htmlAudioElement;
  34854. private _urlType;
  34855. /** @hidden */
  34856. static _SceneComponentInitialization: (scene: Scene) => void;
  34857. /**
  34858. * Create a sound and attach it to a scene
  34859. * @param name Name of your sound
  34860. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34861. * @param scene defines the scene the sound belongs to
  34862. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34863. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34864. */
  34865. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34866. /**
  34867. * Release the sound and its associated resources
  34868. */
  34869. dispose(): void;
  34870. /**
  34871. * Gets if the sounds is ready to be played or not.
  34872. * @returns true if ready, otherwise false
  34873. */
  34874. isReady(): boolean;
  34875. private _soundLoaded;
  34876. /**
  34877. * Sets the data of the sound from an audiobuffer
  34878. * @param audioBuffer The audioBuffer containing the data
  34879. */
  34880. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34881. /**
  34882. * Updates the current sounds options such as maxdistance, loop...
  34883. * @param options A JSON object containing values named as the object properties
  34884. */
  34885. updateOptions(options: any): void;
  34886. private _createSpatialParameters;
  34887. private _updateSpatialParameters;
  34888. /**
  34889. * Switch the panning model to HRTF:
  34890. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34892. */
  34893. switchPanningModelToHRTF(): void;
  34894. /**
  34895. * Switch the panning model to Equal Power:
  34896. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34898. */
  34899. switchPanningModelToEqualPower(): void;
  34900. private _switchPanningModel;
  34901. /**
  34902. * Connect this sound to a sound track audio node like gain...
  34903. * @param soundTrackAudioNode the sound track audio node to connect to
  34904. */
  34905. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34906. /**
  34907. * Transform this sound into a directional source
  34908. * @param coneInnerAngle Size of the inner cone in degree
  34909. * @param coneOuterAngle Size of the outer cone in degree
  34910. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34911. */
  34912. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34913. /**
  34914. * Gets or sets the inner angle for the directional cone.
  34915. */
  34916. /**
  34917. * Gets or sets the inner angle for the directional cone.
  34918. */
  34919. directionalConeInnerAngle: number;
  34920. /**
  34921. * Gets or sets the outer angle for the directional cone.
  34922. */
  34923. /**
  34924. * Gets or sets the outer angle for the directional cone.
  34925. */
  34926. directionalConeOuterAngle: number;
  34927. /**
  34928. * Sets the position of the emitter if spatial sound is enabled
  34929. * @param newPosition Defines the new posisiton
  34930. */
  34931. setPosition(newPosition: Vector3): void;
  34932. /**
  34933. * Sets the local direction of the emitter if spatial sound is enabled
  34934. * @param newLocalDirection Defines the new local direction
  34935. */
  34936. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34937. private _updateDirection;
  34938. /** @hidden */
  34939. updateDistanceFromListener(): void;
  34940. /**
  34941. * Sets a new custom attenuation function for the sound.
  34942. * @param callback Defines the function used for the attenuation
  34943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34944. */
  34945. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34946. /**
  34947. * Play the sound
  34948. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34949. * @param offset (optional) Start the sound setting it at a specific time
  34950. */
  34951. play(time?: number, offset?: number): void;
  34952. private _onended;
  34953. /**
  34954. * Stop the sound
  34955. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34956. */
  34957. stop(time?: number): void;
  34958. /**
  34959. * Put the sound in pause
  34960. */
  34961. pause(): void;
  34962. /**
  34963. * Sets a dedicated volume for this sounds
  34964. * @param newVolume Define the new volume of the sound
  34965. * @param time Define in how long the sound should be at this value
  34966. */
  34967. setVolume(newVolume: number, time?: number): void;
  34968. /**
  34969. * Set the sound play back rate
  34970. * @param newPlaybackRate Define the playback rate the sound should be played at
  34971. */
  34972. setPlaybackRate(newPlaybackRate: number): void;
  34973. /**
  34974. * Gets the volume of the sound.
  34975. * @returns the volume of the sound
  34976. */
  34977. getVolume(): number;
  34978. /**
  34979. * Attach the sound to a dedicated mesh
  34980. * @param transformNode The transform node to connect the sound with
  34981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34982. */
  34983. attachToMesh(transformNode: TransformNode): void;
  34984. /**
  34985. * Detach the sound from the previously attached mesh
  34986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34987. */
  34988. detachFromMesh(): void;
  34989. private _onRegisterAfterWorldMatrixUpdate;
  34990. /**
  34991. * Clone the current sound in the scene.
  34992. * @returns the new sound clone
  34993. */
  34994. clone(): Nullable<Sound>;
  34995. /**
  34996. * Gets the current underlying audio buffer containing the data
  34997. * @returns the audio buffer
  34998. */
  34999. getAudioBuffer(): Nullable<AudioBuffer>;
  35000. /**
  35001. * Serializes the Sound in a JSON representation
  35002. * @returns the JSON representation of the sound
  35003. */
  35004. serialize(): any;
  35005. /**
  35006. * Parse a JSON representation of a sound to innstantiate in a given scene
  35007. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35008. * @param scene Define the scene the new parsed sound should be created in
  35009. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35010. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35011. * @returns the newly parsed sound
  35012. */
  35013. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35014. }
  35015. }
  35016. declare module "babylonjs/Actions/directAudioActions" {
  35017. import { Action } from "babylonjs/Actions/action";
  35018. import { Condition } from "babylonjs/Actions/condition";
  35019. import { Sound } from "babylonjs/Audio/sound";
  35020. /**
  35021. * This defines an action helpful to play a defined sound on a triggered action.
  35022. */
  35023. export class PlaySoundAction extends Action {
  35024. private _sound;
  35025. /**
  35026. * Instantiate the action
  35027. * @param triggerOptions defines the trigger options
  35028. * @param sound defines the sound to play
  35029. * @param condition defines the trigger related conditions
  35030. */
  35031. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35032. /** @hidden */
  35033. _prepare(): void;
  35034. /**
  35035. * Execute the action and play the sound.
  35036. */
  35037. execute(): void;
  35038. /**
  35039. * Serializes the actions and its related information.
  35040. * @param parent defines the object to serialize in
  35041. * @returns the serialized object
  35042. */
  35043. serialize(parent: any): any;
  35044. }
  35045. /**
  35046. * This defines an action helpful to stop a defined sound on a triggered action.
  35047. */
  35048. export class StopSoundAction extends Action {
  35049. private _sound;
  35050. /**
  35051. * Instantiate the action
  35052. * @param triggerOptions defines the trigger options
  35053. * @param sound defines the sound to stop
  35054. * @param condition defines the trigger related conditions
  35055. */
  35056. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35057. /** @hidden */
  35058. _prepare(): void;
  35059. /**
  35060. * Execute the action and stop the sound.
  35061. */
  35062. execute(): void;
  35063. /**
  35064. * Serializes the actions and its related information.
  35065. * @param parent defines the object to serialize in
  35066. * @returns the serialized object
  35067. */
  35068. serialize(parent: any): any;
  35069. }
  35070. }
  35071. declare module "babylonjs/Actions/interpolateValueAction" {
  35072. import { Action } from "babylonjs/Actions/action";
  35073. import { Condition } from "babylonjs/Actions/condition";
  35074. import { Observable } from "babylonjs/Misc/observable";
  35075. /**
  35076. * This defines an action responsible to change the value of a property
  35077. * by interpolating between its current value and the newly set one once triggered.
  35078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35079. */
  35080. export class InterpolateValueAction extends Action {
  35081. /**
  35082. * Defines the path of the property where the value should be interpolated
  35083. */
  35084. propertyPath: string;
  35085. /**
  35086. * Defines the target value at the end of the interpolation.
  35087. */
  35088. value: any;
  35089. /**
  35090. * Defines the time it will take for the property to interpolate to the value.
  35091. */
  35092. duration: number;
  35093. /**
  35094. * Defines if the other scene animations should be stopped when the action has been triggered
  35095. */
  35096. stopOtherAnimations?: boolean;
  35097. /**
  35098. * Defines a callback raised once the interpolation animation has been done.
  35099. */
  35100. onInterpolationDone?: () => void;
  35101. /**
  35102. * Observable triggered once the interpolation animation has been done.
  35103. */
  35104. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35105. private _target;
  35106. private _effectiveTarget;
  35107. private _property;
  35108. /**
  35109. * Instantiate the action
  35110. * @param triggerOptions defines the trigger options
  35111. * @param target defines the object containing the value to interpolate
  35112. * @param propertyPath defines the path to the property in the target object
  35113. * @param value defines the target value at the end of the interpolation
  35114. * @param duration deines the time it will take for the property to interpolate to the value.
  35115. * @param condition defines the trigger related conditions
  35116. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35117. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35118. */
  35119. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35120. /** @hidden */
  35121. _prepare(): void;
  35122. /**
  35123. * Execute the action starts the value interpolation.
  35124. */
  35125. execute(): void;
  35126. /**
  35127. * Serializes the actions and its related information.
  35128. * @param parent defines the object to serialize in
  35129. * @returns the serialized object
  35130. */
  35131. serialize(parent: any): any;
  35132. }
  35133. }
  35134. declare module "babylonjs/Actions/index" {
  35135. export * from "babylonjs/Actions/action";
  35136. export * from "babylonjs/Actions/actionEvent";
  35137. export * from "babylonjs/Actions/actionManager";
  35138. export * from "babylonjs/Actions/condition";
  35139. export * from "babylonjs/Actions/directActions";
  35140. export * from "babylonjs/Actions/directAudioActions";
  35141. export * from "babylonjs/Actions/interpolateValueAction";
  35142. }
  35143. declare module "babylonjs/Animations/index" {
  35144. export * from "babylonjs/Animations/animatable";
  35145. export * from "babylonjs/Animations/animation";
  35146. export * from "babylonjs/Animations/animationGroup";
  35147. export * from "babylonjs/Animations/animationPropertiesOverride";
  35148. export * from "babylonjs/Animations/easing";
  35149. export * from "babylonjs/Animations/runtimeAnimation";
  35150. export * from "babylonjs/Animations/animationEvent";
  35151. export * from "babylonjs/Animations/animationGroup";
  35152. export * from "babylonjs/Animations/animationKey";
  35153. export * from "babylonjs/Animations/animationRange";
  35154. }
  35155. declare module "babylonjs/Audio/soundTrack" {
  35156. import { Sound } from "babylonjs/Audio/sound";
  35157. import { Analyser } from "babylonjs/Audio/analyser";
  35158. import { Scene } from "babylonjs/scene";
  35159. /**
  35160. * Options allowed during the creation of a sound track.
  35161. */
  35162. export interface ISoundTrackOptions {
  35163. /**
  35164. * The volume the sound track should take during creation
  35165. */
  35166. volume?: number;
  35167. /**
  35168. * Define if the sound track is the main sound track of the scene
  35169. */
  35170. mainTrack?: boolean;
  35171. }
  35172. /**
  35173. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35174. * It will be also used in a future release to apply effects on a specific track.
  35175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35176. */
  35177. export class SoundTrack {
  35178. /**
  35179. * The unique identifier of the sound track in the scene.
  35180. */
  35181. id: number;
  35182. /**
  35183. * The list of sounds included in the sound track.
  35184. */
  35185. soundCollection: Array<Sound>;
  35186. private _outputAudioNode;
  35187. private _scene;
  35188. private _isMainTrack;
  35189. private _connectedAnalyser;
  35190. private _options;
  35191. private _isInitialized;
  35192. /**
  35193. * Creates a new sound track.
  35194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35195. * @param scene Define the scene the sound track belongs to
  35196. * @param options
  35197. */
  35198. constructor(scene: Scene, options?: ISoundTrackOptions);
  35199. private _initializeSoundTrackAudioGraph;
  35200. /**
  35201. * Release the sound track and its associated resources
  35202. */
  35203. dispose(): void;
  35204. /**
  35205. * Adds a sound to this sound track
  35206. * @param sound define the cound to add
  35207. * @ignoreNaming
  35208. */
  35209. AddSound(sound: Sound): void;
  35210. /**
  35211. * Removes a sound to this sound track
  35212. * @param sound define the cound to remove
  35213. * @ignoreNaming
  35214. */
  35215. RemoveSound(sound: Sound): void;
  35216. /**
  35217. * Set a global volume for the full sound track.
  35218. * @param newVolume Define the new volume of the sound track
  35219. */
  35220. setVolume(newVolume: number): void;
  35221. /**
  35222. * Switch the panning model to HRTF:
  35223. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35225. */
  35226. switchPanningModelToHRTF(): void;
  35227. /**
  35228. * Switch the panning model to Equal Power:
  35229. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35231. */
  35232. switchPanningModelToEqualPower(): void;
  35233. /**
  35234. * Connect the sound track to an audio analyser allowing some amazing
  35235. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35237. * @param analyser The analyser to connect to the engine
  35238. */
  35239. connectToAnalyser(analyser: Analyser): void;
  35240. }
  35241. }
  35242. declare module "babylonjs/Audio/audioSceneComponent" {
  35243. import { Sound } from "babylonjs/Audio/sound";
  35244. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35245. import { Nullable } from "babylonjs/types";
  35246. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35247. import { Scene } from "babylonjs/scene";
  35248. import { AbstractScene } from "babylonjs/abstractScene";
  35249. module "babylonjs/abstractScene" {
  35250. interface AbstractScene {
  35251. /**
  35252. * The list of sounds used in the scene.
  35253. */
  35254. sounds: Nullable<Array<Sound>>;
  35255. }
  35256. }
  35257. module "babylonjs/scene" {
  35258. interface Scene {
  35259. /**
  35260. * @hidden
  35261. * Backing field
  35262. */
  35263. _mainSoundTrack: SoundTrack;
  35264. /**
  35265. * The main sound track played by the scene.
  35266. * It cotains your primary collection of sounds.
  35267. */
  35268. mainSoundTrack: SoundTrack;
  35269. /**
  35270. * The list of sound tracks added to the scene
  35271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35272. */
  35273. soundTracks: Nullable<Array<SoundTrack>>;
  35274. /**
  35275. * Gets a sound using a given name
  35276. * @param name defines the name to search for
  35277. * @return the found sound or null if not found at all.
  35278. */
  35279. getSoundByName(name: string): Nullable<Sound>;
  35280. /**
  35281. * Gets or sets if audio support is enabled
  35282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35283. */
  35284. audioEnabled: boolean;
  35285. /**
  35286. * Gets or sets if audio will be output to headphones
  35287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35288. */
  35289. headphone: boolean;
  35290. }
  35291. }
  35292. /**
  35293. * Defines the sound scene component responsible to manage any sounds
  35294. * in a given scene.
  35295. */
  35296. export class AudioSceneComponent implements ISceneSerializableComponent {
  35297. /**
  35298. * The component name helpfull to identify the component in the list of scene components.
  35299. */
  35300. readonly name: string;
  35301. /**
  35302. * The scene the component belongs to.
  35303. */
  35304. scene: Scene;
  35305. private _audioEnabled;
  35306. /**
  35307. * Gets whether audio is enabled or not.
  35308. * Please use related enable/disable method to switch state.
  35309. */
  35310. readonly audioEnabled: boolean;
  35311. private _headphone;
  35312. /**
  35313. * Gets whether audio is outputing to headphone or not.
  35314. * Please use the according Switch methods to change output.
  35315. */
  35316. readonly headphone: boolean;
  35317. /**
  35318. * Creates a new instance of the component for the given scene
  35319. * @param scene Defines the scene to register the component in
  35320. */
  35321. constructor(scene: Scene);
  35322. /**
  35323. * Registers the component in a given scene
  35324. */
  35325. register(): void;
  35326. /**
  35327. * Rebuilds the elements related to this component in case of
  35328. * context lost for instance.
  35329. */
  35330. rebuild(): void;
  35331. /**
  35332. * Serializes the component data to the specified json object
  35333. * @param serializationObject The object to serialize to
  35334. */
  35335. serialize(serializationObject: any): void;
  35336. /**
  35337. * Adds all the element from the container to the scene
  35338. * @param container the container holding the elements
  35339. */
  35340. addFromContainer(container: AbstractScene): void;
  35341. /**
  35342. * Removes all the elements in the container from the scene
  35343. * @param container contains the elements to remove
  35344. * @param dispose if the removed element should be disposed (default: false)
  35345. */
  35346. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35347. /**
  35348. * Disposes the component and the associated ressources.
  35349. */
  35350. dispose(): void;
  35351. /**
  35352. * Disables audio in the associated scene.
  35353. */
  35354. disableAudio(): void;
  35355. /**
  35356. * Enables audio in the associated scene.
  35357. */
  35358. enableAudio(): void;
  35359. /**
  35360. * Switch audio to headphone output.
  35361. */
  35362. switchAudioModeForHeadphones(): void;
  35363. /**
  35364. * Switch audio to normal speakers.
  35365. */
  35366. switchAudioModeForNormalSpeakers(): void;
  35367. private _afterRender;
  35368. }
  35369. }
  35370. declare module "babylonjs/Audio/weightedsound" {
  35371. import { Sound } from "babylonjs/Audio/sound";
  35372. /**
  35373. * Wraps one or more Sound objects and selects one with random weight for playback.
  35374. */
  35375. export class WeightedSound {
  35376. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35377. loop: boolean;
  35378. private _coneInnerAngle;
  35379. private _coneOuterAngle;
  35380. private _volume;
  35381. /** A Sound is currently playing. */
  35382. isPlaying: boolean;
  35383. /** A Sound is currently paused. */
  35384. isPaused: boolean;
  35385. private _sounds;
  35386. private _weights;
  35387. private _currentIndex?;
  35388. /**
  35389. * Creates a new WeightedSound from the list of sounds given.
  35390. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35391. * @param sounds Array of Sounds that will be selected from.
  35392. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35393. */
  35394. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35395. /**
  35396. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35397. */
  35398. /**
  35399. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35400. */
  35401. directionalConeInnerAngle: number;
  35402. /**
  35403. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35404. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35405. */
  35406. /**
  35407. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35408. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35409. */
  35410. directionalConeOuterAngle: number;
  35411. /**
  35412. * Playback volume.
  35413. */
  35414. /**
  35415. * Playback volume.
  35416. */
  35417. volume: number;
  35418. private _onended;
  35419. /**
  35420. * Suspend playback
  35421. */
  35422. pause(): void;
  35423. /**
  35424. * Stop playback
  35425. */
  35426. stop(): void;
  35427. /**
  35428. * Start playback.
  35429. * @param startOffset Position the clip head at a specific time in seconds.
  35430. */
  35431. play(startOffset?: number): void;
  35432. }
  35433. }
  35434. declare module "babylonjs/Audio/index" {
  35435. export * from "babylonjs/Audio/analyser";
  35436. export * from "babylonjs/Audio/audioEngine";
  35437. export * from "babylonjs/Audio/audioSceneComponent";
  35438. export * from "babylonjs/Audio/sound";
  35439. export * from "babylonjs/Audio/soundTrack";
  35440. export * from "babylonjs/Audio/weightedsound";
  35441. }
  35442. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35443. import { Behavior } from "babylonjs/Behaviors/behavior";
  35444. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35445. import { BackEase } from "babylonjs/Animations/easing";
  35446. /**
  35447. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35448. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35449. */
  35450. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35451. /**
  35452. * Gets the name of the behavior.
  35453. */
  35454. readonly name: string;
  35455. /**
  35456. * The easing function used by animations
  35457. */
  35458. static EasingFunction: BackEase;
  35459. /**
  35460. * The easing mode used by animations
  35461. */
  35462. static EasingMode: number;
  35463. /**
  35464. * The duration of the animation, in milliseconds
  35465. */
  35466. transitionDuration: number;
  35467. /**
  35468. * Length of the distance animated by the transition when lower radius is reached
  35469. */
  35470. lowerRadiusTransitionRange: number;
  35471. /**
  35472. * Length of the distance animated by the transition when upper radius is reached
  35473. */
  35474. upperRadiusTransitionRange: number;
  35475. private _autoTransitionRange;
  35476. /**
  35477. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35478. */
  35479. /**
  35480. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35481. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35482. */
  35483. autoTransitionRange: boolean;
  35484. private _attachedCamera;
  35485. private _onAfterCheckInputsObserver;
  35486. private _onMeshTargetChangedObserver;
  35487. /**
  35488. * Initializes the behavior.
  35489. */
  35490. init(): void;
  35491. /**
  35492. * Attaches the behavior to its arc rotate camera.
  35493. * @param camera Defines the camera to attach the behavior to
  35494. */
  35495. attach(camera: ArcRotateCamera): void;
  35496. /**
  35497. * Detaches the behavior from its current arc rotate camera.
  35498. */
  35499. detach(): void;
  35500. private _radiusIsAnimating;
  35501. private _radiusBounceTransition;
  35502. private _animatables;
  35503. private _cachedWheelPrecision;
  35504. /**
  35505. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35506. * @param radiusLimit The limit to check against.
  35507. * @return Bool to indicate if at limit.
  35508. */
  35509. private _isRadiusAtLimit;
  35510. /**
  35511. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35512. * @param radiusDelta The delta by which to animate to. Can be negative.
  35513. */
  35514. private _applyBoundRadiusAnimation;
  35515. /**
  35516. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35517. */
  35518. protected _clearAnimationLocks(): void;
  35519. /**
  35520. * Stops and removes all animations that have been applied to the camera
  35521. */
  35522. stopAllAnimations(): void;
  35523. }
  35524. }
  35525. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35526. import { Behavior } from "babylonjs/Behaviors/behavior";
  35527. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35528. import { ExponentialEase } from "babylonjs/Animations/easing";
  35529. import { Nullable } from "babylonjs/types";
  35530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35531. import { Vector3 } from "babylonjs/Maths/math";
  35532. /**
  35533. * 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.
  35534. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35535. */
  35536. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35537. /**
  35538. * Gets the name of the behavior.
  35539. */
  35540. readonly name: string;
  35541. private _mode;
  35542. private _radiusScale;
  35543. private _positionScale;
  35544. private _defaultElevation;
  35545. private _elevationReturnTime;
  35546. private _elevationReturnWaitTime;
  35547. private _zoomStopsAnimation;
  35548. private _framingTime;
  35549. /**
  35550. * The easing function used by animations
  35551. */
  35552. static EasingFunction: ExponentialEase;
  35553. /**
  35554. * The easing mode used by animations
  35555. */
  35556. static EasingMode: number;
  35557. /**
  35558. * Sets the current mode used by the behavior
  35559. */
  35560. /**
  35561. * Gets current mode used by the behavior.
  35562. */
  35563. mode: number;
  35564. /**
  35565. * Sets the scale applied to the radius (1 by default)
  35566. */
  35567. /**
  35568. * Gets the scale applied to the radius
  35569. */
  35570. radiusScale: number;
  35571. /**
  35572. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35573. */
  35574. /**
  35575. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35576. */
  35577. positionScale: number;
  35578. /**
  35579. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35580. * behaviour is triggered, in radians.
  35581. */
  35582. /**
  35583. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35584. * behaviour is triggered, in radians.
  35585. */
  35586. defaultElevation: number;
  35587. /**
  35588. * Sets the time (in milliseconds) taken to return to the default beta position.
  35589. * Negative value indicates camera should not return to default.
  35590. */
  35591. /**
  35592. * Gets the time (in milliseconds) taken to return to the default beta position.
  35593. * Negative value indicates camera should not return to default.
  35594. */
  35595. elevationReturnTime: number;
  35596. /**
  35597. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35598. */
  35599. /**
  35600. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35601. */
  35602. elevationReturnWaitTime: number;
  35603. /**
  35604. * Sets the flag that indicates if user zooming should stop animation.
  35605. */
  35606. /**
  35607. * Gets the flag that indicates if user zooming should stop animation.
  35608. */
  35609. zoomStopsAnimation: boolean;
  35610. /**
  35611. * Sets the transition time when framing the mesh, in milliseconds
  35612. */
  35613. /**
  35614. * Gets the transition time when framing the mesh, in milliseconds
  35615. */
  35616. framingTime: number;
  35617. /**
  35618. * Define if the behavior should automatically change the configured
  35619. * camera limits and sensibilities.
  35620. */
  35621. autoCorrectCameraLimitsAndSensibility: boolean;
  35622. private _onPrePointerObservableObserver;
  35623. private _onAfterCheckInputsObserver;
  35624. private _onMeshTargetChangedObserver;
  35625. private _attachedCamera;
  35626. private _isPointerDown;
  35627. private _lastInteractionTime;
  35628. /**
  35629. * Initializes the behavior.
  35630. */
  35631. init(): void;
  35632. /**
  35633. * Attaches the behavior to its arc rotate camera.
  35634. * @param camera Defines the camera to attach the behavior to
  35635. */
  35636. attach(camera: ArcRotateCamera): void;
  35637. /**
  35638. * Detaches the behavior from its current arc rotate camera.
  35639. */
  35640. detach(): void;
  35641. private _animatables;
  35642. private _betaIsAnimating;
  35643. private _betaTransition;
  35644. private _radiusTransition;
  35645. private _vectorTransition;
  35646. /**
  35647. * Targets the given mesh and updates zoom level accordingly.
  35648. * @param mesh The mesh to target.
  35649. * @param radius Optional. If a cached radius position already exists, overrides default.
  35650. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35651. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35652. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35653. */
  35654. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35655. /**
  35656. * Targets the given mesh with its children and updates zoom level accordingly.
  35657. * @param mesh The mesh to target.
  35658. * @param radius Optional. If a cached radius position already exists, overrides default.
  35659. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35660. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35661. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35662. */
  35663. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35664. /**
  35665. * Targets the given meshes with their children and updates zoom level accordingly.
  35666. * @param meshes The mesh to target.
  35667. * @param radius Optional. If a cached radius position already exists, overrides default.
  35668. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35669. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35670. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35671. */
  35672. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35673. /**
  35674. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35675. * @param minimumWorld Determines the smaller position of the bounding box extend
  35676. * @param maximumWorld Determines the bigger position of the bounding box extend
  35677. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35678. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35679. */
  35680. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35681. /**
  35682. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35683. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35684. * frustum width.
  35685. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35686. * to fully enclose the mesh in the viewing frustum.
  35687. */
  35688. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35689. /**
  35690. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35691. * is automatically returned to its default position (expected to be above ground plane).
  35692. */
  35693. private _maintainCameraAboveGround;
  35694. /**
  35695. * Returns the frustum slope based on the canvas ratio and camera FOV
  35696. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35697. */
  35698. private _getFrustumSlope;
  35699. /**
  35700. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35701. */
  35702. private _clearAnimationLocks;
  35703. /**
  35704. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35705. */
  35706. private _applyUserInteraction;
  35707. /**
  35708. * Stops and removes all animations that have been applied to the camera
  35709. */
  35710. stopAllAnimations(): void;
  35711. /**
  35712. * Gets a value indicating if the user is moving the camera
  35713. */
  35714. readonly isUserIsMoving: boolean;
  35715. /**
  35716. * The camera can move all the way towards the mesh.
  35717. */
  35718. static IgnoreBoundsSizeMode: number;
  35719. /**
  35720. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35721. */
  35722. static FitFrustumSidesMode: number;
  35723. }
  35724. }
  35725. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35726. import { Nullable } from "babylonjs/types";
  35727. import { Camera } from "babylonjs/Cameras/camera";
  35728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35729. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35730. /**
  35731. * Base class for Camera Pointer Inputs.
  35732. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35733. * for example usage.
  35734. */
  35735. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35736. /**
  35737. * Defines the camera the input is attached to.
  35738. */
  35739. abstract camera: Camera;
  35740. /**
  35741. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35742. */
  35743. protected _altKey: boolean;
  35744. protected _ctrlKey: boolean;
  35745. protected _metaKey: boolean;
  35746. protected _shiftKey: boolean;
  35747. /**
  35748. * Which mouse buttons were pressed at time of last mouse event.
  35749. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35750. */
  35751. protected _buttonsPressed: number;
  35752. /**
  35753. * Defines the buttons associated with the input to handle camera move.
  35754. */
  35755. buttons: number[];
  35756. /**
  35757. * Attach the input controls to a specific dom element to get the input from.
  35758. * @param element Defines the element the controls should be listened from
  35759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35760. */
  35761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35762. /**
  35763. * Detach the current controls from the specified dom element.
  35764. * @param element Defines the element to stop listening the inputs from
  35765. */
  35766. detachControl(element: Nullable<HTMLElement>): void;
  35767. /**
  35768. * Gets the class name of the current input.
  35769. * @returns the class name
  35770. */
  35771. getClassName(): string;
  35772. /**
  35773. * Get the friendly name associated with the input class.
  35774. * @returns the input friendly name
  35775. */
  35776. getSimpleName(): string;
  35777. /**
  35778. * Called on pointer POINTERDOUBLETAP event.
  35779. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35780. */
  35781. protected onDoubleTap(type: string): void;
  35782. /**
  35783. * Called on pointer POINTERMOVE event if only a single touch is active.
  35784. * Override this method to provide functionality.
  35785. */
  35786. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35787. /**
  35788. * Called on pointer POINTERMOVE event if multiple touches are active.
  35789. * Override this method to provide functionality.
  35790. */
  35791. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35792. /**
  35793. * Called on JS contextmenu event.
  35794. * Override this method to provide functionality.
  35795. */
  35796. protected onContextMenu(evt: PointerEvent): void;
  35797. /**
  35798. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35799. * press.
  35800. * Override this method to provide functionality.
  35801. */
  35802. protected onButtonDown(evt: PointerEvent): void;
  35803. /**
  35804. * Called each time a new POINTERUP event occurs. Ie, for each button
  35805. * release.
  35806. * Override this method to provide functionality.
  35807. */
  35808. protected onButtonUp(evt: PointerEvent): void;
  35809. /**
  35810. * Called when window becomes inactive.
  35811. * Override this method to provide functionality.
  35812. */
  35813. protected onLostFocus(): void;
  35814. private _pointerInput;
  35815. private _observer;
  35816. private _onLostFocus;
  35817. private pointA;
  35818. private pointB;
  35819. }
  35820. }
  35821. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35822. import { Nullable } from "babylonjs/types";
  35823. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35824. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35825. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35826. /**
  35827. * Manage the pointers inputs to control an arc rotate camera.
  35828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35829. */
  35830. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35831. /**
  35832. * Defines the camera the input is attached to.
  35833. */
  35834. camera: ArcRotateCamera;
  35835. /**
  35836. * Gets the class name of the current input.
  35837. * @returns the class name
  35838. */
  35839. getClassName(): string;
  35840. /**
  35841. * Defines the buttons associated with the input to handle camera move.
  35842. */
  35843. buttons: number[];
  35844. /**
  35845. * Defines the pointer angular sensibility along the X axis or how fast is
  35846. * the camera rotating.
  35847. */
  35848. angularSensibilityX: number;
  35849. /**
  35850. * Defines the pointer angular sensibility along the Y axis or how fast is
  35851. * the camera rotating.
  35852. */
  35853. angularSensibilityY: number;
  35854. /**
  35855. * Defines the pointer pinch precision or how fast is the camera zooming.
  35856. */
  35857. pinchPrecision: number;
  35858. /**
  35859. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35860. * from 0.
  35861. * It defines the percentage of current camera.radius to use as delta when
  35862. * pinch zoom is used.
  35863. */
  35864. pinchDeltaPercentage: number;
  35865. /**
  35866. * Defines the pointer panning sensibility or how fast is the camera moving.
  35867. */
  35868. panningSensibility: number;
  35869. /**
  35870. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35871. */
  35872. multiTouchPanning: boolean;
  35873. /**
  35874. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35875. * zoom (pinch) through multitouch.
  35876. */
  35877. multiTouchPanAndZoom: boolean;
  35878. /**
  35879. * Revers pinch action direction.
  35880. */
  35881. pinchInwards: boolean;
  35882. private _isPanClick;
  35883. private _twoFingerActivityCount;
  35884. private _isPinching;
  35885. /**
  35886. * Called on pointer POINTERMOVE event if only a single touch is active.
  35887. */
  35888. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35889. /**
  35890. * Called on pointer POINTERDOUBLETAP event.
  35891. */
  35892. protected onDoubleTap(type: string): void;
  35893. /**
  35894. * Called on pointer POINTERMOVE event if multiple touches are active.
  35895. */
  35896. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35897. /**
  35898. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35899. * press.
  35900. */
  35901. protected onButtonDown(evt: PointerEvent): void;
  35902. /**
  35903. * Called each time a new POINTERUP event occurs. Ie, for each button
  35904. * release.
  35905. */
  35906. protected onButtonUp(evt: PointerEvent): void;
  35907. /**
  35908. * Called when window becomes inactive.
  35909. */
  35910. protected onLostFocus(): void;
  35911. }
  35912. }
  35913. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35914. import { Nullable } from "babylonjs/types";
  35915. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35916. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35917. /**
  35918. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35920. */
  35921. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35922. /**
  35923. * Defines the camera the input is attached to.
  35924. */
  35925. camera: ArcRotateCamera;
  35926. /**
  35927. * Defines the list of key codes associated with the up action (increase alpha)
  35928. */
  35929. keysUp: number[];
  35930. /**
  35931. * Defines the list of key codes associated with the down action (decrease alpha)
  35932. */
  35933. keysDown: number[];
  35934. /**
  35935. * Defines the list of key codes associated with the left action (increase beta)
  35936. */
  35937. keysLeft: number[];
  35938. /**
  35939. * Defines the list of key codes associated with the right action (decrease beta)
  35940. */
  35941. keysRight: number[];
  35942. /**
  35943. * Defines the list of key codes associated with the reset action.
  35944. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35945. */
  35946. keysReset: number[];
  35947. /**
  35948. * Defines the panning sensibility of the inputs.
  35949. * (How fast is the camera paning)
  35950. */
  35951. panningSensibility: number;
  35952. /**
  35953. * Defines the zooming sensibility of the inputs.
  35954. * (How fast is the camera zooming)
  35955. */
  35956. zoomingSensibility: number;
  35957. /**
  35958. * Defines wether maintaining the alt key down switch the movement mode from
  35959. * orientation to zoom.
  35960. */
  35961. useAltToZoom: boolean;
  35962. /**
  35963. * Rotation speed of the camera
  35964. */
  35965. angularSpeed: number;
  35966. private _keys;
  35967. private _ctrlPressed;
  35968. private _altPressed;
  35969. private _onCanvasBlurObserver;
  35970. private _onKeyboardObserver;
  35971. private _engine;
  35972. private _scene;
  35973. /**
  35974. * Attach the input controls to a specific dom element to get the input from.
  35975. * @param element Defines the element the controls should be listened from
  35976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35977. */
  35978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35979. /**
  35980. * Detach the current controls from the specified dom element.
  35981. * @param element Defines the element to stop listening the inputs from
  35982. */
  35983. detachControl(element: Nullable<HTMLElement>): void;
  35984. /**
  35985. * Update the current camera state depending on the inputs that have been used this frame.
  35986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35987. */
  35988. checkInputs(): void;
  35989. /**
  35990. * Gets the class name of the current intput.
  35991. * @returns the class name
  35992. */
  35993. getClassName(): string;
  35994. /**
  35995. * Get the friendly name associated with the input class.
  35996. * @returns the input friendly name
  35997. */
  35998. getSimpleName(): string;
  35999. }
  36000. }
  36001. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36002. import { Nullable } from "babylonjs/types";
  36003. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36004. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36005. /**
  36006. * Manage the mouse wheel inputs to control an arc rotate camera.
  36007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36008. */
  36009. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36010. /**
  36011. * Defines the camera the input is attached to.
  36012. */
  36013. camera: ArcRotateCamera;
  36014. /**
  36015. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36016. */
  36017. wheelPrecision: number;
  36018. /**
  36019. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36020. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36021. */
  36022. wheelDeltaPercentage: number;
  36023. private _wheel;
  36024. private _observer;
  36025. private computeDeltaFromMouseWheelLegacyEvent;
  36026. /**
  36027. * Attach the input controls to a specific dom element to get the input from.
  36028. * @param element Defines the element the controls should be listened from
  36029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36030. */
  36031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36032. /**
  36033. * Detach the current controls from the specified dom element.
  36034. * @param element Defines the element to stop listening the inputs from
  36035. */
  36036. detachControl(element: Nullable<HTMLElement>): void;
  36037. /**
  36038. * Gets the class name of the current intput.
  36039. * @returns the class name
  36040. */
  36041. getClassName(): string;
  36042. /**
  36043. * Get the friendly name associated with the input class.
  36044. * @returns the input friendly name
  36045. */
  36046. getSimpleName(): string;
  36047. }
  36048. }
  36049. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36050. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36051. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36052. /**
  36053. * Default Inputs manager for the ArcRotateCamera.
  36054. * It groups all the default supported inputs for ease of use.
  36055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36056. */
  36057. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36058. /**
  36059. * Instantiates a new ArcRotateCameraInputsManager.
  36060. * @param camera Defines the camera the inputs belong to
  36061. */
  36062. constructor(camera: ArcRotateCamera);
  36063. /**
  36064. * Add mouse wheel input support to the input manager.
  36065. * @returns the current input manager
  36066. */
  36067. addMouseWheel(): ArcRotateCameraInputsManager;
  36068. /**
  36069. * Add pointers input support to the input manager.
  36070. * @returns the current input manager
  36071. */
  36072. addPointers(): ArcRotateCameraInputsManager;
  36073. /**
  36074. * Add keyboard input support to the input manager.
  36075. * @returns the current input manager
  36076. */
  36077. addKeyboard(): ArcRotateCameraInputsManager;
  36078. }
  36079. }
  36080. declare module "babylonjs/Cameras/arcRotateCamera" {
  36081. import { Observable } from "babylonjs/Misc/observable";
  36082. import { Nullable } from "babylonjs/types";
  36083. import { Scene } from "babylonjs/scene";
  36084. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36086. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36087. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36088. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36089. import { Camera } from "babylonjs/Cameras/camera";
  36090. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36091. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36092. import { Collider } from "babylonjs/Collisions/collider";
  36093. /**
  36094. * This represents an orbital type of camera.
  36095. *
  36096. * 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.
  36097. * 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.
  36098. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36099. */
  36100. export class ArcRotateCamera extends TargetCamera {
  36101. /**
  36102. * Defines the rotation angle of the camera along the longitudinal axis.
  36103. */
  36104. alpha: number;
  36105. /**
  36106. * Defines the rotation angle of the camera along the latitudinal axis.
  36107. */
  36108. beta: number;
  36109. /**
  36110. * Defines the radius of the camera from it s target point.
  36111. */
  36112. radius: number;
  36113. protected _target: Vector3;
  36114. protected _targetHost: Nullable<AbstractMesh>;
  36115. /**
  36116. * Defines the target point of the camera.
  36117. * The camera looks towards it form the radius distance.
  36118. */
  36119. target: Vector3;
  36120. /**
  36121. * Define the current local position of the camera in the scene
  36122. */
  36123. position: Vector3;
  36124. protected _upVector: Vector3;
  36125. protected _upToYMatrix: Matrix;
  36126. protected _YToUpMatrix: Matrix;
  36127. /**
  36128. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36129. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36130. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36131. */
  36132. upVector: Vector3;
  36133. /**
  36134. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36135. */
  36136. setMatUp(): void;
  36137. /**
  36138. * Current inertia value on the longitudinal axis.
  36139. * The bigger this number the longer it will take for the camera to stop.
  36140. */
  36141. inertialAlphaOffset: number;
  36142. /**
  36143. * Current inertia value on the latitudinal axis.
  36144. * The bigger this number the longer it will take for the camera to stop.
  36145. */
  36146. inertialBetaOffset: number;
  36147. /**
  36148. * Current inertia value on the radius axis.
  36149. * The bigger this number the longer it will take for the camera to stop.
  36150. */
  36151. inertialRadiusOffset: number;
  36152. /**
  36153. * Minimum allowed angle on the longitudinal axis.
  36154. * This can help limiting how the Camera is able to move in the scene.
  36155. */
  36156. lowerAlphaLimit: Nullable<number>;
  36157. /**
  36158. * Maximum allowed angle on the longitudinal axis.
  36159. * This can help limiting how the Camera is able to move in the scene.
  36160. */
  36161. upperAlphaLimit: Nullable<number>;
  36162. /**
  36163. * Minimum allowed angle on the latitudinal axis.
  36164. * This can help limiting how the Camera is able to move in the scene.
  36165. */
  36166. lowerBetaLimit: number;
  36167. /**
  36168. * Maximum allowed angle on the latitudinal axis.
  36169. * This can help limiting how the Camera is able to move in the scene.
  36170. */
  36171. upperBetaLimit: number;
  36172. /**
  36173. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36174. * This can help limiting how the Camera is able to move in the scene.
  36175. */
  36176. lowerRadiusLimit: Nullable<number>;
  36177. /**
  36178. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36179. * This can help limiting how the Camera is able to move in the scene.
  36180. */
  36181. upperRadiusLimit: Nullable<number>;
  36182. /**
  36183. * Defines the current inertia value used during panning of the camera along the X axis.
  36184. */
  36185. inertialPanningX: number;
  36186. /**
  36187. * Defines the current inertia value used during panning of the camera along the Y axis.
  36188. */
  36189. inertialPanningY: number;
  36190. /**
  36191. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36192. * Basically if your fingers moves away from more than this distance you will be considered
  36193. * in pinch mode.
  36194. */
  36195. pinchToPanMaxDistance: number;
  36196. /**
  36197. * Defines the maximum distance the camera can pan.
  36198. * This could help keeping the cammera always in your scene.
  36199. */
  36200. panningDistanceLimit: Nullable<number>;
  36201. /**
  36202. * Defines the target of the camera before paning.
  36203. */
  36204. panningOriginTarget: Vector3;
  36205. /**
  36206. * Defines the value of the inertia used during panning.
  36207. * 0 would mean stop inertia and one would mean no decelleration at all.
  36208. */
  36209. panningInertia: number;
  36210. /**
  36211. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36212. */
  36213. angularSensibilityX: number;
  36214. /**
  36215. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36216. */
  36217. angularSensibilityY: number;
  36218. /**
  36219. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36220. */
  36221. pinchPrecision: number;
  36222. /**
  36223. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36224. * It will be used instead of pinchDeltaPrecision if different from 0.
  36225. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36226. */
  36227. pinchDeltaPercentage: number;
  36228. /**
  36229. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36230. */
  36231. panningSensibility: number;
  36232. /**
  36233. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36234. */
  36235. keysUp: number[];
  36236. /**
  36237. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36238. */
  36239. keysDown: number[];
  36240. /**
  36241. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36242. */
  36243. keysLeft: number[];
  36244. /**
  36245. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36246. */
  36247. keysRight: number[];
  36248. /**
  36249. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36250. */
  36251. wheelPrecision: number;
  36252. /**
  36253. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36254. * It will be used instead of pinchDeltaPrecision if different from 0.
  36255. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36256. */
  36257. wheelDeltaPercentage: number;
  36258. /**
  36259. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36260. */
  36261. zoomOnFactor: number;
  36262. /**
  36263. * Defines a screen offset for the camera position.
  36264. */
  36265. targetScreenOffset: Vector2;
  36266. /**
  36267. * Allows the camera to be completely reversed.
  36268. * If false the camera can not arrive upside down.
  36269. */
  36270. allowUpsideDown: boolean;
  36271. /**
  36272. * Define if double tap/click is used to restore the previously saved state of the camera.
  36273. */
  36274. useInputToRestoreState: boolean;
  36275. /** @hidden */
  36276. _viewMatrix: Matrix;
  36277. /** @hidden */
  36278. _useCtrlForPanning: boolean;
  36279. /** @hidden */
  36280. _panningMouseButton: number;
  36281. /**
  36282. * Defines the input associated to the camera.
  36283. */
  36284. inputs: ArcRotateCameraInputsManager;
  36285. /** @hidden */
  36286. _reset: () => void;
  36287. /**
  36288. * Defines the allowed panning axis.
  36289. */
  36290. panningAxis: Vector3;
  36291. protected _localDirection: Vector3;
  36292. protected _transformedDirection: Vector3;
  36293. private _bouncingBehavior;
  36294. /**
  36295. * Gets the bouncing behavior of the camera if it has been enabled.
  36296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36297. */
  36298. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36299. /**
  36300. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36302. */
  36303. useBouncingBehavior: boolean;
  36304. private _framingBehavior;
  36305. /**
  36306. * Gets the framing behavior of the camera if it has been enabled.
  36307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36308. */
  36309. readonly framingBehavior: Nullable<FramingBehavior>;
  36310. /**
  36311. * Defines if the framing behavior of the camera is enabled on the camera.
  36312. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36313. */
  36314. useFramingBehavior: boolean;
  36315. private _autoRotationBehavior;
  36316. /**
  36317. * Gets the auto rotation behavior of the camera if it has been enabled.
  36318. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36319. */
  36320. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36321. /**
  36322. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36323. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36324. */
  36325. useAutoRotationBehavior: boolean;
  36326. /**
  36327. * Observable triggered when the mesh target has been changed on the camera.
  36328. */
  36329. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36330. /**
  36331. * Event raised when the camera is colliding with a mesh.
  36332. */
  36333. onCollide: (collidedMesh: AbstractMesh) => void;
  36334. /**
  36335. * Defines whether the camera should check collision with the objects oh the scene.
  36336. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36337. */
  36338. checkCollisions: boolean;
  36339. /**
  36340. * Defines the collision radius of the camera.
  36341. * This simulates a sphere around the camera.
  36342. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36343. */
  36344. collisionRadius: Vector3;
  36345. protected _collider: Collider;
  36346. protected _previousPosition: Vector3;
  36347. protected _collisionVelocity: Vector3;
  36348. protected _newPosition: Vector3;
  36349. protected _previousAlpha: number;
  36350. protected _previousBeta: number;
  36351. protected _previousRadius: number;
  36352. protected _collisionTriggered: boolean;
  36353. protected _targetBoundingCenter: Nullable<Vector3>;
  36354. private _computationVector;
  36355. /**
  36356. * Instantiates a new ArcRotateCamera in a given scene
  36357. * @param name Defines the name of the camera
  36358. * @param alpha Defines the camera rotation along the logitudinal axis
  36359. * @param beta Defines the camera rotation along the latitudinal axis
  36360. * @param radius Defines the camera distance from its target
  36361. * @param target Defines the camera target
  36362. * @param scene Defines the scene the camera belongs to
  36363. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36364. */
  36365. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36366. /** @hidden */
  36367. _initCache(): void;
  36368. /** @hidden */
  36369. _updateCache(ignoreParentClass?: boolean): void;
  36370. protected _getTargetPosition(): Vector3;
  36371. private _storedAlpha;
  36372. private _storedBeta;
  36373. private _storedRadius;
  36374. private _storedTarget;
  36375. /**
  36376. * Stores the current state of the camera (alpha, beta, radius and target)
  36377. * @returns the camera itself
  36378. */
  36379. storeState(): Camera;
  36380. /**
  36381. * @hidden
  36382. * Restored camera state. You must call storeState() first
  36383. */
  36384. _restoreStateValues(): boolean;
  36385. /** @hidden */
  36386. _isSynchronizedViewMatrix(): boolean;
  36387. /**
  36388. * Attached controls to the current camera.
  36389. * @param element Defines the element the controls should be listened from
  36390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36391. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36392. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36393. */
  36394. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36395. /**
  36396. * Detach the current controls from the camera.
  36397. * The camera will stop reacting to inputs.
  36398. * @param element Defines the element to stop listening the inputs from
  36399. */
  36400. detachControl(element: HTMLElement): void;
  36401. /** @hidden */
  36402. _checkInputs(): void;
  36403. protected _checkLimits(): void;
  36404. /**
  36405. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36406. */
  36407. rebuildAnglesAndRadius(): void;
  36408. /**
  36409. * Use a position to define the current camera related information like aplha, beta and radius
  36410. * @param position Defines the position to set the camera at
  36411. */
  36412. setPosition(position: Vector3): void;
  36413. /**
  36414. * Defines the target the camera should look at.
  36415. * This will automatically adapt alpha beta and radius to fit within the new target.
  36416. * @param target Defines the new target as a Vector or a mesh
  36417. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36418. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36419. */
  36420. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36421. /** @hidden */
  36422. _getViewMatrix(): Matrix;
  36423. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36424. /**
  36425. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36426. * @param meshes Defines the mesh to zoom on
  36427. * @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)
  36428. */
  36429. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36430. /**
  36431. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36432. * The target will be changed but the radius
  36433. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36434. * @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)
  36435. */
  36436. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36437. min: Vector3;
  36438. max: Vector3;
  36439. distance: number;
  36440. }, doNotUpdateMaxZ?: boolean): void;
  36441. /**
  36442. * @override
  36443. * Override Camera.createRigCamera
  36444. */
  36445. createRigCamera(name: string, cameraIndex: number): Camera;
  36446. /**
  36447. * @hidden
  36448. * @override
  36449. * Override Camera._updateRigCameras
  36450. */
  36451. _updateRigCameras(): void;
  36452. /**
  36453. * Destroy the camera and release the current resources hold by it.
  36454. */
  36455. dispose(): void;
  36456. /**
  36457. * Gets the current object class name.
  36458. * @return the class name
  36459. */
  36460. getClassName(): string;
  36461. }
  36462. }
  36463. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36464. import { Behavior } from "babylonjs/Behaviors/behavior";
  36465. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36466. /**
  36467. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36468. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36469. */
  36470. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36471. /**
  36472. * Gets the name of the behavior.
  36473. */
  36474. readonly name: string;
  36475. private _zoomStopsAnimation;
  36476. private _idleRotationSpeed;
  36477. private _idleRotationWaitTime;
  36478. private _idleRotationSpinupTime;
  36479. /**
  36480. * Sets the flag that indicates if user zooming should stop animation.
  36481. */
  36482. /**
  36483. * Gets the flag that indicates if user zooming should stop animation.
  36484. */
  36485. zoomStopsAnimation: boolean;
  36486. /**
  36487. * Sets the default speed at which the camera rotates around the model.
  36488. */
  36489. /**
  36490. * Gets the default speed at which the camera rotates around the model.
  36491. */
  36492. idleRotationSpeed: number;
  36493. /**
  36494. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36495. */
  36496. /**
  36497. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36498. */
  36499. idleRotationWaitTime: number;
  36500. /**
  36501. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36502. */
  36503. /**
  36504. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36505. */
  36506. idleRotationSpinupTime: number;
  36507. /**
  36508. * Gets a value indicating if the camera is currently rotating because of this behavior
  36509. */
  36510. readonly rotationInProgress: boolean;
  36511. private _onPrePointerObservableObserver;
  36512. private _onAfterCheckInputsObserver;
  36513. private _attachedCamera;
  36514. private _isPointerDown;
  36515. private _lastFrameTime;
  36516. private _lastInteractionTime;
  36517. private _cameraRotationSpeed;
  36518. /**
  36519. * Initializes the behavior.
  36520. */
  36521. init(): void;
  36522. /**
  36523. * Attaches the behavior to its arc rotate camera.
  36524. * @param camera Defines the camera to attach the behavior to
  36525. */
  36526. attach(camera: ArcRotateCamera): void;
  36527. /**
  36528. * Detaches the behavior from its current arc rotate camera.
  36529. */
  36530. detach(): void;
  36531. /**
  36532. * Returns true if user is scrolling.
  36533. * @return true if user is scrolling.
  36534. */
  36535. private _userIsZooming;
  36536. private _lastFrameRadius;
  36537. private _shouldAnimationStopForInteraction;
  36538. /**
  36539. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36540. */
  36541. private _applyUserInteraction;
  36542. private _userIsMoving;
  36543. }
  36544. }
  36545. declare module "babylonjs/Behaviors/Cameras/index" {
  36546. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36547. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36548. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36549. }
  36550. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36551. import { Mesh } from "babylonjs/Meshes/mesh";
  36552. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36553. import { Behavior } from "babylonjs/Behaviors/behavior";
  36554. /**
  36555. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36556. */
  36557. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36558. private ui;
  36559. /**
  36560. * The name of the behavior
  36561. */
  36562. name: string;
  36563. /**
  36564. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36565. */
  36566. distanceAwayFromFace: number;
  36567. /**
  36568. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36569. */
  36570. distanceAwayFromBottomOfFace: number;
  36571. private _faceVectors;
  36572. private _target;
  36573. private _scene;
  36574. private _onRenderObserver;
  36575. private _tmpMatrix;
  36576. private _tmpVector;
  36577. /**
  36578. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36579. * @param ui The transform node that should be attched to the mesh
  36580. */
  36581. constructor(ui: TransformNode);
  36582. /**
  36583. * Initializes the behavior
  36584. */
  36585. init(): void;
  36586. private _closestFace;
  36587. private _zeroVector;
  36588. private _lookAtTmpMatrix;
  36589. private _lookAtToRef;
  36590. /**
  36591. * Attaches the AttachToBoxBehavior to the passed in mesh
  36592. * @param target The mesh that the specified node will be attached to
  36593. */
  36594. attach(target: Mesh): void;
  36595. /**
  36596. * Detaches the behavior from the mesh
  36597. */
  36598. detach(): void;
  36599. }
  36600. }
  36601. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36602. import { Behavior } from "babylonjs/Behaviors/behavior";
  36603. import { Mesh } from "babylonjs/Meshes/mesh";
  36604. /**
  36605. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36606. */
  36607. export class FadeInOutBehavior implements Behavior<Mesh> {
  36608. /**
  36609. * Time in milliseconds to delay before fading in (Default: 0)
  36610. */
  36611. delay: number;
  36612. /**
  36613. * Time in milliseconds for the mesh to fade in (Default: 300)
  36614. */
  36615. fadeInTime: number;
  36616. private _millisecondsPerFrame;
  36617. private _hovered;
  36618. private _hoverValue;
  36619. private _ownerNode;
  36620. /**
  36621. * Instatiates the FadeInOutBehavior
  36622. */
  36623. constructor();
  36624. /**
  36625. * The name of the behavior
  36626. */
  36627. readonly name: string;
  36628. /**
  36629. * Initializes the behavior
  36630. */
  36631. init(): void;
  36632. /**
  36633. * Attaches the fade behavior on the passed in mesh
  36634. * @param ownerNode The mesh that will be faded in/out once attached
  36635. */
  36636. attach(ownerNode: Mesh): void;
  36637. /**
  36638. * Detaches the behavior from the mesh
  36639. */
  36640. detach(): void;
  36641. /**
  36642. * Triggers the mesh to begin fading in or out
  36643. * @param value if the object should fade in or out (true to fade in)
  36644. */
  36645. fadeIn(value: boolean): void;
  36646. private _update;
  36647. private _setAllVisibility;
  36648. }
  36649. }
  36650. declare module "babylonjs/Misc/pivotTools" {
  36651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36652. /**
  36653. * Class containing a set of static utilities functions for managing Pivots
  36654. * @hidden
  36655. */
  36656. export class PivotTools {
  36657. private static _PivotCached;
  36658. private static _OldPivotPoint;
  36659. private static _PivotTranslation;
  36660. private static _PivotTmpVector;
  36661. /** @hidden */
  36662. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36663. /** @hidden */
  36664. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36665. }
  36666. }
  36667. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36668. import { Scene } from "babylonjs/scene";
  36669. import { Vector4, Plane } from "babylonjs/Maths/math";
  36670. import { Mesh } from "babylonjs/Meshes/mesh";
  36671. import { Nullable } from "babylonjs/types";
  36672. /**
  36673. * Class containing static functions to help procedurally build meshes
  36674. */
  36675. export class PlaneBuilder {
  36676. /**
  36677. * Creates a plane mesh
  36678. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36679. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36680. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36684. * @param name defines the name of the mesh
  36685. * @param options defines the options used to create the mesh
  36686. * @param scene defines the hosting scene
  36687. * @returns the plane mesh
  36688. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36689. */
  36690. static CreatePlane(name: string, options: {
  36691. size?: number;
  36692. width?: number;
  36693. height?: number;
  36694. sideOrientation?: number;
  36695. frontUVs?: Vector4;
  36696. backUVs?: Vector4;
  36697. updatable?: boolean;
  36698. sourcePlane?: Plane;
  36699. }, scene?: Nullable<Scene>): Mesh;
  36700. }
  36701. }
  36702. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36703. import { Behavior } from "babylonjs/Behaviors/behavior";
  36704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36705. import { Observable } from "babylonjs/Misc/observable";
  36706. import { Vector3 } from "babylonjs/Maths/math";
  36707. import { Ray } from "babylonjs/Culling/ray";
  36708. import "babylonjs/Meshes/Builders/planeBuilder";
  36709. /**
  36710. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36711. */
  36712. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36713. private static _AnyMouseID;
  36714. private _attachedNode;
  36715. private _dragPlane;
  36716. private _scene;
  36717. private _pointerObserver;
  36718. private _beforeRenderObserver;
  36719. private static _planeScene;
  36720. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36721. /**
  36722. * 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)
  36723. */
  36724. maxDragAngle: number;
  36725. /**
  36726. * @hidden
  36727. */
  36728. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36729. /**
  36730. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36731. */
  36732. currentDraggingPointerID: number;
  36733. /**
  36734. * The last position where the pointer hit the drag plane in world space
  36735. */
  36736. lastDragPosition: Vector3;
  36737. /**
  36738. * If the behavior is currently in a dragging state
  36739. */
  36740. dragging: boolean;
  36741. /**
  36742. * 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)
  36743. */
  36744. dragDeltaRatio: number;
  36745. /**
  36746. * If the drag plane orientation should be updated during the dragging (Default: true)
  36747. */
  36748. updateDragPlane: boolean;
  36749. private _debugMode;
  36750. private _moving;
  36751. /**
  36752. * Fires each time the attached mesh is dragged with the pointer
  36753. * * delta between last drag position and current drag position in world space
  36754. * * dragDistance along the drag axis
  36755. * * dragPlaneNormal normal of the current drag plane used during the drag
  36756. * * dragPlanePoint in world space where the drag intersects the drag plane
  36757. */
  36758. onDragObservable: Observable<{
  36759. delta: Vector3;
  36760. dragPlanePoint: Vector3;
  36761. dragPlaneNormal: Vector3;
  36762. dragDistance: number;
  36763. pointerId: number;
  36764. }>;
  36765. /**
  36766. * Fires each time a drag begins (eg. mouse down on mesh)
  36767. */
  36768. onDragStartObservable: Observable<{
  36769. dragPlanePoint: Vector3;
  36770. pointerId: number;
  36771. }>;
  36772. /**
  36773. * Fires each time a drag ends (eg. mouse release after drag)
  36774. */
  36775. onDragEndObservable: Observable<{
  36776. dragPlanePoint: Vector3;
  36777. pointerId: number;
  36778. }>;
  36779. /**
  36780. * If the attached mesh should be moved when dragged
  36781. */
  36782. moveAttached: boolean;
  36783. /**
  36784. * If the drag behavior will react to drag events (Default: true)
  36785. */
  36786. enabled: boolean;
  36787. /**
  36788. * If camera controls should be detached during the drag
  36789. */
  36790. detachCameraControls: boolean;
  36791. /**
  36792. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36793. */
  36794. useObjectOrienationForDragging: boolean;
  36795. private _options;
  36796. /**
  36797. * Creates a pointer drag behavior that can be attached to a mesh
  36798. * @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)
  36799. */
  36800. constructor(options?: {
  36801. dragAxis?: Vector3;
  36802. dragPlaneNormal?: Vector3;
  36803. });
  36804. /**
  36805. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36806. */
  36807. validateDrag: (targetPosition: Vector3) => boolean;
  36808. /**
  36809. * The name of the behavior
  36810. */
  36811. readonly name: string;
  36812. /**
  36813. * Initializes the behavior
  36814. */
  36815. init(): void;
  36816. private _tmpVector;
  36817. private _alternatePickedPoint;
  36818. private _worldDragAxis;
  36819. private _targetPosition;
  36820. private _attachedElement;
  36821. /**
  36822. * Attaches the drag behavior the passed in mesh
  36823. * @param ownerNode The mesh that will be dragged around once attached
  36824. */
  36825. attach(ownerNode: AbstractMesh): void;
  36826. /**
  36827. * Force relase the drag action by code.
  36828. */
  36829. releaseDrag(): void;
  36830. private _startDragRay;
  36831. private _lastPointerRay;
  36832. /**
  36833. * Simulates the start of a pointer drag event on the behavior
  36834. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36835. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36836. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36837. */
  36838. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36839. private _startDrag;
  36840. private _dragDelta;
  36841. private _moveDrag;
  36842. private _pickWithRayOnDragPlane;
  36843. private _pointA;
  36844. private _pointB;
  36845. private _pointC;
  36846. private _lineA;
  36847. private _lineB;
  36848. private _localAxis;
  36849. private _lookAt;
  36850. private _updateDragPlanePosition;
  36851. /**
  36852. * Detaches the behavior from the mesh
  36853. */
  36854. detach(): void;
  36855. }
  36856. }
  36857. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36858. import { Mesh } from "babylonjs/Meshes/mesh";
  36859. import { Behavior } from "babylonjs/Behaviors/behavior";
  36860. /**
  36861. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36862. */
  36863. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36864. private _dragBehaviorA;
  36865. private _dragBehaviorB;
  36866. private _startDistance;
  36867. private _initialScale;
  36868. private _targetScale;
  36869. private _ownerNode;
  36870. private _sceneRenderObserver;
  36871. /**
  36872. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36873. */
  36874. constructor();
  36875. /**
  36876. * The name of the behavior
  36877. */
  36878. readonly name: string;
  36879. /**
  36880. * Initializes the behavior
  36881. */
  36882. init(): void;
  36883. private _getCurrentDistance;
  36884. /**
  36885. * Attaches the scale behavior the passed in mesh
  36886. * @param ownerNode The mesh that will be scaled around once attached
  36887. */
  36888. attach(ownerNode: Mesh): void;
  36889. /**
  36890. * Detaches the behavior from the mesh
  36891. */
  36892. detach(): void;
  36893. }
  36894. }
  36895. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36896. import { Behavior } from "babylonjs/Behaviors/behavior";
  36897. import { Mesh } from "babylonjs/Meshes/mesh";
  36898. import { Observable } from "babylonjs/Misc/observable";
  36899. /**
  36900. * 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
  36901. */
  36902. export class SixDofDragBehavior implements Behavior<Mesh> {
  36903. private static _virtualScene;
  36904. private _ownerNode;
  36905. private _sceneRenderObserver;
  36906. private _scene;
  36907. private _targetPosition;
  36908. private _virtualOriginMesh;
  36909. private _virtualDragMesh;
  36910. private _pointerObserver;
  36911. private _moving;
  36912. private _startingOrientation;
  36913. /**
  36914. * 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)
  36915. */
  36916. private zDragFactor;
  36917. /**
  36918. * If the object should rotate to face the drag origin
  36919. */
  36920. rotateDraggedObject: boolean;
  36921. /**
  36922. * If the behavior is currently in a dragging state
  36923. */
  36924. dragging: boolean;
  36925. /**
  36926. * 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)
  36927. */
  36928. dragDeltaRatio: number;
  36929. /**
  36930. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36931. */
  36932. currentDraggingPointerID: number;
  36933. /**
  36934. * If camera controls should be detached during the drag
  36935. */
  36936. detachCameraControls: boolean;
  36937. /**
  36938. * Fires each time a drag starts
  36939. */
  36940. onDragStartObservable: Observable<{}>;
  36941. /**
  36942. * Fires each time a drag ends (eg. mouse release after drag)
  36943. */
  36944. onDragEndObservable: Observable<{}>;
  36945. /**
  36946. * 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
  36947. */
  36948. constructor();
  36949. /**
  36950. * The name of the behavior
  36951. */
  36952. readonly name: string;
  36953. /**
  36954. * Initializes the behavior
  36955. */
  36956. init(): void;
  36957. /**
  36958. * Attaches the scale behavior the passed in mesh
  36959. * @param ownerNode The mesh that will be scaled around once attached
  36960. */
  36961. attach(ownerNode: Mesh): void;
  36962. /**
  36963. * Detaches the behavior from the mesh
  36964. */
  36965. detach(): void;
  36966. }
  36967. }
  36968. declare module "babylonjs/Behaviors/Meshes/index" {
  36969. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36970. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36971. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36972. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36973. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36974. }
  36975. declare module "babylonjs/Behaviors/index" {
  36976. export * from "babylonjs/Behaviors/behavior";
  36977. export * from "babylonjs/Behaviors/Cameras/index";
  36978. export * from "babylonjs/Behaviors/Meshes/index";
  36979. }
  36980. declare module "babylonjs/Bones/boneIKController" {
  36981. import { Bone } from "babylonjs/Bones/bone";
  36982. import { Vector3 } from "babylonjs/Maths/math";
  36983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36984. import { Nullable } from "babylonjs/types";
  36985. /**
  36986. * Class used to apply inverse kinematics to bones
  36987. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36988. */
  36989. export class BoneIKController {
  36990. private static _tmpVecs;
  36991. private static _tmpQuat;
  36992. private static _tmpMats;
  36993. /**
  36994. * Gets or sets the target mesh
  36995. */
  36996. targetMesh: AbstractMesh;
  36997. /** Gets or sets the mesh used as pole */
  36998. poleTargetMesh: AbstractMesh;
  36999. /**
  37000. * Gets or sets the bone used as pole
  37001. */
  37002. poleTargetBone: Nullable<Bone>;
  37003. /**
  37004. * Gets or sets the target position
  37005. */
  37006. targetPosition: Vector3;
  37007. /**
  37008. * Gets or sets the pole target position
  37009. */
  37010. poleTargetPosition: Vector3;
  37011. /**
  37012. * Gets or sets the pole target local offset
  37013. */
  37014. poleTargetLocalOffset: Vector3;
  37015. /**
  37016. * Gets or sets the pole angle
  37017. */
  37018. poleAngle: number;
  37019. /**
  37020. * Gets or sets the mesh associated with the controller
  37021. */
  37022. mesh: AbstractMesh;
  37023. /**
  37024. * 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)
  37025. */
  37026. slerpAmount: number;
  37027. private _bone1Quat;
  37028. private _bone1Mat;
  37029. private _bone2Ang;
  37030. private _bone1;
  37031. private _bone2;
  37032. private _bone1Length;
  37033. private _bone2Length;
  37034. private _maxAngle;
  37035. private _maxReach;
  37036. private _rightHandedSystem;
  37037. private _bendAxis;
  37038. private _slerping;
  37039. private _adjustRoll;
  37040. /**
  37041. * Gets or sets maximum allowed angle
  37042. */
  37043. maxAngle: number;
  37044. /**
  37045. * Creates a new BoneIKController
  37046. * @param mesh defines the mesh to control
  37047. * @param bone defines the bone to control
  37048. * @param options defines options to set up the controller
  37049. */
  37050. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37051. targetMesh?: AbstractMesh;
  37052. poleTargetMesh?: AbstractMesh;
  37053. poleTargetBone?: Bone;
  37054. poleTargetLocalOffset?: Vector3;
  37055. poleAngle?: number;
  37056. bendAxis?: Vector3;
  37057. maxAngle?: number;
  37058. slerpAmount?: number;
  37059. });
  37060. private _setMaxAngle;
  37061. /**
  37062. * Force the controller to update the bones
  37063. */
  37064. update(): void;
  37065. }
  37066. }
  37067. declare module "babylonjs/Bones/boneLookController" {
  37068. import { Vector3, Space } from "babylonjs/Maths/math";
  37069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37070. import { Bone } from "babylonjs/Bones/bone";
  37071. /**
  37072. * Class used to make a bone look toward a point in space
  37073. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37074. */
  37075. export class BoneLookController {
  37076. private static _tmpVecs;
  37077. private static _tmpQuat;
  37078. private static _tmpMats;
  37079. /**
  37080. * The target Vector3 that the bone will look at
  37081. */
  37082. target: Vector3;
  37083. /**
  37084. * The mesh that the bone is attached to
  37085. */
  37086. mesh: AbstractMesh;
  37087. /**
  37088. * The bone that will be looking to the target
  37089. */
  37090. bone: Bone;
  37091. /**
  37092. * The up axis of the coordinate system that is used when the bone is rotated
  37093. */
  37094. upAxis: Vector3;
  37095. /**
  37096. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37097. */
  37098. upAxisSpace: Space;
  37099. /**
  37100. * Used to make an adjustment to the yaw of the bone
  37101. */
  37102. adjustYaw: number;
  37103. /**
  37104. * Used to make an adjustment to the pitch of the bone
  37105. */
  37106. adjustPitch: number;
  37107. /**
  37108. * Used to make an adjustment to the roll of the bone
  37109. */
  37110. adjustRoll: number;
  37111. /**
  37112. * 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)
  37113. */
  37114. slerpAmount: number;
  37115. private _minYaw;
  37116. private _maxYaw;
  37117. private _minPitch;
  37118. private _maxPitch;
  37119. private _minYawSin;
  37120. private _minYawCos;
  37121. private _maxYawSin;
  37122. private _maxYawCos;
  37123. private _midYawConstraint;
  37124. private _minPitchTan;
  37125. private _maxPitchTan;
  37126. private _boneQuat;
  37127. private _slerping;
  37128. private _transformYawPitch;
  37129. private _transformYawPitchInv;
  37130. private _firstFrameSkipped;
  37131. private _yawRange;
  37132. private _fowardAxis;
  37133. /**
  37134. * Gets or sets the minimum yaw angle that the bone can look to
  37135. */
  37136. minYaw: number;
  37137. /**
  37138. * Gets or sets the maximum yaw angle that the bone can look to
  37139. */
  37140. maxYaw: number;
  37141. /**
  37142. * Gets or sets the minimum pitch angle that the bone can look to
  37143. */
  37144. minPitch: number;
  37145. /**
  37146. * Gets or sets the maximum pitch angle that the bone can look to
  37147. */
  37148. maxPitch: number;
  37149. /**
  37150. * Create a BoneLookController
  37151. * @param mesh the mesh that the bone belongs to
  37152. * @param bone the bone that will be looking to the target
  37153. * @param target the target Vector3 to look at
  37154. * @param options optional settings:
  37155. * * maxYaw: the maximum angle the bone will yaw to
  37156. * * minYaw: the minimum angle the bone will yaw to
  37157. * * maxPitch: the maximum angle the bone will pitch to
  37158. * * minPitch: the minimum angle the bone will yaw to
  37159. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37160. * * upAxis: the up axis of the coordinate system
  37161. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37162. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37163. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37164. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37165. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37166. * * adjustRoll: used to make an adjustment to the roll of the bone
  37167. **/
  37168. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37169. maxYaw?: number;
  37170. minYaw?: number;
  37171. maxPitch?: number;
  37172. minPitch?: number;
  37173. slerpAmount?: number;
  37174. upAxis?: Vector3;
  37175. upAxisSpace?: Space;
  37176. yawAxis?: Vector3;
  37177. pitchAxis?: Vector3;
  37178. adjustYaw?: number;
  37179. adjustPitch?: number;
  37180. adjustRoll?: number;
  37181. });
  37182. /**
  37183. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37184. */
  37185. update(): void;
  37186. private _getAngleDiff;
  37187. private _getAngleBetween;
  37188. private _isAngleBetween;
  37189. }
  37190. }
  37191. declare module "babylonjs/Bones/index" {
  37192. export * from "babylonjs/Bones/bone";
  37193. export * from "babylonjs/Bones/boneIKController";
  37194. export * from "babylonjs/Bones/boneLookController";
  37195. export * from "babylonjs/Bones/skeleton";
  37196. }
  37197. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37198. import { Nullable } from "babylonjs/types";
  37199. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37200. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37201. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37202. /**
  37203. * Manage the gamepad inputs to control an arc rotate camera.
  37204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37205. */
  37206. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37207. /**
  37208. * Defines the camera the input is attached to.
  37209. */
  37210. camera: ArcRotateCamera;
  37211. /**
  37212. * Defines the gamepad the input is gathering event from.
  37213. */
  37214. gamepad: Nullable<Gamepad>;
  37215. /**
  37216. * Defines the gamepad rotation sensiblity.
  37217. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37218. */
  37219. gamepadRotationSensibility: number;
  37220. /**
  37221. * Defines the gamepad move sensiblity.
  37222. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37223. */
  37224. gamepadMoveSensibility: number;
  37225. private _onGamepadConnectedObserver;
  37226. private _onGamepadDisconnectedObserver;
  37227. /**
  37228. * Attach the input controls to a specific dom element to get the input from.
  37229. * @param element Defines the element the controls should be listened from
  37230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37231. */
  37232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37233. /**
  37234. * Detach the current controls from the specified dom element.
  37235. * @param element Defines the element to stop listening the inputs from
  37236. */
  37237. detachControl(element: Nullable<HTMLElement>): void;
  37238. /**
  37239. * Update the current camera state depending on the inputs that have been used this frame.
  37240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37241. */
  37242. checkInputs(): void;
  37243. /**
  37244. * Gets the class name of the current intput.
  37245. * @returns the class name
  37246. */
  37247. getClassName(): string;
  37248. /**
  37249. * Get the friendly name associated with the input class.
  37250. * @returns the input friendly name
  37251. */
  37252. getSimpleName(): string;
  37253. }
  37254. }
  37255. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37256. import { Nullable } from "babylonjs/types";
  37257. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37258. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37259. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37260. interface ArcRotateCameraInputsManager {
  37261. /**
  37262. * Add orientation input support to the input manager.
  37263. * @returns the current input manager
  37264. */
  37265. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37266. }
  37267. }
  37268. /**
  37269. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37271. */
  37272. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37273. /**
  37274. * Defines the camera the input is attached to.
  37275. */
  37276. camera: ArcRotateCamera;
  37277. /**
  37278. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37279. */
  37280. alphaCorrection: number;
  37281. /**
  37282. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37283. */
  37284. gammaCorrection: number;
  37285. private _alpha;
  37286. private _gamma;
  37287. private _dirty;
  37288. private _deviceOrientationHandler;
  37289. /**
  37290. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37291. */
  37292. constructor();
  37293. /**
  37294. * Attach the input controls to a specific dom element to get the input from.
  37295. * @param element Defines the element the controls should be listened from
  37296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37297. */
  37298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37299. /** @hidden */
  37300. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37301. /**
  37302. * Update the current camera state depending on the inputs that have been used this frame.
  37303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37304. */
  37305. checkInputs(): void;
  37306. /**
  37307. * Detach the current controls from the specified dom element.
  37308. * @param element Defines the element to stop listening the inputs from
  37309. */
  37310. detachControl(element: Nullable<HTMLElement>): void;
  37311. /**
  37312. * Gets the class name of the current intput.
  37313. * @returns the class name
  37314. */
  37315. getClassName(): string;
  37316. /**
  37317. * Get the friendly name associated with the input class.
  37318. * @returns the input friendly name
  37319. */
  37320. getSimpleName(): string;
  37321. }
  37322. }
  37323. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37324. import { Nullable } from "babylonjs/types";
  37325. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37326. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37327. /**
  37328. * Listen to mouse events to control the camera.
  37329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37330. */
  37331. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37332. /**
  37333. * Defines the camera the input is attached to.
  37334. */
  37335. camera: FlyCamera;
  37336. /**
  37337. * Defines if touch is enabled. (Default is true.)
  37338. */
  37339. touchEnabled: boolean;
  37340. /**
  37341. * Defines the buttons associated with the input to handle camera rotation.
  37342. */
  37343. buttons: number[];
  37344. /**
  37345. * Assign buttons for Yaw control.
  37346. */
  37347. buttonsYaw: number[];
  37348. /**
  37349. * Assign buttons for Pitch control.
  37350. */
  37351. buttonsPitch: number[];
  37352. /**
  37353. * Assign buttons for Roll control.
  37354. */
  37355. buttonsRoll: number[];
  37356. /**
  37357. * Detect if any button is being pressed while mouse is moved.
  37358. * -1 = Mouse locked.
  37359. * 0 = Left button.
  37360. * 1 = Middle Button.
  37361. * 2 = Right Button.
  37362. */
  37363. activeButton: number;
  37364. /**
  37365. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37366. * Higher values reduce its sensitivity.
  37367. */
  37368. angularSensibility: number;
  37369. private _mousemoveCallback;
  37370. private _observer;
  37371. private _rollObserver;
  37372. private previousPosition;
  37373. private noPreventDefault;
  37374. private element;
  37375. /**
  37376. * Listen to mouse events to control the camera.
  37377. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37379. */
  37380. constructor(touchEnabled?: boolean);
  37381. /**
  37382. * Attach the mouse control to the HTML DOM element.
  37383. * @param element Defines the element that listens to the input events.
  37384. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37385. */
  37386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37387. /**
  37388. * Detach the current controls from the specified dom element.
  37389. * @param element Defines the element to stop listening the inputs from
  37390. */
  37391. detachControl(element: Nullable<HTMLElement>): void;
  37392. /**
  37393. * Gets the class name of the current input.
  37394. * @returns the class name.
  37395. */
  37396. getClassName(): string;
  37397. /**
  37398. * Get the friendly name associated with the input class.
  37399. * @returns the input's friendly name.
  37400. */
  37401. getSimpleName(): string;
  37402. private _pointerInput;
  37403. private _onMouseMove;
  37404. /**
  37405. * Rotate camera by mouse offset.
  37406. */
  37407. private rotateCamera;
  37408. }
  37409. }
  37410. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37411. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37412. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37413. /**
  37414. * Default Inputs manager for the FlyCamera.
  37415. * It groups all the default supported inputs for ease of use.
  37416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37417. */
  37418. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37419. /**
  37420. * Instantiates a new FlyCameraInputsManager.
  37421. * @param camera Defines the camera the inputs belong to.
  37422. */
  37423. constructor(camera: FlyCamera);
  37424. /**
  37425. * Add keyboard input support to the input manager.
  37426. * @returns the new FlyCameraKeyboardMoveInput().
  37427. */
  37428. addKeyboard(): FlyCameraInputsManager;
  37429. /**
  37430. * Add mouse input support to the input manager.
  37431. * @param touchEnabled Enable touch screen support.
  37432. * @returns the new FlyCameraMouseInput().
  37433. */
  37434. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37435. }
  37436. }
  37437. declare module "babylonjs/Cameras/flyCamera" {
  37438. import { Scene } from "babylonjs/scene";
  37439. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37441. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37442. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37443. /**
  37444. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37445. * such as in a 3D Space Shooter or a Flight Simulator.
  37446. */
  37447. export class FlyCamera extends TargetCamera {
  37448. /**
  37449. * Define the collision ellipsoid of the camera.
  37450. * This is helpful for simulating a camera body, like a player's body.
  37451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37452. */
  37453. ellipsoid: Vector3;
  37454. /**
  37455. * Define an offset for the position of the ellipsoid around the camera.
  37456. * This can be helpful if the camera is attached away from the player's body center,
  37457. * such as at its head.
  37458. */
  37459. ellipsoidOffset: Vector3;
  37460. /**
  37461. * Enable or disable collisions of the camera with the rest of the scene objects.
  37462. */
  37463. checkCollisions: boolean;
  37464. /**
  37465. * Enable or disable gravity on the camera.
  37466. */
  37467. applyGravity: boolean;
  37468. /**
  37469. * Define the current direction the camera is moving to.
  37470. */
  37471. cameraDirection: Vector3;
  37472. /**
  37473. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37474. * This overrides and empties cameraRotation.
  37475. */
  37476. rotationQuaternion: Quaternion;
  37477. /**
  37478. * Track Roll to maintain the wanted Rolling when looking around.
  37479. */
  37480. _trackRoll: number;
  37481. /**
  37482. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37483. */
  37484. rollCorrect: number;
  37485. /**
  37486. * Mimic a banked turn, Rolling the camera when Yawing.
  37487. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37488. */
  37489. bankedTurn: boolean;
  37490. /**
  37491. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37492. */
  37493. bankedTurnLimit: number;
  37494. /**
  37495. * Value of 0 disables the banked Roll.
  37496. * Value of 1 is equal to the Yaw angle in radians.
  37497. */
  37498. bankedTurnMultiplier: number;
  37499. /**
  37500. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37501. */
  37502. inputs: FlyCameraInputsManager;
  37503. /**
  37504. * Gets the input sensibility for mouse input.
  37505. * Higher values reduce sensitivity.
  37506. */
  37507. /**
  37508. * Sets the input sensibility for a mouse input.
  37509. * Higher values reduce sensitivity.
  37510. */
  37511. angularSensibility: number;
  37512. /**
  37513. * Get the keys for camera movement forward.
  37514. */
  37515. /**
  37516. * Set the keys for camera movement forward.
  37517. */
  37518. keysForward: number[];
  37519. /**
  37520. * Get the keys for camera movement backward.
  37521. */
  37522. keysBackward: number[];
  37523. /**
  37524. * Get the keys for camera movement up.
  37525. */
  37526. /**
  37527. * Set the keys for camera movement up.
  37528. */
  37529. keysUp: number[];
  37530. /**
  37531. * Get the keys for camera movement down.
  37532. */
  37533. /**
  37534. * Set the keys for camera movement down.
  37535. */
  37536. keysDown: number[];
  37537. /**
  37538. * Get the keys for camera movement left.
  37539. */
  37540. /**
  37541. * Set the keys for camera movement left.
  37542. */
  37543. keysLeft: number[];
  37544. /**
  37545. * Set the keys for camera movement right.
  37546. */
  37547. /**
  37548. * Set the keys for camera movement right.
  37549. */
  37550. keysRight: number[];
  37551. /**
  37552. * Event raised when the camera collides with a mesh in the scene.
  37553. */
  37554. onCollide: (collidedMesh: AbstractMesh) => void;
  37555. private _collider;
  37556. private _needMoveForGravity;
  37557. private _oldPosition;
  37558. private _diffPosition;
  37559. private _newPosition;
  37560. /** @hidden */
  37561. _localDirection: Vector3;
  37562. /** @hidden */
  37563. _transformedDirection: Vector3;
  37564. /**
  37565. * Instantiates a FlyCamera.
  37566. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37567. * such as in a 3D Space Shooter or a Flight Simulator.
  37568. * @param name Define the name of the camera in the scene.
  37569. * @param position Define the starting position of the camera in the scene.
  37570. * @param scene Define the scene the camera belongs to.
  37571. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37572. */
  37573. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37574. /**
  37575. * Attach a control to the HTML DOM element.
  37576. * @param element Defines the element that listens to the input events.
  37577. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37578. */
  37579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37580. /**
  37581. * Detach a control from the HTML DOM element.
  37582. * The camera will stop reacting to that input.
  37583. * @param element Defines the element that listens to the input events.
  37584. */
  37585. detachControl(element: HTMLElement): void;
  37586. private _collisionMask;
  37587. /**
  37588. * Get the mask that the camera ignores in collision events.
  37589. */
  37590. /**
  37591. * Set the mask that the camera ignores in collision events.
  37592. */
  37593. collisionMask: number;
  37594. /** @hidden */
  37595. _collideWithWorld(displacement: Vector3): void;
  37596. /** @hidden */
  37597. private _onCollisionPositionChange;
  37598. /** @hidden */
  37599. _checkInputs(): void;
  37600. /** @hidden */
  37601. _decideIfNeedsToMove(): boolean;
  37602. /** @hidden */
  37603. _updatePosition(): void;
  37604. /**
  37605. * Restore the Roll to its target value at the rate specified.
  37606. * @param rate - Higher means slower restoring.
  37607. * @hidden
  37608. */
  37609. restoreRoll(rate: number): void;
  37610. /**
  37611. * Destroy the camera and release the current resources held by it.
  37612. */
  37613. dispose(): void;
  37614. /**
  37615. * Get the current object class name.
  37616. * @returns the class name.
  37617. */
  37618. getClassName(): string;
  37619. }
  37620. }
  37621. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37622. import { Nullable } from "babylonjs/types";
  37623. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37624. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37625. /**
  37626. * Listen to keyboard events to control the camera.
  37627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37628. */
  37629. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37630. /**
  37631. * Defines the camera the input is attached to.
  37632. */
  37633. camera: FlyCamera;
  37634. /**
  37635. * The list of keyboard keys used to control the forward move of the camera.
  37636. */
  37637. keysForward: number[];
  37638. /**
  37639. * The list of keyboard keys used to control the backward move of the camera.
  37640. */
  37641. keysBackward: number[];
  37642. /**
  37643. * The list of keyboard keys used to control the forward move of the camera.
  37644. */
  37645. keysUp: number[];
  37646. /**
  37647. * The list of keyboard keys used to control the backward move of the camera.
  37648. */
  37649. keysDown: number[];
  37650. /**
  37651. * The list of keyboard keys used to control the right strafe move of the camera.
  37652. */
  37653. keysRight: number[];
  37654. /**
  37655. * The list of keyboard keys used to control the left strafe move of the camera.
  37656. */
  37657. keysLeft: number[];
  37658. private _keys;
  37659. private _onCanvasBlurObserver;
  37660. private _onKeyboardObserver;
  37661. private _engine;
  37662. private _scene;
  37663. /**
  37664. * Attach the input controls to a specific dom element to get the input from.
  37665. * @param element Defines the element the controls should be listened from
  37666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37667. */
  37668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37669. /**
  37670. * Detach the current controls from the specified dom element.
  37671. * @param element Defines the element to stop listening the inputs from
  37672. */
  37673. detachControl(element: Nullable<HTMLElement>): void;
  37674. /**
  37675. * Gets the class name of the current intput.
  37676. * @returns the class name
  37677. */
  37678. getClassName(): string;
  37679. /** @hidden */
  37680. _onLostFocus(e: FocusEvent): void;
  37681. /**
  37682. * Get the friendly name associated with the input class.
  37683. * @returns the input friendly name
  37684. */
  37685. getSimpleName(): string;
  37686. /**
  37687. * Update the current camera state depending on the inputs that have been used this frame.
  37688. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37689. */
  37690. checkInputs(): void;
  37691. }
  37692. }
  37693. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37694. import { Nullable } from "babylonjs/types";
  37695. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37696. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37697. /**
  37698. * Manage the mouse wheel inputs to control a follow camera.
  37699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37700. */
  37701. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37702. /**
  37703. * Defines the camera the input is attached to.
  37704. */
  37705. camera: FollowCamera;
  37706. /**
  37707. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37708. */
  37709. axisControlRadius: boolean;
  37710. /**
  37711. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37712. */
  37713. axisControlHeight: boolean;
  37714. /**
  37715. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37716. */
  37717. axisControlRotation: boolean;
  37718. /**
  37719. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37720. * relation to mouseWheel events.
  37721. */
  37722. wheelPrecision: number;
  37723. /**
  37724. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37725. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37726. */
  37727. wheelDeltaPercentage: number;
  37728. private _wheel;
  37729. private _observer;
  37730. /**
  37731. * Attach the input controls to a specific dom element to get the input from.
  37732. * @param element Defines the element the controls should be listened from
  37733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37734. */
  37735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37736. /**
  37737. * Detach the current controls from the specified dom element.
  37738. * @param element Defines the element to stop listening the inputs from
  37739. */
  37740. detachControl(element: Nullable<HTMLElement>): void;
  37741. /**
  37742. * Gets the class name of the current intput.
  37743. * @returns the class name
  37744. */
  37745. getClassName(): string;
  37746. /**
  37747. * Get the friendly name associated with the input class.
  37748. * @returns the input friendly name
  37749. */
  37750. getSimpleName(): string;
  37751. }
  37752. }
  37753. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37754. import { Nullable } from "babylonjs/types";
  37755. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37756. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37757. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37758. /**
  37759. * Manage the pointers inputs to control an follow camera.
  37760. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37761. */
  37762. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37763. /**
  37764. * Defines the camera the input is attached to.
  37765. */
  37766. camera: FollowCamera;
  37767. /**
  37768. * Gets the class name of the current input.
  37769. * @returns the class name
  37770. */
  37771. getClassName(): string;
  37772. /**
  37773. * Defines the pointer angular sensibility along the X axis or how fast is
  37774. * the camera rotating.
  37775. * A negative number will reverse the axis direction.
  37776. */
  37777. angularSensibilityX: number;
  37778. /**
  37779. * Defines the pointer angular sensibility along the Y axis or how fast is
  37780. * the camera rotating.
  37781. * A negative number will reverse the axis direction.
  37782. */
  37783. angularSensibilityY: number;
  37784. /**
  37785. * Defines the pointer pinch precision or how fast is the camera zooming.
  37786. * A negative number will reverse the axis direction.
  37787. */
  37788. pinchPrecision: number;
  37789. /**
  37790. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37791. * from 0.
  37792. * It defines the percentage of current camera.radius to use as delta when
  37793. * pinch zoom is used.
  37794. */
  37795. pinchDeltaPercentage: number;
  37796. /**
  37797. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37798. */
  37799. axisXControlRadius: boolean;
  37800. /**
  37801. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37802. */
  37803. axisXControlHeight: boolean;
  37804. /**
  37805. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37806. */
  37807. axisXControlRotation: boolean;
  37808. /**
  37809. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37810. */
  37811. axisYControlRadius: boolean;
  37812. /**
  37813. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37814. */
  37815. axisYControlHeight: boolean;
  37816. /**
  37817. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37818. */
  37819. axisYControlRotation: boolean;
  37820. /**
  37821. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37822. */
  37823. axisPinchControlRadius: boolean;
  37824. /**
  37825. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37826. */
  37827. axisPinchControlHeight: boolean;
  37828. /**
  37829. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37830. */
  37831. axisPinchControlRotation: boolean;
  37832. /**
  37833. * Log error messages if basic misconfiguration has occurred.
  37834. */
  37835. warningEnable: boolean;
  37836. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37837. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37838. private _warningCounter;
  37839. private _warning;
  37840. }
  37841. }
  37842. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37843. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37844. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37845. /**
  37846. * Default Inputs manager for the FollowCamera.
  37847. * It groups all the default supported inputs for ease of use.
  37848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37849. */
  37850. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37851. /**
  37852. * Instantiates a new FollowCameraInputsManager.
  37853. * @param camera Defines the camera the inputs belong to
  37854. */
  37855. constructor(camera: FollowCamera);
  37856. /**
  37857. * Add keyboard input support to the input manager.
  37858. * @returns the current input manager
  37859. */
  37860. addKeyboard(): FollowCameraInputsManager;
  37861. /**
  37862. * Add mouse wheel input support to the input manager.
  37863. * @returns the current input manager
  37864. */
  37865. addMouseWheel(): FollowCameraInputsManager;
  37866. /**
  37867. * Add pointers input support to the input manager.
  37868. * @returns the current input manager
  37869. */
  37870. addPointers(): FollowCameraInputsManager;
  37871. /**
  37872. * Add orientation input support to the input manager.
  37873. * @returns the current input manager
  37874. */
  37875. addVRDeviceOrientation(): FollowCameraInputsManager;
  37876. }
  37877. }
  37878. declare module "babylonjs/Cameras/followCamera" {
  37879. import { Nullable } from "babylonjs/types";
  37880. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37881. import { Scene } from "babylonjs/scene";
  37882. import { Vector3 } from "babylonjs/Maths/math";
  37883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37884. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37885. /**
  37886. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37887. * an arc rotate version arcFollowCamera are available.
  37888. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37889. */
  37890. export class FollowCamera extends TargetCamera {
  37891. /**
  37892. * Distance the follow camera should follow an object at
  37893. */
  37894. radius: number;
  37895. /**
  37896. * Minimum allowed distance of the camera to the axis of rotation
  37897. * (The camera can not get closer).
  37898. * This can help limiting how the Camera is able to move in the scene.
  37899. */
  37900. lowerRadiusLimit: Nullable<number>;
  37901. /**
  37902. * Maximum allowed distance of the camera to the axis of rotation
  37903. * (The camera can not get further).
  37904. * This can help limiting how the Camera is able to move in the scene.
  37905. */
  37906. upperRadiusLimit: Nullable<number>;
  37907. /**
  37908. * Define a rotation offset between the camera and the object it follows
  37909. */
  37910. rotationOffset: number;
  37911. /**
  37912. * Minimum allowed angle to camera position relative to target object.
  37913. * This can help limiting how the Camera is able to move in the scene.
  37914. */
  37915. lowerRotationOffsetLimit: Nullable<number>;
  37916. /**
  37917. * Maximum allowed angle to camera position relative to target object.
  37918. * This can help limiting how the Camera is able to move in the scene.
  37919. */
  37920. upperRotationOffsetLimit: Nullable<number>;
  37921. /**
  37922. * Define a height offset between the camera and the object it follows.
  37923. * It can help following an object from the top (like a car chaing a plane)
  37924. */
  37925. heightOffset: number;
  37926. /**
  37927. * Minimum allowed height of camera position relative to target object.
  37928. * This can help limiting how the Camera is able to move in the scene.
  37929. */
  37930. lowerHeightOffsetLimit: Nullable<number>;
  37931. /**
  37932. * Maximum allowed height of camera position relative to target object.
  37933. * This can help limiting how the Camera is able to move in the scene.
  37934. */
  37935. upperHeightOffsetLimit: Nullable<number>;
  37936. /**
  37937. * Define how fast the camera can accelerate to follow it s target.
  37938. */
  37939. cameraAcceleration: number;
  37940. /**
  37941. * Define the speed limit of the camera following an object.
  37942. */
  37943. maxCameraSpeed: number;
  37944. /**
  37945. * Define the target of the camera.
  37946. */
  37947. lockedTarget: Nullable<AbstractMesh>;
  37948. /**
  37949. * Defines the input associated with the camera.
  37950. */
  37951. inputs: FollowCameraInputsManager;
  37952. /**
  37953. * Instantiates the follow camera.
  37954. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37955. * @param name Define the name of the camera in the scene
  37956. * @param position Define the position of the camera
  37957. * @param scene Define the scene the camera belong to
  37958. * @param lockedTarget Define the target of the camera
  37959. */
  37960. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37961. private _follow;
  37962. /**
  37963. * Attached controls to the current camera.
  37964. * @param element Defines the element the controls should be listened from
  37965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37966. */
  37967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37968. /**
  37969. * Detach the current controls from the camera.
  37970. * The camera will stop reacting to inputs.
  37971. * @param element Defines the element to stop listening the inputs from
  37972. */
  37973. detachControl(element: HTMLElement): void;
  37974. /** @hidden */
  37975. _checkInputs(): void;
  37976. private _checkLimits;
  37977. /**
  37978. * Gets the camera class name.
  37979. * @returns the class name
  37980. */
  37981. getClassName(): string;
  37982. }
  37983. /**
  37984. * Arc Rotate version of the follow camera.
  37985. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37986. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37987. */
  37988. export class ArcFollowCamera extends TargetCamera {
  37989. /** The longitudinal angle of the camera */
  37990. alpha: number;
  37991. /** The latitudinal angle of the camera */
  37992. beta: number;
  37993. /** The radius of the camera from its target */
  37994. radius: number;
  37995. /** Define the camera target (the messh it should follow) */
  37996. target: Nullable<AbstractMesh>;
  37997. private _cartesianCoordinates;
  37998. /**
  37999. * Instantiates a new ArcFollowCamera
  38000. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38001. * @param name Define the name of the camera
  38002. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38003. * @param beta Define the rotation angle of the camera around the elevation axis
  38004. * @param radius Define the radius of the camera from its target point
  38005. * @param target Define the target of the camera
  38006. * @param scene Define the scene the camera belongs to
  38007. */
  38008. constructor(name: string,
  38009. /** The longitudinal angle of the camera */
  38010. alpha: number,
  38011. /** The latitudinal angle of the camera */
  38012. beta: number,
  38013. /** The radius of the camera from its target */
  38014. radius: number,
  38015. /** Define the camera target (the messh it should follow) */
  38016. target: Nullable<AbstractMesh>, scene: Scene);
  38017. private _follow;
  38018. /** @hidden */
  38019. _checkInputs(): void;
  38020. /**
  38021. * Returns the class name of the object.
  38022. * It is mostly used internally for serialization purposes.
  38023. */
  38024. getClassName(): string;
  38025. }
  38026. }
  38027. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38028. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38029. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38030. import { Nullable } from "babylonjs/types";
  38031. /**
  38032. * Manage the keyboard inputs to control the movement of a follow camera.
  38033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38034. */
  38035. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38036. /**
  38037. * Defines the camera the input is attached to.
  38038. */
  38039. camera: FollowCamera;
  38040. /**
  38041. * Defines the list of key codes associated with the up action (increase heightOffset)
  38042. */
  38043. keysHeightOffsetIncr: number[];
  38044. /**
  38045. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38046. */
  38047. keysHeightOffsetDecr: number[];
  38048. /**
  38049. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38050. */
  38051. keysHeightOffsetModifierAlt: boolean;
  38052. /**
  38053. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38054. */
  38055. keysHeightOffsetModifierCtrl: boolean;
  38056. /**
  38057. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38058. */
  38059. keysHeightOffsetModifierShift: boolean;
  38060. /**
  38061. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38062. */
  38063. keysRotationOffsetIncr: number[];
  38064. /**
  38065. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38066. */
  38067. keysRotationOffsetDecr: number[];
  38068. /**
  38069. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38070. */
  38071. keysRotationOffsetModifierAlt: boolean;
  38072. /**
  38073. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38074. */
  38075. keysRotationOffsetModifierCtrl: boolean;
  38076. /**
  38077. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38078. */
  38079. keysRotationOffsetModifierShift: boolean;
  38080. /**
  38081. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38082. */
  38083. keysRadiusIncr: number[];
  38084. /**
  38085. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38086. */
  38087. keysRadiusDecr: number[];
  38088. /**
  38089. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38090. */
  38091. keysRadiusModifierAlt: boolean;
  38092. /**
  38093. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38094. */
  38095. keysRadiusModifierCtrl: boolean;
  38096. /**
  38097. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38098. */
  38099. keysRadiusModifierShift: boolean;
  38100. /**
  38101. * Defines the rate of change of heightOffset.
  38102. */
  38103. heightSensibility: number;
  38104. /**
  38105. * Defines the rate of change of rotationOffset.
  38106. */
  38107. rotationSensibility: number;
  38108. /**
  38109. * Defines the rate of change of radius.
  38110. */
  38111. radiusSensibility: number;
  38112. private _keys;
  38113. private _ctrlPressed;
  38114. private _altPressed;
  38115. private _shiftPressed;
  38116. private _onCanvasBlurObserver;
  38117. private _onKeyboardObserver;
  38118. private _engine;
  38119. private _scene;
  38120. /**
  38121. * Attach the input controls to a specific dom element to get the input from.
  38122. * @param element Defines the element the controls should be listened from
  38123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38124. */
  38125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38126. /**
  38127. * Detach the current controls from the specified dom element.
  38128. * @param element Defines the element to stop listening the inputs from
  38129. */
  38130. detachControl(element: Nullable<HTMLElement>): void;
  38131. /**
  38132. * Update the current camera state depending on the inputs that have been used this frame.
  38133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38134. */
  38135. checkInputs(): void;
  38136. /**
  38137. * Gets the class name of the current input.
  38138. * @returns the class name
  38139. */
  38140. getClassName(): string;
  38141. /**
  38142. * Get the friendly name associated with the input class.
  38143. * @returns the input friendly name
  38144. */
  38145. getSimpleName(): string;
  38146. /**
  38147. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38148. * allow modification of the heightOffset value.
  38149. */
  38150. private _modifierHeightOffset;
  38151. /**
  38152. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38153. * allow modification of the rotationOffset value.
  38154. */
  38155. private _modifierRotationOffset;
  38156. /**
  38157. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38158. * allow modification of the radius value.
  38159. */
  38160. private _modifierRadius;
  38161. }
  38162. }
  38163. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38164. import { Nullable } from "babylonjs/types";
  38165. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38166. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38167. import { Observable } from "babylonjs/Misc/observable";
  38168. module "babylonjs/Cameras/freeCameraInputsManager" {
  38169. interface FreeCameraInputsManager {
  38170. /**
  38171. * @hidden
  38172. */
  38173. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38174. /**
  38175. * Add orientation input support to the input manager.
  38176. * @returns the current input manager
  38177. */
  38178. addDeviceOrientation(): FreeCameraInputsManager;
  38179. }
  38180. }
  38181. /**
  38182. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38183. * Screen rotation is taken into account.
  38184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38185. */
  38186. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38187. private _camera;
  38188. private _screenOrientationAngle;
  38189. private _constantTranform;
  38190. private _screenQuaternion;
  38191. private _alpha;
  38192. private _beta;
  38193. private _gamma;
  38194. /**
  38195. * @hidden
  38196. */
  38197. _onDeviceOrientationChangedObservable: Observable<void>;
  38198. /**
  38199. * Instantiates a new input
  38200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38201. */
  38202. constructor();
  38203. /**
  38204. * Define the camera controlled by the input.
  38205. */
  38206. camera: FreeCamera;
  38207. /**
  38208. * Attach the input controls to a specific dom element to get the input from.
  38209. * @param element Defines the element the controls should be listened from
  38210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38211. */
  38212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38213. private _orientationChanged;
  38214. private _deviceOrientation;
  38215. /**
  38216. * Detach the current controls from the specified dom element.
  38217. * @param element Defines the element to stop listening the inputs from
  38218. */
  38219. detachControl(element: Nullable<HTMLElement>): void;
  38220. /**
  38221. * Update the current camera state depending on the inputs that have been used this frame.
  38222. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38223. */
  38224. checkInputs(): void;
  38225. /**
  38226. * Gets the class name of the current intput.
  38227. * @returns the class name
  38228. */
  38229. getClassName(): string;
  38230. /**
  38231. * Get the friendly name associated with the input class.
  38232. * @returns the input friendly name
  38233. */
  38234. getSimpleName(): string;
  38235. }
  38236. }
  38237. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38238. import { Nullable } from "babylonjs/types";
  38239. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38240. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38241. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38242. /**
  38243. * Manage the gamepad inputs to control a free camera.
  38244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38245. */
  38246. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38247. /**
  38248. * Define the camera the input is attached to.
  38249. */
  38250. camera: FreeCamera;
  38251. /**
  38252. * Define the Gamepad controlling the input
  38253. */
  38254. gamepad: Nullable<Gamepad>;
  38255. /**
  38256. * Defines the gamepad rotation sensiblity.
  38257. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38258. */
  38259. gamepadAngularSensibility: number;
  38260. /**
  38261. * Defines the gamepad move sensiblity.
  38262. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38263. */
  38264. gamepadMoveSensibility: number;
  38265. private _onGamepadConnectedObserver;
  38266. private _onGamepadDisconnectedObserver;
  38267. private _cameraTransform;
  38268. private _deltaTransform;
  38269. private _vector3;
  38270. private _vector2;
  38271. /**
  38272. * Attach the input controls to a specific dom element to get the input from.
  38273. * @param element Defines the element the controls should be listened from
  38274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38275. */
  38276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38277. /**
  38278. * Detach the current controls from the specified dom element.
  38279. * @param element Defines the element to stop listening the inputs from
  38280. */
  38281. detachControl(element: Nullable<HTMLElement>): void;
  38282. /**
  38283. * Update the current camera state depending on the inputs that have been used this frame.
  38284. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38285. */
  38286. checkInputs(): void;
  38287. /**
  38288. * Gets the class name of the current intput.
  38289. * @returns the class name
  38290. */
  38291. getClassName(): string;
  38292. /**
  38293. * Get the friendly name associated with the input class.
  38294. * @returns the input friendly name
  38295. */
  38296. getSimpleName(): string;
  38297. }
  38298. }
  38299. declare module "babylonjs/Misc/virtualJoystick" {
  38300. import { Nullable } from "babylonjs/types";
  38301. import { Vector3 } from "babylonjs/Maths/math";
  38302. /**
  38303. * Defines the potential axis of a Joystick
  38304. */
  38305. export enum JoystickAxis {
  38306. /** X axis */
  38307. X = 0,
  38308. /** Y axis */
  38309. Y = 1,
  38310. /** Z axis */
  38311. Z = 2
  38312. }
  38313. /**
  38314. * Class used to define virtual joystick (used in touch mode)
  38315. */
  38316. export class VirtualJoystick {
  38317. /**
  38318. * Gets or sets a boolean indicating that left and right values must be inverted
  38319. */
  38320. reverseLeftRight: boolean;
  38321. /**
  38322. * Gets or sets a boolean indicating that up and down values must be inverted
  38323. */
  38324. reverseUpDown: boolean;
  38325. /**
  38326. * Gets the offset value for the position (ie. the change of the position value)
  38327. */
  38328. deltaPosition: Vector3;
  38329. /**
  38330. * Gets a boolean indicating if the virtual joystick was pressed
  38331. */
  38332. pressed: boolean;
  38333. /**
  38334. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38335. */
  38336. static Canvas: Nullable<HTMLCanvasElement>;
  38337. private static _globalJoystickIndex;
  38338. private static vjCanvasContext;
  38339. private static vjCanvasWidth;
  38340. private static vjCanvasHeight;
  38341. private static halfWidth;
  38342. private _action;
  38343. private _axisTargetedByLeftAndRight;
  38344. private _axisTargetedByUpAndDown;
  38345. private _joystickSensibility;
  38346. private _inversedSensibility;
  38347. private _joystickPointerID;
  38348. private _joystickColor;
  38349. private _joystickPointerPos;
  38350. private _joystickPreviousPointerPos;
  38351. private _joystickPointerStartPos;
  38352. private _deltaJoystickVector;
  38353. private _leftJoystick;
  38354. private _touches;
  38355. private _onPointerDownHandlerRef;
  38356. private _onPointerMoveHandlerRef;
  38357. private _onPointerUpHandlerRef;
  38358. private _onResize;
  38359. /**
  38360. * Creates a new virtual joystick
  38361. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38362. */
  38363. constructor(leftJoystick?: boolean);
  38364. /**
  38365. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38366. * @param newJoystickSensibility defines the new sensibility
  38367. */
  38368. setJoystickSensibility(newJoystickSensibility: number): void;
  38369. private _onPointerDown;
  38370. private _onPointerMove;
  38371. private _onPointerUp;
  38372. /**
  38373. * Change the color of the virtual joystick
  38374. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38375. */
  38376. setJoystickColor(newColor: string): void;
  38377. /**
  38378. * Defines a callback to call when the joystick is touched
  38379. * @param action defines the callback
  38380. */
  38381. setActionOnTouch(action: () => any): void;
  38382. /**
  38383. * Defines which axis you'd like to control for left & right
  38384. * @param axis defines the axis to use
  38385. */
  38386. setAxisForLeftRight(axis: JoystickAxis): void;
  38387. /**
  38388. * Defines which axis you'd like to control for up & down
  38389. * @param axis defines the axis to use
  38390. */
  38391. setAxisForUpDown(axis: JoystickAxis): void;
  38392. private _drawVirtualJoystick;
  38393. /**
  38394. * Release internal HTML canvas
  38395. */
  38396. releaseCanvas(): void;
  38397. }
  38398. }
  38399. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38400. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38401. import { Nullable } from "babylonjs/types";
  38402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38403. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38404. module "babylonjs/Cameras/freeCameraInputsManager" {
  38405. interface FreeCameraInputsManager {
  38406. /**
  38407. * Add virtual joystick input support to the input manager.
  38408. * @returns the current input manager
  38409. */
  38410. addVirtualJoystick(): FreeCameraInputsManager;
  38411. }
  38412. }
  38413. /**
  38414. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38416. */
  38417. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38418. /**
  38419. * Defines the camera the input is attached to.
  38420. */
  38421. camera: FreeCamera;
  38422. private _leftjoystick;
  38423. private _rightjoystick;
  38424. /**
  38425. * Gets the left stick of the virtual joystick.
  38426. * @returns The virtual Joystick
  38427. */
  38428. getLeftJoystick(): VirtualJoystick;
  38429. /**
  38430. * Gets the right stick of the virtual joystick.
  38431. * @returns The virtual Joystick
  38432. */
  38433. getRightJoystick(): VirtualJoystick;
  38434. /**
  38435. * Update the current camera state depending on the inputs that have been used this frame.
  38436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38437. */
  38438. checkInputs(): void;
  38439. /**
  38440. * Attach the input controls to a specific dom element to get the input from.
  38441. * @param element Defines the element the controls should be listened from
  38442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38443. */
  38444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38445. /**
  38446. * Detach the current controls from the specified dom element.
  38447. * @param element Defines the element to stop listening the inputs from
  38448. */
  38449. detachControl(element: Nullable<HTMLElement>): void;
  38450. /**
  38451. * Gets the class name of the current intput.
  38452. * @returns the class name
  38453. */
  38454. getClassName(): string;
  38455. /**
  38456. * Get the friendly name associated with the input class.
  38457. * @returns the input friendly name
  38458. */
  38459. getSimpleName(): string;
  38460. }
  38461. }
  38462. declare module "babylonjs/Cameras/Inputs/index" {
  38463. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38464. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38465. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38466. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38467. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38468. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38469. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38470. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38471. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38472. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38473. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38474. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38475. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38476. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38477. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38478. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38479. }
  38480. declare module "babylonjs/Cameras/touchCamera" {
  38481. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38482. import { Scene } from "babylonjs/scene";
  38483. import { Vector3 } from "babylonjs/Maths/math";
  38484. /**
  38485. * This represents a FPS type of camera controlled by touch.
  38486. * This is like a universal camera minus the Gamepad controls.
  38487. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38488. */
  38489. export class TouchCamera extends FreeCamera {
  38490. /**
  38491. * Defines the touch sensibility for rotation.
  38492. * The higher the faster.
  38493. */
  38494. touchAngularSensibility: number;
  38495. /**
  38496. * Defines the touch sensibility for move.
  38497. * The higher the faster.
  38498. */
  38499. touchMoveSensibility: number;
  38500. /**
  38501. * Instantiates a new touch camera.
  38502. * This represents a FPS type of camera controlled by touch.
  38503. * This is like a universal camera minus the Gamepad controls.
  38504. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38505. * @param name Define the name of the camera in the scene
  38506. * @param position Define the start position of the camera in the scene
  38507. * @param scene Define the scene the camera belongs to
  38508. */
  38509. constructor(name: string, position: Vector3, scene: Scene);
  38510. /**
  38511. * Gets the current object class name.
  38512. * @return the class name
  38513. */
  38514. getClassName(): string;
  38515. /** @hidden */
  38516. _setupInputs(): void;
  38517. }
  38518. }
  38519. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38520. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38521. import { Scene } from "babylonjs/scene";
  38522. import { Vector3, Axis } from "babylonjs/Maths/math";
  38523. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38524. /**
  38525. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38526. * being tilted forward or back and left or right.
  38527. */
  38528. export class DeviceOrientationCamera extends FreeCamera {
  38529. private _initialQuaternion;
  38530. private _quaternionCache;
  38531. private _tmpDragQuaternion;
  38532. /**
  38533. * Creates a new device orientation camera
  38534. * @param name The name of the camera
  38535. * @param position The start position camera
  38536. * @param scene The scene the camera belongs to
  38537. */
  38538. constructor(name: string, position: Vector3, scene: Scene);
  38539. /**
  38540. * @hidden
  38541. * Disabled pointer input on first orientation sensor update (Default: true)
  38542. */
  38543. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38544. private _dragFactor;
  38545. /**
  38546. * Enabled turning on the y axis when the orientation sensor is active
  38547. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38548. */
  38549. enableHorizontalDragging(dragFactor?: number): void;
  38550. /**
  38551. * Gets the current instance class name ("DeviceOrientationCamera").
  38552. * This helps avoiding instanceof at run time.
  38553. * @returns the class name
  38554. */
  38555. getClassName(): string;
  38556. /**
  38557. * @hidden
  38558. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38559. */
  38560. _checkInputs(): void;
  38561. /**
  38562. * Reset the camera to its default orientation on the specified axis only.
  38563. * @param axis The axis to reset
  38564. */
  38565. resetToCurrentRotation(axis?: Axis): void;
  38566. }
  38567. }
  38568. declare module "babylonjs/Gamepads/xboxGamepad" {
  38569. import { Observable } from "babylonjs/Misc/observable";
  38570. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38571. /**
  38572. * Defines supported buttons for XBox360 compatible gamepads
  38573. */
  38574. export enum Xbox360Button {
  38575. /** A */
  38576. A = 0,
  38577. /** B */
  38578. B = 1,
  38579. /** X */
  38580. X = 2,
  38581. /** Y */
  38582. Y = 3,
  38583. /** Start */
  38584. Start = 4,
  38585. /** Back */
  38586. Back = 5,
  38587. /** Left button */
  38588. LB = 6,
  38589. /** Right button */
  38590. RB = 7,
  38591. /** Left stick */
  38592. LeftStick = 8,
  38593. /** Right stick */
  38594. RightStick = 9
  38595. }
  38596. /** Defines values for XBox360 DPad */
  38597. export enum Xbox360Dpad {
  38598. /** Up */
  38599. Up = 0,
  38600. /** Down */
  38601. Down = 1,
  38602. /** Left */
  38603. Left = 2,
  38604. /** Right */
  38605. Right = 3
  38606. }
  38607. /**
  38608. * Defines a XBox360 gamepad
  38609. */
  38610. export class Xbox360Pad extends Gamepad {
  38611. private _leftTrigger;
  38612. private _rightTrigger;
  38613. private _onlefttriggerchanged;
  38614. private _onrighttriggerchanged;
  38615. private _onbuttondown;
  38616. private _onbuttonup;
  38617. private _ondpaddown;
  38618. private _ondpadup;
  38619. /** Observable raised when a button is pressed */
  38620. onButtonDownObservable: Observable<Xbox360Button>;
  38621. /** Observable raised when a button is released */
  38622. onButtonUpObservable: Observable<Xbox360Button>;
  38623. /** Observable raised when a pad is pressed */
  38624. onPadDownObservable: Observable<Xbox360Dpad>;
  38625. /** Observable raised when a pad is released */
  38626. onPadUpObservable: Observable<Xbox360Dpad>;
  38627. private _buttonA;
  38628. private _buttonB;
  38629. private _buttonX;
  38630. private _buttonY;
  38631. private _buttonBack;
  38632. private _buttonStart;
  38633. private _buttonLB;
  38634. private _buttonRB;
  38635. private _buttonLeftStick;
  38636. private _buttonRightStick;
  38637. private _dPadUp;
  38638. private _dPadDown;
  38639. private _dPadLeft;
  38640. private _dPadRight;
  38641. private _isXboxOnePad;
  38642. /**
  38643. * Creates a new XBox360 gamepad object
  38644. * @param id defines the id of this gamepad
  38645. * @param index defines its index
  38646. * @param gamepad defines the internal HTML gamepad object
  38647. * @param xboxOne defines if it is a XBox One gamepad
  38648. */
  38649. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38650. /**
  38651. * Defines the callback to call when left trigger is pressed
  38652. * @param callback defines the callback to use
  38653. */
  38654. onlefttriggerchanged(callback: (value: number) => void): void;
  38655. /**
  38656. * Defines the callback to call when right trigger is pressed
  38657. * @param callback defines the callback to use
  38658. */
  38659. onrighttriggerchanged(callback: (value: number) => void): void;
  38660. /**
  38661. * Gets the left trigger value
  38662. */
  38663. /**
  38664. * Sets the left trigger value
  38665. */
  38666. leftTrigger: number;
  38667. /**
  38668. * Gets the right trigger value
  38669. */
  38670. /**
  38671. * Sets the right trigger value
  38672. */
  38673. rightTrigger: number;
  38674. /**
  38675. * Defines the callback to call when a button is pressed
  38676. * @param callback defines the callback to use
  38677. */
  38678. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38679. /**
  38680. * Defines the callback to call when a button is released
  38681. * @param callback defines the callback to use
  38682. */
  38683. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38684. /**
  38685. * Defines the callback to call when a pad is pressed
  38686. * @param callback defines the callback to use
  38687. */
  38688. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38689. /**
  38690. * Defines the callback to call when a pad is released
  38691. * @param callback defines the callback to use
  38692. */
  38693. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38694. private _setButtonValue;
  38695. private _setDPadValue;
  38696. /**
  38697. * Gets the value of the `A` button
  38698. */
  38699. /**
  38700. * Sets the value of the `A` button
  38701. */
  38702. buttonA: number;
  38703. /**
  38704. * Gets the value of the `B` button
  38705. */
  38706. /**
  38707. * Sets the value of the `B` button
  38708. */
  38709. buttonB: number;
  38710. /**
  38711. * Gets the value of the `X` button
  38712. */
  38713. /**
  38714. * Sets the value of the `X` button
  38715. */
  38716. buttonX: number;
  38717. /**
  38718. * Gets the value of the `Y` button
  38719. */
  38720. /**
  38721. * Sets the value of the `Y` button
  38722. */
  38723. buttonY: number;
  38724. /**
  38725. * Gets the value of the `Start` button
  38726. */
  38727. /**
  38728. * Sets the value of the `Start` button
  38729. */
  38730. buttonStart: number;
  38731. /**
  38732. * Gets the value of the `Back` button
  38733. */
  38734. /**
  38735. * Sets the value of the `Back` button
  38736. */
  38737. buttonBack: number;
  38738. /**
  38739. * Gets the value of the `Left` button
  38740. */
  38741. /**
  38742. * Sets the value of the `Left` button
  38743. */
  38744. buttonLB: number;
  38745. /**
  38746. * Gets the value of the `Right` button
  38747. */
  38748. /**
  38749. * Sets the value of the `Right` button
  38750. */
  38751. buttonRB: number;
  38752. /**
  38753. * Gets the value of the Left joystick
  38754. */
  38755. /**
  38756. * Sets the value of the Left joystick
  38757. */
  38758. buttonLeftStick: number;
  38759. /**
  38760. * Gets the value of the Right joystick
  38761. */
  38762. /**
  38763. * Sets the value of the Right joystick
  38764. */
  38765. buttonRightStick: number;
  38766. /**
  38767. * Gets the value of D-pad up
  38768. */
  38769. /**
  38770. * Sets the value of D-pad up
  38771. */
  38772. dPadUp: number;
  38773. /**
  38774. * Gets the value of D-pad down
  38775. */
  38776. /**
  38777. * Sets the value of D-pad down
  38778. */
  38779. dPadDown: number;
  38780. /**
  38781. * Gets the value of D-pad left
  38782. */
  38783. /**
  38784. * Sets the value of D-pad left
  38785. */
  38786. dPadLeft: number;
  38787. /**
  38788. * Gets the value of D-pad right
  38789. */
  38790. /**
  38791. * Sets the value of D-pad right
  38792. */
  38793. dPadRight: number;
  38794. /**
  38795. * Force the gamepad to synchronize with device values
  38796. */
  38797. update(): void;
  38798. /**
  38799. * Disposes the gamepad
  38800. */
  38801. dispose(): void;
  38802. }
  38803. }
  38804. declare module "babylonjs/Gamepads/gamepadManager" {
  38805. import { Observable } from "babylonjs/Misc/observable";
  38806. import { Nullable } from "babylonjs/types";
  38807. import { Scene } from "babylonjs/scene";
  38808. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38809. /**
  38810. * Manager for handling gamepads
  38811. */
  38812. export class GamepadManager {
  38813. private _scene?;
  38814. private _babylonGamepads;
  38815. private _oneGamepadConnected;
  38816. /** @hidden */
  38817. _isMonitoring: boolean;
  38818. private _gamepadEventSupported;
  38819. private _gamepadSupport;
  38820. /**
  38821. * observable to be triggered when the gamepad controller has been connected
  38822. */
  38823. onGamepadConnectedObservable: Observable<Gamepad>;
  38824. /**
  38825. * observable to be triggered when the gamepad controller has been disconnected
  38826. */
  38827. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38828. private _onGamepadConnectedEvent;
  38829. private _onGamepadDisconnectedEvent;
  38830. /**
  38831. * Initializes the gamepad manager
  38832. * @param _scene BabylonJS scene
  38833. */
  38834. constructor(_scene?: Scene | undefined);
  38835. /**
  38836. * The gamepads in the game pad manager
  38837. */
  38838. readonly gamepads: Gamepad[];
  38839. /**
  38840. * Get the gamepad controllers based on type
  38841. * @param type The type of gamepad controller
  38842. * @returns Nullable gamepad
  38843. */
  38844. getGamepadByType(type?: number): Nullable<Gamepad>;
  38845. /**
  38846. * Disposes the gamepad manager
  38847. */
  38848. dispose(): void;
  38849. private _addNewGamepad;
  38850. private _startMonitoringGamepads;
  38851. private _stopMonitoringGamepads;
  38852. /** @hidden */
  38853. _checkGamepadsStatus(): void;
  38854. private _updateGamepadObjects;
  38855. }
  38856. }
  38857. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  38858. import { Nullable } from "babylonjs/types";
  38859. import { Scene } from "babylonjs/scene";
  38860. import { ISceneComponent } from "babylonjs/sceneComponent";
  38861. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  38862. module "babylonjs/scene" {
  38863. interface Scene {
  38864. /** @hidden */
  38865. _gamepadManager: Nullable<GamepadManager>;
  38866. /**
  38867. * Gets the gamepad manager associated with the scene
  38868. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38869. */
  38870. gamepadManager: GamepadManager;
  38871. }
  38872. }
  38873. module "babylonjs/Cameras/freeCameraInputsManager" {
  38874. /**
  38875. * Interface representing a free camera inputs manager
  38876. */
  38877. interface FreeCameraInputsManager {
  38878. /**
  38879. * Adds gamepad input support to the FreeCameraInputsManager.
  38880. * @returns the FreeCameraInputsManager
  38881. */
  38882. addGamepad(): FreeCameraInputsManager;
  38883. }
  38884. }
  38885. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38886. /**
  38887. * Interface representing an arc rotate camera inputs manager
  38888. */
  38889. interface ArcRotateCameraInputsManager {
  38890. /**
  38891. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38892. * @returns the camera inputs manager
  38893. */
  38894. addGamepad(): ArcRotateCameraInputsManager;
  38895. }
  38896. }
  38897. /**
  38898. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38899. */
  38900. export class GamepadSystemSceneComponent implements ISceneComponent {
  38901. /**
  38902. * The component name helpfull to identify the component in the list of scene components.
  38903. */
  38904. readonly name: string;
  38905. /**
  38906. * The scene the component belongs to.
  38907. */
  38908. scene: Scene;
  38909. /**
  38910. * Creates a new instance of the component for the given scene
  38911. * @param scene Defines the scene to register the component in
  38912. */
  38913. constructor(scene: Scene);
  38914. /**
  38915. * Registers the component in a given scene
  38916. */
  38917. register(): void;
  38918. /**
  38919. * Rebuilds the elements related to this component in case of
  38920. * context lost for instance.
  38921. */
  38922. rebuild(): void;
  38923. /**
  38924. * Disposes the component and the associated ressources
  38925. */
  38926. dispose(): void;
  38927. private _beforeCameraUpdate;
  38928. }
  38929. }
  38930. declare module "babylonjs/Cameras/universalCamera" {
  38931. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38932. import { Scene } from "babylonjs/scene";
  38933. import { Vector3 } from "babylonjs/Maths/math";
  38934. import "babylonjs/Gamepads/gamepadSceneComponent";
  38935. /**
  38936. * 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,
  38937. * which still works and will still be found in many Playgrounds.
  38938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38939. */
  38940. export class UniversalCamera extends TouchCamera {
  38941. /**
  38942. * Defines the gamepad rotation sensiblity.
  38943. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38944. */
  38945. gamepadAngularSensibility: number;
  38946. /**
  38947. * Defines the gamepad move sensiblity.
  38948. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38949. */
  38950. gamepadMoveSensibility: number;
  38951. /**
  38952. * 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,
  38953. * which still works and will still be found in many Playgrounds.
  38954. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38955. * @param name Define the name of the camera in the scene
  38956. * @param position Define the start position of the camera in the scene
  38957. * @param scene Define the scene the camera belongs to
  38958. */
  38959. constructor(name: string, position: Vector3, scene: Scene);
  38960. /**
  38961. * Gets the current object class name.
  38962. * @return the class name
  38963. */
  38964. getClassName(): string;
  38965. }
  38966. }
  38967. declare module "babylonjs/Cameras/gamepadCamera" {
  38968. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38969. import { Scene } from "babylonjs/scene";
  38970. import { Vector3 } from "babylonjs/Maths/math";
  38971. /**
  38972. * This represents a FPS type of camera. This is only here for back compat purpose.
  38973. * Please use the UniversalCamera instead as both are identical.
  38974. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38975. */
  38976. export class GamepadCamera extends UniversalCamera {
  38977. /**
  38978. * Instantiates a new Gamepad Camera
  38979. * This represents a FPS type of camera. This is only here for back compat purpose.
  38980. * Please use the UniversalCamera instead as both are identical.
  38981. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38982. * @param name Define the name of the camera in the scene
  38983. * @param position Define the start position of the camera in the scene
  38984. * @param scene Define the scene the camera belongs to
  38985. */
  38986. constructor(name: string, position: Vector3, scene: Scene);
  38987. /**
  38988. * Gets the current object class name.
  38989. * @return the class name
  38990. */
  38991. getClassName(): string;
  38992. }
  38993. }
  38994. declare module "babylonjs/Shaders/pass.fragment" {
  38995. /** @hidden */
  38996. export var passPixelShader: {
  38997. name: string;
  38998. shader: string;
  38999. };
  39000. }
  39001. declare module "babylonjs/Shaders/passCube.fragment" {
  39002. /** @hidden */
  39003. export var passCubePixelShader: {
  39004. name: string;
  39005. shader: string;
  39006. };
  39007. }
  39008. declare module "babylonjs/PostProcesses/passPostProcess" {
  39009. import { Nullable } from "babylonjs/types";
  39010. import { Camera } from "babylonjs/Cameras/camera";
  39011. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39012. import { Engine } from "babylonjs/Engines/engine";
  39013. import "babylonjs/Shaders/pass.fragment";
  39014. import "babylonjs/Shaders/passCube.fragment";
  39015. /**
  39016. * PassPostProcess which produces an output the same as it's input
  39017. */
  39018. export class PassPostProcess extends PostProcess {
  39019. /**
  39020. * Creates the PassPostProcess
  39021. * @param name The name of the effect.
  39022. * @param options The required width/height ratio to downsize to before computing the render pass.
  39023. * @param camera The camera to apply the render pass to.
  39024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39025. * @param engine The engine which the post process will be applied. (default: current engine)
  39026. * @param reusable If the post process can be reused on the same frame. (default: false)
  39027. * @param textureType The type of texture to be used when performing the post processing.
  39028. * @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)
  39029. */
  39030. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39031. }
  39032. /**
  39033. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39034. */
  39035. export class PassCubePostProcess extends PostProcess {
  39036. private _face;
  39037. /**
  39038. * Gets or sets the cube face to display.
  39039. * * 0 is +X
  39040. * * 1 is -X
  39041. * * 2 is +Y
  39042. * * 3 is -Y
  39043. * * 4 is +Z
  39044. * * 5 is -Z
  39045. */
  39046. face: number;
  39047. /**
  39048. * Creates the PassCubePostProcess
  39049. * @param name The name of the effect.
  39050. * @param options The required width/height ratio to downsize to before computing the render pass.
  39051. * @param camera The camera to apply the render pass to.
  39052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39053. * @param engine The engine which the post process will be applied. (default: current engine)
  39054. * @param reusable If the post process can be reused on the same frame. (default: false)
  39055. * @param textureType The type of texture to be used when performing the post processing.
  39056. * @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)
  39057. */
  39058. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39059. }
  39060. }
  39061. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39062. /** @hidden */
  39063. export var anaglyphPixelShader: {
  39064. name: string;
  39065. shader: string;
  39066. };
  39067. }
  39068. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39069. import { Engine } from "babylonjs/Engines/engine";
  39070. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39071. import { Camera } from "babylonjs/Cameras/camera";
  39072. import "babylonjs/Shaders/anaglyph.fragment";
  39073. /**
  39074. * Postprocess used to generate anaglyphic rendering
  39075. */
  39076. export class AnaglyphPostProcess extends PostProcess {
  39077. private _passedProcess;
  39078. /**
  39079. * Creates a new AnaglyphPostProcess
  39080. * @param name defines postprocess name
  39081. * @param options defines creation options or target ratio scale
  39082. * @param rigCameras defines cameras using this postprocess
  39083. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39084. * @param engine defines hosting engine
  39085. * @param reusable defines if the postprocess will be reused multiple times per frame
  39086. */
  39087. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39088. }
  39089. }
  39090. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39091. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39092. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39093. import { Scene } from "babylonjs/scene";
  39094. import { Vector3 } from "babylonjs/Maths/math";
  39095. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39096. /**
  39097. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39098. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39099. */
  39100. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39101. /**
  39102. * Creates a new AnaglyphArcRotateCamera
  39103. * @param name defines camera name
  39104. * @param alpha defines alpha angle (in radians)
  39105. * @param beta defines beta angle (in radians)
  39106. * @param radius defines radius
  39107. * @param target defines camera target
  39108. * @param interaxialDistance defines distance between each color axis
  39109. * @param scene defines the hosting scene
  39110. */
  39111. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39112. /**
  39113. * Gets camera class name
  39114. * @returns AnaglyphArcRotateCamera
  39115. */
  39116. getClassName(): string;
  39117. }
  39118. }
  39119. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39120. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39121. import { Scene } from "babylonjs/scene";
  39122. import { Vector3 } from "babylonjs/Maths/math";
  39123. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39124. /**
  39125. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39126. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39127. */
  39128. export class AnaglyphFreeCamera extends FreeCamera {
  39129. /**
  39130. * Creates a new AnaglyphFreeCamera
  39131. * @param name defines camera name
  39132. * @param position defines initial position
  39133. * @param interaxialDistance defines distance between each color axis
  39134. * @param scene defines the hosting scene
  39135. */
  39136. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39137. /**
  39138. * Gets camera class name
  39139. * @returns AnaglyphFreeCamera
  39140. */
  39141. getClassName(): string;
  39142. }
  39143. }
  39144. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39145. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39146. import { Scene } from "babylonjs/scene";
  39147. import { Vector3 } from "babylonjs/Maths/math";
  39148. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39149. /**
  39150. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39151. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39152. */
  39153. export class AnaglyphGamepadCamera extends GamepadCamera {
  39154. /**
  39155. * Creates a new AnaglyphGamepadCamera
  39156. * @param name defines camera name
  39157. * @param position defines initial position
  39158. * @param interaxialDistance defines distance between each color axis
  39159. * @param scene defines the hosting scene
  39160. */
  39161. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39162. /**
  39163. * Gets camera class name
  39164. * @returns AnaglyphGamepadCamera
  39165. */
  39166. getClassName(): string;
  39167. }
  39168. }
  39169. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39170. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39171. import { Scene } from "babylonjs/scene";
  39172. import { Vector3 } from "babylonjs/Maths/math";
  39173. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39174. /**
  39175. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39176. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39177. */
  39178. export class AnaglyphUniversalCamera extends UniversalCamera {
  39179. /**
  39180. * Creates a new AnaglyphUniversalCamera
  39181. * @param name defines camera name
  39182. * @param position defines initial position
  39183. * @param interaxialDistance defines distance between each color axis
  39184. * @param scene defines the hosting scene
  39185. */
  39186. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39187. /**
  39188. * Gets camera class name
  39189. * @returns AnaglyphUniversalCamera
  39190. */
  39191. getClassName(): string;
  39192. }
  39193. }
  39194. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39195. /** @hidden */
  39196. export var stereoscopicInterlacePixelShader: {
  39197. name: string;
  39198. shader: string;
  39199. };
  39200. }
  39201. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39202. import { Camera } from "babylonjs/Cameras/camera";
  39203. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39204. import { Engine } from "babylonjs/Engines/engine";
  39205. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39206. /**
  39207. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39208. */
  39209. export class StereoscopicInterlacePostProcess extends PostProcess {
  39210. private _stepSize;
  39211. private _passedProcess;
  39212. /**
  39213. * Initializes a StereoscopicInterlacePostProcess
  39214. * @param name The name of the effect.
  39215. * @param rigCameras The rig cameras to be appled to the post process
  39216. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39218. * @param engine The engine which the post process will be applied. (default: current engine)
  39219. * @param reusable If the post process can be reused on the same frame. (default: false)
  39220. */
  39221. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39222. }
  39223. }
  39224. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39225. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39226. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39227. import { Scene } from "babylonjs/scene";
  39228. import { Vector3 } from "babylonjs/Maths/math";
  39229. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39230. /**
  39231. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39232. * @see http://doc.babylonjs.com/features/cameras
  39233. */
  39234. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39235. /**
  39236. * Creates a new StereoscopicArcRotateCamera
  39237. * @param name defines camera name
  39238. * @param alpha defines alpha angle (in radians)
  39239. * @param beta defines beta angle (in radians)
  39240. * @param radius defines radius
  39241. * @param target defines camera target
  39242. * @param interaxialDistance defines distance between each color axis
  39243. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39244. * @param scene defines the hosting scene
  39245. */
  39246. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39247. /**
  39248. * Gets camera class name
  39249. * @returns StereoscopicArcRotateCamera
  39250. */
  39251. getClassName(): string;
  39252. }
  39253. }
  39254. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39255. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39256. import { Scene } from "babylonjs/scene";
  39257. import { Vector3 } from "babylonjs/Maths/math";
  39258. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39259. /**
  39260. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39261. * @see http://doc.babylonjs.com/features/cameras
  39262. */
  39263. export class StereoscopicFreeCamera extends FreeCamera {
  39264. /**
  39265. * Creates a new StereoscopicFreeCamera
  39266. * @param name defines camera name
  39267. * @param position defines initial position
  39268. * @param interaxialDistance defines distance between each color axis
  39269. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39270. * @param scene defines the hosting scene
  39271. */
  39272. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39273. /**
  39274. * Gets camera class name
  39275. * @returns StereoscopicFreeCamera
  39276. */
  39277. getClassName(): string;
  39278. }
  39279. }
  39280. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39281. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39282. import { Scene } from "babylonjs/scene";
  39283. import { Vector3 } from "babylonjs/Maths/math";
  39284. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39285. /**
  39286. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39287. * @see http://doc.babylonjs.com/features/cameras
  39288. */
  39289. export class StereoscopicGamepadCamera extends GamepadCamera {
  39290. /**
  39291. * Creates a new StereoscopicGamepadCamera
  39292. * @param name defines camera name
  39293. * @param position defines initial position
  39294. * @param interaxialDistance defines distance between each color axis
  39295. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39296. * @param scene defines the hosting scene
  39297. */
  39298. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39299. /**
  39300. * Gets camera class name
  39301. * @returns StereoscopicGamepadCamera
  39302. */
  39303. getClassName(): string;
  39304. }
  39305. }
  39306. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39307. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39308. import { Scene } from "babylonjs/scene";
  39309. import { Vector3 } from "babylonjs/Maths/math";
  39310. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39311. /**
  39312. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39313. * @see http://doc.babylonjs.com/features/cameras
  39314. */
  39315. export class StereoscopicUniversalCamera extends UniversalCamera {
  39316. /**
  39317. * Creates a new StereoscopicUniversalCamera
  39318. * @param name defines camera name
  39319. * @param position defines initial position
  39320. * @param interaxialDistance defines distance between each color axis
  39321. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39322. * @param scene defines the hosting scene
  39323. */
  39324. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39325. /**
  39326. * Gets camera class name
  39327. * @returns StereoscopicUniversalCamera
  39328. */
  39329. getClassName(): string;
  39330. }
  39331. }
  39332. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39333. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39334. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39335. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39336. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39337. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39338. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39339. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39340. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39341. }
  39342. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39343. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39344. import { Scene } from "babylonjs/scene";
  39345. import { Vector3 } from "babylonjs/Maths/math";
  39346. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39347. /**
  39348. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39349. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39350. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39351. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39352. */
  39353. export class VirtualJoysticksCamera extends FreeCamera {
  39354. /**
  39355. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39356. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39357. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39358. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39359. * @param name Define the name of the camera in the scene
  39360. * @param position Define the start position of the camera in the scene
  39361. * @param scene Define the scene the camera belongs to
  39362. */
  39363. constructor(name: string, position: Vector3, scene: Scene);
  39364. /**
  39365. * Gets the current object class name.
  39366. * @return the class name
  39367. */
  39368. getClassName(): string;
  39369. }
  39370. }
  39371. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39372. import { Matrix } from "babylonjs/Maths/math";
  39373. /**
  39374. * This represents all the required metrics to create a VR camera.
  39375. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39376. */
  39377. export class VRCameraMetrics {
  39378. /**
  39379. * Define the horizontal resolution off the screen.
  39380. */
  39381. hResolution: number;
  39382. /**
  39383. * Define the vertical resolution off the screen.
  39384. */
  39385. vResolution: number;
  39386. /**
  39387. * Define the horizontal screen size.
  39388. */
  39389. hScreenSize: number;
  39390. /**
  39391. * Define the vertical screen size.
  39392. */
  39393. vScreenSize: number;
  39394. /**
  39395. * Define the vertical screen center position.
  39396. */
  39397. vScreenCenter: number;
  39398. /**
  39399. * Define the distance of the eyes to the screen.
  39400. */
  39401. eyeToScreenDistance: number;
  39402. /**
  39403. * Define the distance between both lenses
  39404. */
  39405. lensSeparationDistance: number;
  39406. /**
  39407. * Define the distance between both viewer's eyes.
  39408. */
  39409. interpupillaryDistance: number;
  39410. /**
  39411. * Define the distortion factor of the VR postprocess.
  39412. * Please, touch with care.
  39413. */
  39414. distortionK: number[];
  39415. /**
  39416. * Define the chromatic aberration correction factors for the VR post process.
  39417. */
  39418. chromaAbCorrection: number[];
  39419. /**
  39420. * Define the scale factor of the post process.
  39421. * The smaller the better but the slower.
  39422. */
  39423. postProcessScaleFactor: number;
  39424. /**
  39425. * Define an offset for the lens center.
  39426. */
  39427. lensCenterOffset: number;
  39428. /**
  39429. * Define if the current vr camera should compensate the distortion of the lense or not.
  39430. */
  39431. compensateDistortion: boolean;
  39432. /**
  39433. * Defines if multiview should be enabled when rendering (Default: false)
  39434. */
  39435. multiviewEnabled: boolean;
  39436. /**
  39437. * Gets the rendering aspect ratio based on the provided resolutions.
  39438. */
  39439. readonly aspectRatio: number;
  39440. /**
  39441. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39442. */
  39443. readonly aspectRatioFov: number;
  39444. /**
  39445. * @hidden
  39446. */
  39447. readonly leftHMatrix: Matrix;
  39448. /**
  39449. * @hidden
  39450. */
  39451. readonly rightHMatrix: Matrix;
  39452. /**
  39453. * @hidden
  39454. */
  39455. readonly leftPreViewMatrix: Matrix;
  39456. /**
  39457. * @hidden
  39458. */
  39459. readonly rightPreViewMatrix: Matrix;
  39460. /**
  39461. * Get the default VRMetrics based on the most generic setup.
  39462. * @returns the default vr metrics
  39463. */
  39464. static GetDefault(): VRCameraMetrics;
  39465. }
  39466. }
  39467. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39468. /** @hidden */
  39469. export var vrDistortionCorrectionPixelShader: {
  39470. name: string;
  39471. shader: string;
  39472. };
  39473. }
  39474. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39475. import { Camera } from "babylonjs/Cameras/camera";
  39476. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39477. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39478. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39479. /**
  39480. * VRDistortionCorrectionPostProcess used for mobile VR
  39481. */
  39482. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39483. private _isRightEye;
  39484. private _distortionFactors;
  39485. private _postProcessScaleFactor;
  39486. private _lensCenterOffset;
  39487. private _scaleIn;
  39488. private _scaleFactor;
  39489. private _lensCenter;
  39490. /**
  39491. * Initializes the VRDistortionCorrectionPostProcess
  39492. * @param name The name of the effect.
  39493. * @param camera The camera to apply the render pass to.
  39494. * @param isRightEye If this is for the right eye distortion
  39495. * @param vrMetrics All the required metrics for the VR camera
  39496. */
  39497. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39498. }
  39499. }
  39500. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39501. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39502. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39503. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39504. import { Scene } from "babylonjs/scene";
  39505. import { Vector3 } from "babylonjs/Maths/math";
  39506. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39507. import "babylonjs/Cameras/RigModes/vrRigMode";
  39508. /**
  39509. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39510. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39511. */
  39512. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39513. /**
  39514. * Creates a new VRDeviceOrientationArcRotateCamera
  39515. * @param name defines camera name
  39516. * @param alpha defines the camera rotation along the logitudinal axis
  39517. * @param beta defines the camera rotation along the latitudinal axis
  39518. * @param radius defines the camera distance from its target
  39519. * @param target defines the camera target
  39520. * @param scene defines the scene the camera belongs to
  39521. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39522. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39523. */
  39524. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39525. /**
  39526. * Gets camera class name
  39527. * @returns VRDeviceOrientationArcRotateCamera
  39528. */
  39529. getClassName(): string;
  39530. }
  39531. }
  39532. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39533. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39534. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39535. import { Scene } from "babylonjs/scene";
  39536. import { Vector3 } from "babylonjs/Maths/math";
  39537. import "babylonjs/Cameras/RigModes/vrRigMode";
  39538. /**
  39539. * Camera used to simulate VR rendering (based on FreeCamera)
  39540. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39541. */
  39542. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39543. /**
  39544. * Creates a new VRDeviceOrientationFreeCamera
  39545. * @param name defines camera name
  39546. * @param position defines the start position of the camera
  39547. * @param scene defines the scene the camera belongs to
  39548. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39549. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39550. */
  39551. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39552. /**
  39553. * Gets camera class name
  39554. * @returns VRDeviceOrientationFreeCamera
  39555. */
  39556. getClassName(): string;
  39557. }
  39558. }
  39559. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39560. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39561. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39562. import { Scene } from "babylonjs/scene";
  39563. import { Vector3 } from "babylonjs/Maths/math";
  39564. import "babylonjs/Gamepads/gamepadSceneComponent";
  39565. /**
  39566. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39567. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39568. */
  39569. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39570. /**
  39571. * Creates a new VRDeviceOrientationGamepadCamera
  39572. * @param name defines camera name
  39573. * @param position defines the start position of the camera
  39574. * @param scene defines the scene the camera belongs to
  39575. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39576. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39577. */
  39578. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39579. /**
  39580. * Gets camera class name
  39581. * @returns VRDeviceOrientationGamepadCamera
  39582. */
  39583. getClassName(): string;
  39584. }
  39585. }
  39586. declare module "babylonjs/Materials/pushMaterial" {
  39587. import { Nullable } from "babylonjs/types";
  39588. import { Scene } from "babylonjs/scene";
  39589. import { Matrix } from "babylonjs/Maths/math";
  39590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39591. import { Mesh } from "babylonjs/Meshes/mesh";
  39592. import { Material } from "babylonjs/Materials/material";
  39593. import { Effect } from "babylonjs/Materials/effect";
  39594. /**
  39595. * Base class of materials working in push mode in babylon JS
  39596. * @hidden
  39597. */
  39598. export class PushMaterial extends Material {
  39599. protected _activeEffect: Effect;
  39600. protected _normalMatrix: Matrix;
  39601. /**
  39602. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39603. * This means that the material can keep using a previous shader while a new one is being compiled.
  39604. * This is mostly used when shader parallel compilation is supported (true by default)
  39605. */
  39606. allowShaderHotSwapping: boolean;
  39607. constructor(name: string, scene: Scene);
  39608. getEffect(): Effect;
  39609. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39610. /**
  39611. * Binds the given world matrix to the active effect
  39612. *
  39613. * @param world the matrix to bind
  39614. */
  39615. bindOnlyWorldMatrix(world: Matrix): void;
  39616. /**
  39617. * Binds the given normal matrix to the active effect
  39618. *
  39619. * @param normalMatrix the matrix to bind
  39620. */
  39621. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39622. bind(world: Matrix, mesh?: Mesh): void;
  39623. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39624. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39625. }
  39626. }
  39627. declare module "babylonjs/Materials/materialFlags" {
  39628. /**
  39629. * This groups all the flags used to control the materials channel.
  39630. */
  39631. export class MaterialFlags {
  39632. private static _DiffuseTextureEnabled;
  39633. /**
  39634. * Are diffuse textures enabled in the application.
  39635. */
  39636. static DiffuseTextureEnabled: boolean;
  39637. private static _AmbientTextureEnabled;
  39638. /**
  39639. * Are ambient textures enabled in the application.
  39640. */
  39641. static AmbientTextureEnabled: boolean;
  39642. private static _OpacityTextureEnabled;
  39643. /**
  39644. * Are opacity textures enabled in the application.
  39645. */
  39646. static OpacityTextureEnabled: boolean;
  39647. private static _ReflectionTextureEnabled;
  39648. /**
  39649. * Are reflection textures enabled in the application.
  39650. */
  39651. static ReflectionTextureEnabled: boolean;
  39652. private static _EmissiveTextureEnabled;
  39653. /**
  39654. * Are emissive textures enabled in the application.
  39655. */
  39656. static EmissiveTextureEnabled: boolean;
  39657. private static _SpecularTextureEnabled;
  39658. /**
  39659. * Are specular textures enabled in the application.
  39660. */
  39661. static SpecularTextureEnabled: boolean;
  39662. private static _BumpTextureEnabled;
  39663. /**
  39664. * Are bump textures enabled in the application.
  39665. */
  39666. static BumpTextureEnabled: boolean;
  39667. private static _LightmapTextureEnabled;
  39668. /**
  39669. * Are lightmap textures enabled in the application.
  39670. */
  39671. static LightmapTextureEnabled: boolean;
  39672. private static _RefractionTextureEnabled;
  39673. /**
  39674. * Are refraction textures enabled in the application.
  39675. */
  39676. static RefractionTextureEnabled: boolean;
  39677. private static _ColorGradingTextureEnabled;
  39678. /**
  39679. * Are color grading textures enabled in the application.
  39680. */
  39681. static ColorGradingTextureEnabled: boolean;
  39682. private static _FresnelEnabled;
  39683. /**
  39684. * Are fresnels enabled in the application.
  39685. */
  39686. static FresnelEnabled: boolean;
  39687. private static _ClearCoatTextureEnabled;
  39688. /**
  39689. * Are clear coat textures enabled in the application.
  39690. */
  39691. static ClearCoatTextureEnabled: boolean;
  39692. private static _ClearCoatBumpTextureEnabled;
  39693. /**
  39694. * Are clear coat bump textures enabled in the application.
  39695. */
  39696. static ClearCoatBumpTextureEnabled: boolean;
  39697. private static _ClearCoatTintTextureEnabled;
  39698. /**
  39699. * Are clear coat tint textures enabled in the application.
  39700. */
  39701. static ClearCoatTintTextureEnabled: boolean;
  39702. private static _SheenTextureEnabled;
  39703. /**
  39704. * Are sheen textures enabled in the application.
  39705. */
  39706. static SheenTextureEnabled: boolean;
  39707. private static _AnisotropicTextureEnabled;
  39708. /**
  39709. * Are anisotropic textures enabled in the application.
  39710. */
  39711. static AnisotropicTextureEnabled: boolean;
  39712. private static _ThicknessTextureEnabled;
  39713. /**
  39714. * Are thickness textures enabled in the application.
  39715. */
  39716. static ThicknessTextureEnabled: boolean;
  39717. }
  39718. }
  39719. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39720. /** @hidden */
  39721. export var defaultFragmentDeclaration: {
  39722. name: string;
  39723. shader: string;
  39724. };
  39725. }
  39726. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39727. /** @hidden */
  39728. export var defaultUboDeclaration: {
  39729. name: string;
  39730. shader: string;
  39731. };
  39732. }
  39733. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39734. /** @hidden */
  39735. export var lightFragmentDeclaration: {
  39736. name: string;
  39737. shader: string;
  39738. };
  39739. }
  39740. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39741. /** @hidden */
  39742. export var lightUboDeclaration: {
  39743. name: string;
  39744. shader: string;
  39745. };
  39746. }
  39747. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39748. /** @hidden */
  39749. export var lightsFragmentFunctions: {
  39750. name: string;
  39751. shader: string;
  39752. };
  39753. }
  39754. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39755. /** @hidden */
  39756. export var shadowsFragmentFunctions: {
  39757. name: string;
  39758. shader: string;
  39759. };
  39760. }
  39761. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39762. /** @hidden */
  39763. export var fresnelFunction: {
  39764. name: string;
  39765. shader: string;
  39766. };
  39767. }
  39768. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39769. /** @hidden */
  39770. export var reflectionFunction: {
  39771. name: string;
  39772. shader: string;
  39773. };
  39774. }
  39775. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39776. /** @hidden */
  39777. export var bumpFragmentFunctions: {
  39778. name: string;
  39779. shader: string;
  39780. };
  39781. }
  39782. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39783. /** @hidden */
  39784. export var logDepthDeclaration: {
  39785. name: string;
  39786. shader: string;
  39787. };
  39788. }
  39789. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39790. /** @hidden */
  39791. export var bumpFragment: {
  39792. name: string;
  39793. shader: string;
  39794. };
  39795. }
  39796. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39797. /** @hidden */
  39798. export var depthPrePass: {
  39799. name: string;
  39800. shader: string;
  39801. };
  39802. }
  39803. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39804. /** @hidden */
  39805. export var lightFragment: {
  39806. name: string;
  39807. shader: string;
  39808. };
  39809. }
  39810. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39811. /** @hidden */
  39812. export var logDepthFragment: {
  39813. name: string;
  39814. shader: string;
  39815. };
  39816. }
  39817. declare module "babylonjs/Shaders/default.fragment" {
  39818. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39819. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39821. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39822. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39823. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39824. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39825. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39826. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39827. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39828. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39829. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39830. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39831. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39832. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39833. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39834. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39835. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39836. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39837. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39838. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39839. /** @hidden */
  39840. export var defaultPixelShader: {
  39841. name: string;
  39842. shader: string;
  39843. };
  39844. }
  39845. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39846. /** @hidden */
  39847. export var defaultVertexDeclaration: {
  39848. name: string;
  39849. shader: string;
  39850. };
  39851. }
  39852. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39853. /** @hidden */
  39854. export var bumpVertexDeclaration: {
  39855. name: string;
  39856. shader: string;
  39857. };
  39858. }
  39859. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39860. /** @hidden */
  39861. export var bumpVertex: {
  39862. name: string;
  39863. shader: string;
  39864. };
  39865. }
  39866. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39867. /** @hidden */
  39868. export var fogVertex: {
  39869. name: string;
  39870. shader: string;
  39871. };
  39872. }
  39873. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39874. /** @hidden */
  39875. export var shadowsVertex: {
  39876. name: string;
  39877. shader: string;
  39878. };
  39879. }
  39880. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39881. /** @hidden */
  39882. export var pointCloudVertex: {
  39883. name: string;
  39884. shader: string;
  39885. };
  39886. }
  39887. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39888. /** @hidden */
  39889. export var logDepthVertex: {
  39890. name: string;
  39891. shader: string;
  39892. };
  39893. }
  39894. declare module "babylonjs/Shaders/default.vertex" {
  39895. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39896. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39897. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39898. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39899. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39900. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39901. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39902. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39903. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39904. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39905. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39907. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39908. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39909. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39910. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39911. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39912. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39913. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39914. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39915. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39916. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39917. /** @hidden */
  39918. export var defaultVertexShader: {
  39919. name: string;
  39920. shader: string;
  39921. };
  39922. }
  39923. declare module "babylonjs/Materials/standardMaterial" {
  39924. import { SmartArray } from "babylonjs/Misc/smartArray";
  39925. import { IAnimatable } from "babylonjs/Misc/tools";
  39926. import { Nullable } from "babylonjs/types";
  39927. import { Scene } from "babylonjs/scene";
  39928. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39929. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39931. import { Mesh } from "babylonjs/Meshes/mesh";
  39932. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39933. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39934. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39935. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39936. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39937. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39938. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39939. import "babylonjs/Shaders/default.fragment";
  39940. import "babylonjs/Shaders/default.vertex";
  39941. /** @hidden */
  39942. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39943. MAINUV1: boolean;
  39944. MAINUV2: boolean;
  39945. DIFFUSE: boolean;
  39946. DIFFUSEDIRECTUV: number;
  39947. AMBIENT: boolean;
  39948. AMBIENTDIRECTUV: number;
  39949. OPACITY: boolean;
  39950. OPACITYDIRECTUV: number;
  39951. OPACITYRGB: boolean;
  39952. REFLECTION: boolean;
  39953. EMISSIVE: boolean;
  39954. EMISSIVEDIRECTUV: number;
  39955. SPECULAR: boolean;
  39956. SPECULARDIRECTUV: number;
  39957. BUMP: boolean;
  39958. BUMPDIRECTUV: number;
  39959. PARALLAX: boolean;
  39960. PARALLAXOCCLUSION: boolean;
  39961. SPECULAROVERALPHA: boolean;
  39962. CLIPPLANE: boolean;
  39963. CLIPPLANE2: boolean;
  39964. CLIPPLANE3: boolean;
  39965. CLIPPLANE4: boolean;
  39966. ALPHATEST: boolean;
  39967. DEPTHPREPASS: boolean;
  39968. ALPHAFROMDIFFUSE: boolean;
  39969. POINTSIZE: boolean;
  39970. FOG: boolean;
  39971. SPECULARTERM: boolean;
  39972. DIFFUSEFRESNEL: boolean;
  39973. OPACITYFRESNEL: boolean;
  39974. REFLECTIONFRESNEL: boolean;
  39975. REFRACTIONFRESNEL: boolean;
  39976. EMISSIVEFRESNEL: boolean;
  39977. FRESNEL: boolean;
  39978. NORMAL: boolean;
  39979. UV1: boolean;
  39980. UV2: boolean;
  39981. VERTEXCOLOR: boolean;
  39982. VERTEXALPHA: boolean;
  39983. NUM_BONE_INFLUENCERS: number;
  39984. BonesPerMesh: number;
  39985. BONETEXTURE: boolean;
  39986. INSTANCES: boolean;
  39987. GLOSSINESS: boolean;
  39988. ROUGHNESS: boolean;
  39989. EMISSIVEASILLUMINATION: boolean;
  39990. LINKEMISSIVEWITHDIFFUSE: boolean;
  39991. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39992. LIGHTMAP: boolean;
  39993. LIGHTMAPDIRECTUV: number;
  39994. OBJECTSPACE_NORMALMAP: boolean;
  39995. USELIGHTMAPASSHADOWMAP: boolean;
  39996. REFLECTIONMAP_3D: boolean;
  39997. REFLECTIONMAP_SPHERICAL: boolean;
  39998. REFLECTIONMAP_PLANAR: boolean;
  39999. REFLECTIONMAP_CUBIC: boolean;
  40000. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40001. REFLECTIONMAP_PROJECTION: boolean;
  40002. REFLECTIONMAP_SKYBOX: boolean;
  40003. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40004. REFLECTIONMAP_EXPLICIT: boolean;
  40005. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40006. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40007. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40008. INVERTCUBICMAP: boolean;
  40009. LOGARITHMICDEPTH: boolean;
  40010. REFRACTION: boolean;
  40011. REFRACTIONMAP_3D: boolean;
  40012. REFLECTIONOVERALPHA: boolean;
  40013. TWOSIDEDLIGHTING: boolean;
  40014. SHADOWFLOAT: boolean;
  40015. MORPHTARGETS: boolean;
  40016. MORPHTARGETS_NORMAL: boolean;
  40017. MORPHTARGETS_TANGENT: boolean;
  40018. NUM_MORPH_INFLUENCERS: number;
  40019. NONUNIFORMSCALING: boolean;
  40020. PREMULTIPLYALPHA: boolean;
  40021. IMAGEPROCESSING: boolean;
  40022. VIGNETTE: boolean;
  40023. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40024. VIGNETTEBLENDMODEOPAQUE: boolean;
  40025. TONEMAPPING: boolean;
  40026. TONEMAPPING_ACES: boolean;
  40027. CONTRAST: boolean;
  40028. COLORCURVES: boolean;
  40029. COLORGRADING: boolean;
  40030. COLORGRADING3D: boolean;
  40031. SAMPLER3DGREENDEPTH: boolean;
  40032. SAMPLER3DBGRMAP: boolean;
  40033. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40034. MULTIVIEW: boolean;
  40035. /**
  40036. * If the reflection texture on this material is in linear color space
  40037. * @hidden
  40038. */
  40039. IS_REFLECTION_LINEAR: boolean;
  40040. /**
  40041. * If the refraction texture on this material is in linear color space
  40042. * @hidden
  40043. */
  40044. IS_REFRACTION_LINEAR: boolean;
  40045. EXPOSURE: boolean;
  40046. constructor();
  40047. setReflectionMode(modeToEnable: string): void;
  40048. }
  40049. /**
  40050. * This is the default material used in Babylon. It is the best trade off between quality
  40051. * and performances.
  40052. * @see http://doc.babylonjs.com/babylon101/materials
  40053. */
  40054. export class StandardMaterial extends PushMaterial {
  40055. private _diffuseTexture;
  40056. /**
  40057. * The basic texture of the material as viewed under a light.
  40058. */
  40059. diffuseTexture: Nullable<BaseTexture>;
  40060. private _ambientTexture;
  40061. /**
  40062. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40063. */
  40064. ambientTexture: Nullable<BaseTexture>;
  40065. private _opacityTexture;
  40066. /**
  40067. * Define the transparency of the material from a texture.
  40068. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40069. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40070. */
  40071. opacityTexture: Nullable<BaseTexture>;
  40072. private _reflectionTexture;
  40073. /**
  40074. * Define the texture used to display the reflection.
  40075. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40076. */
  40077. reflectionTexture: Nullable<BaseTexture>;
  40078. private _emissiveTexture;
  40079. /**
  40080. * Define texture of the material as if self lit.
  40081. * This will be mixed in the final result even in the absence of light.
  40082. */
  40083. emissiveTexture: Nullable<BaseTexture>;
  40084. private _specularTexture;
  40085. /**
  40086. * Define how the color and intensity of the highlight given by the light in the material.
  40087. */
  40088. specularTexture: Nullable<BaseTexture>;
  40089. private _bumpTexture;
  40090. /**
  40091. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40092. * 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.
  40093. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40094. */
  40095. bumpTexture: Nullable<BaseTexture>;
  40096. private _lightmapTexture;
  40097. /**
  40098. * Complex lighting can be computationally expensive to compute at runtime.
  40099. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40100. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40101. */
  40102. lightmapTexture: Nullable<BaseTexture>;
  40103. private _refractionTexture;
  40104. /**
  40105. * Define the texture used to display the refraction.
  40106. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40107. */
  40108. refractionTexture: Nullable<BaseTexture>;
  40109. /**
  40110. * The color of the material lit by the environmental background lighting.
  40111. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40112. */
  40113. ambientColor: Color3;
  40114. /**
  40115. * The basic color of the material as viewed under a light.
  40116. */
  40117. diffuseColor: Color3;
  40118. /**
  40119. * Define how the color and intensity of the highlight given by the light in the material.
  40120. */
  40121. specularColor: Color3;
  40122. /**
  40123. * Define the color of the material as if self lit.
  40124. * This will be mixed in the final result even in the absence of light.
  40125. */
  40126. emissiveColor: Color3;
  40127. /**
  40128. * Defines how sharp are the highlights in the material.
  40129. * The bigger the value the sharper giving a more glossy feeling to the result.
  40130. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40131. */
  40132. specularPower: number;
  40133. private _useAlphaFromDiffuseTexture;
  40134. /**
  40135. * Does the transparency come from the diffuse texture alpha channel.
  40136. */
  40137. useAlphaFromDiffuseTexture: boolean;
  40138. private _useEmissiveAsIllumination;
  40139. /**
  40140. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40141. */
  40142. useEmissiveAsIllumination: boolean;
  40143. private _linkEmissiveWithDiffuse;
  40144. /**
  40145. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40146. * the emissive level when the final color is close to one.
  40147. */
  40148. linkEmissiveWithDiffuse: boolean;
  40149. private _useSpecularOverAlpha;
  40150. /**
  40151. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40152. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40153. */
  40154. useSpecularOverAlpha: boolean;
  40155. private _useReflectionOverAlpha;
  40156. /**
  40157. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40158. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40159. */
  40160. useReflectionOverAlpha: boolean;
  40161. private _disableLighting;
  40162. /**
  40163. * Does lights from the scene impacts this material.
  40164. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40165. */
  40166. disableLighting: boolean;
  40167. private _useObjectSpaceNormalMap;
  40168. /**
  40169. * Allows using an object space normal map (instead of tangent space).
  40170. */
  40171. useObjectSpaceNormalMap: boolean;
  40172. private _useParallax;
  40173. /**
  40174. * Is parallax enabled or not.
  40175. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40176. */
  40177. useParallax: boolean;
  40178. private _useParallaxOcclusion;
  40179. /**
  40180. * Is parallax occlusion enabled or not.
  40181. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40182. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40183. */
  40184. useParallaxOcclusion: boolean;
  40185. /**
  40186. * 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.
  40187. */
  40188. parallaxScaleBias: number;
  40189. private _roughness;
  40190. /**
  40191. * Helps to define how blurry the reflections should appears in the material.
  40192. */
  40193. roughness: number;
  40194. /**
  40195. * In case of refraction, define the value of the indice of refraction.
  40196. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40197. */
  40198. indexOfRefraction: number;
  40199. /**
  40200. * Invert the refraction texture alongside the y axis.
  40201. * It can be useful with procedural textures or probe for instance.
  40202. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40203. */
  40204. invertRefractionY: boolean;
  40205. /**
  40206. * Defines the alpha limits in alpha test mode.
  40207. */
  40208. alphaCutOff: number;
  40209. private _useLightmapAsShadowmap;
  40210. /**
  40211. * In case of light mapping, define whether the map contains light or shadow informations.
  40212. */
  40213. useLightmapAsShadowmap: boolean;
  40214. private _diffuseFresnelParameters;
  40215. /**
  40216. * Define the diffuse fresnel parameters of the material.
  40217. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40218. */
  40219. diffuseFresnelParameters: FresnelParameters;
  40220. private _opacityFresnelParameters;
  40221. /**
  40222. * Define the opacity fresnel parameters of the material.
  40223. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40224. */
  40225. opacityFresnelParameters: FresnelParameters;
  40226. private _reflectionFresnelParameters;
  40227. /**
  40228. * Define the reflection fresnel parameters of the material.
  40229. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40230. */
  40231. reflectionFresnelParameters: FresnelParameters;
  40232. private _refractionFresnelParameters;
  40233. /**
  40234. * Define the refraction fresnel parameters of the material.
  40235. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40236. */
  40237. refractionFresnelParameters: FresnelParameters;
  40238. private _emissiveFresnelParameters;
  40239. /**
  40240. * Define the emissive fresnel parameters of the material.
  40241. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40242. */
  40243. emissiveFresnelParameters: FresnelParameters;
  40244. private _useReflectionFresnelFromSpecular;
  40245. /**
  40246. * If true automatically deducts the fresnels values from the material specularity.
  40247. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40248. */
  40249. useReflectionFresnelFromSpecular: boolean;
  40250. private _useGlossinessFromSpecularMapAlpha;
  40251. /**
  40252. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40253. */
  40254. useGlossinessFromSpecularMapAlpha: boolean;
  40255. private _maxSimultaneousLights;
  40256. /**
  40257. * Defines the maximum number of lights that can be used in the material
  40258. */
  40259. maxSimultaneousLights: number;
  40260. private _invertNormalMapX;
  40261. /**
  40262. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40263. */
  40264. invertNormalMapX: boolean;
  40265. private _invertNormalMapY;
  40266. /**
  40267. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40268. */
  40269. invertNormalMapY: boolean;
  40270. private _twoSidedLighting;
  40271. /**
  40272. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40273. */
  40274. twoSidedLighting: boolean;
  40275. /**
  40276. * Default configuration related to image processing available in the standard Material.
  40277. */
  40278. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40279. /**
  40280. * Gets the image processing configuration used either in this material.
  40281. */
  40282. /**
  40283. * Sets the Default image processing configuration used either in the this material.
  40284. *
  40285. * If sets to null, the scene one is in use.
  40286. */
  40287. imageProcessingConfiguration: ImageProcessingConfiguration;
  40288. /**
  40289. * Keep track of the image processing observer to allow dispose and replace.
  40290. */
  40291. private _imageProcessingObserver;
  40292. /**
  40293. * Attaches a new image processing configuration to the Standard Material.
  40294. * @param configuration
  40295. */
  40296. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40297. /**
  40298. * Gets wether the color curves effect is enabled.
  40299. */
  40300. /**
  40301. * Sets wether the color curves effect is enabled.
  40302. */
  40303. cameraColorCurvesEnabled: boolean;
  40304. /**
  40305. * Gets wether the color grading effect is enabled.
  40306. */
  40307. /**
  40308. * Gets wether the color grading effect is enabled.
  40309. */
  40310. cameraColorGradingEnabled: boolean;
  40311. /**
  40312. * Gets wether tonemapping is enabled or not.
  40313. */
  40314. /**
  40315. * Sets wether tonemapping is enabled or not
  40316. */
  40317. cameraToneMappingEnabled: boolean;
  40318. /**
  40319. * The camera exposure used on this material.
  40320. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40321. * This corresponds to a photographic exposure.
  40322. */
  40323. /**
  40324. * The camera exposure used on this material.
  40325. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40326. * This corresponds to a photographic exposure.
  40327. */
  40328. cameraExposure: number;
  40329. /**
  40330. * Gets The camera contrast used on this material.
  40331. */
  40332. /**
  40333. * Sets The camera contrast used on this material.
  40334. */
  40335. cameraContrast: number;
  40336. /**
  40337. * Gets the Color Grading 2D Lookup Texture.
  40338. */
  40339. /**
  40340. * Sets the Color Grading 2D Lookup Texture.
  40341. */
  40342. cameraColorGradingTexture: Nullable<BaseTexture>;
  40343. /**
  40344. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40345. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40346. * 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;
  40347. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40348. */
  40349. /**
  40350. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40351. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40352. * 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;
  40353. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40354. */
  40355. cameraColorCurves: Nullable<ColorCurves>;
  40356. /**
  40357. * Custom callback helping to override the default shader used in the material.
  40358. */
  40359. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40360. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40361. protected _worldViewProjectionMatrix: Matrix;
  40362. protected _globalAmbientColor: Color3;
  40363. protected _useLogarithmicDepth: boolean;
  40364. /**
  40365. * Instantiates a new standard material.
  40366. * This is the default material used in Babylon. It is the best trade off between quality
  40367. * and performances.
  40368. * @see http://doc.babylonjs.com/babylon101/materials
  40369. * @param name Define the name of the material in the scene
  40370. * @param scene Define the scene the material belong to
  40371. */
  40372. constructor(name: string, scene: Scene);
  40373. /**
  40374. * Gets a boolean indicating that current material needs to register RTT
  40375. */
  40376. readonly hasRenderTargetTextures: boolean;
  40377. /**
  40378. * Gets the current class name of the material e.g. "StandardMaterial"
  40379. * Mainly use in serialization.
  40380. * @returns the class name
  40381. */
  40382. getClassName(): string;
  40383. /**
  40384. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40385. * You can try switching to logarithmic depth.
  40386. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40387. */
  40388. useLogarithmicDepth: boolean;
  40389. /**
  40390. * Specifies if the material will require alpha blending
  40391. * @returns a boolean specifying if alpha blending is needed
  40392. */
  40393. needAlphaBlending(): boolean;
  40394. /**
  40395. * Specifies if this material should be rendered in alpha test mode
  40396. * @returns a boolean specifying if an alpha test is needed.
  40397. */
  40398. needAlphaTesting(): boolean;
  40399. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40400. /**
  40401. * Get the texture used for alpha test purpose.
  40402. * @returns the diffuse texture in case of the standard material.
  40403. */
  40404. getAlphaTestTexture(): Nullable<BaseTexture>;
  40405. /**
  40406. * Get if the submesh is ready to be used and all its information available.
  40407. * Child classes can use it to update shaders
  40408. * @param mesh defines the mesh to check
  40409. * @param subMesh defines which submesh to check
  40410. * @param useInstances specifies that instances should be used
  40411. * @returns a boolean indicating that the submesh is ready or not
  40412. */
  40413. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40414. /**
  40415. * Builds the material UBO layouts.
  40416. * Used internally during the effect preparation.
  40417. */
  40418. buildUniformLayout(): void;
  40419. /**
  40420. * Unbinds the material from the mesh
  40421. */
  40422. unbind(): void;
  40423. /**
  40424. * Binds the submesh to this material by preparing the effect and shader to draw
  40425. * @param world defines the world transformation matrix
  40426. * @param mesh defines the mesh containing the submesh
  40427. * @param subMesh defines the submesh to bind the material to
  40428. */
  40429. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40430. /**
  40431. * Get the list of animatables in the material.
  40432. * @returns the list of animatables object used in the material
  40433. */
  40434. getAnimatables(): IAnimatable[];
  40435. /**
  40436. * Gets the active textures from the material
  40437. * @returns an array of textures
  40438. */
  40439. getActiveTextures(): BaseTexture[];
  40440. /**
  40441. * Specifies if the material uses a texture
  40442. * @param texture defines the texture to check against the material
  40443. * @returns a boolean specifying if the material uses the texture
  40444. */
  40445. hasTexture(texture: BaseTexture): boolean;
  40446. /**
  40447. * Disposes the material
  40448. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40449. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40450. */
  40451. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40452. /**
  40453. * Makes a duplicate of the material, and gives it a new name
  40454. * @param name defines the new name for the duplicated material
  40455. * @returns the cloned material
  40456. */
  40457. clone(name: string): StandardMaterial;
  40458. /**
  40459. * Serializes this material in a JSON representation
  40460. * @returns the serialized material object
  40461. */
  40462. serialize(): any;
  40463. /**
  40464. * Creates a standard material from parsed material data
  40465. * @param source defines the JSON representation of the material
  40466. * @param scene defines the hosting scene
  40467. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40468. * @returns a new standard material
  40469. */
  40470. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40471. /**
  40472. * Are diffuse textures enabled in the application.
  40473. */
  40474. static DiffuseTextureEnabled: boolean;
  40475. /**
  40476. * Are ambient textures enabled in the application.
  40477. */
  40478. static AmbientTextureEnabled: boolean;
  40479. /**
  40480. * Are opacity textures enabled in the application.
  40481. */
  40482. static OpacityTextureEnabled: boolean;
  40483. /**
  40484. * Are reflection textures enabled in the application.
  40485. */
  40486. static ReflectionTextureEnabled: boolean;
  40487. /**
  40488. * Are emissive textures enabled in the application.
  40489. */
  40490. static EmissiveTextureEnabled: boolean;
  40491. /**
  40492. * Are specular textures enabled in the application.
  40493. */
  40494. static SpecularTextureEnabled: boolean;
  40495. /**
  40496. * Are bump textures enabled in the application.
  40497. */
  40498. static BumpTextureEnabled: boolean;
  40499. /**
  40500. * Are lightmap textures enabled in the application.
  40501. */
  40502. static LightmapTextureEnabled: boolean;
  40503. /**
  40504. * Are refraction textures enabled in the application.
  40505. */
  40506. static RefractionTextureEnabled: boolean;
  40507. /**
  40508. * Are color grading textures enabled in the application.
  40509. */
  40510. static ColorGradingTextureEnabled: boolean;
  40511. /**
  40512. * Are fresnels enabled in the application.
  40513. */
  40514. static FresnelEnabled: boolean;
  40515. }
  40516. }
  40517. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40518. import { Scene } from "babylonjs/scene";
  40519. import { Texture } from "babylonjs/Materials/Textures/texture";
  40520. /**
  40521. * A class extending Texture allowing drawing on a texture
  40522. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40523. */
  40524. export class DynamicTexture extends Texture {
  40525. private _generateMipMaps;
  40526. private _canvas;
  40527. private _context;
  40528. private _engine;
  40529. /**
  40530. * Creates a DynamicTexture
  40531. * @param name defines the name of the texture
  40532. * @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
  40533. * @param scene defines the scene where you want the texture
  40534. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40535. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40536. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40537. */
  40538. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40539. /**
  40540. * Get the current class name of the texture useful for serialization or dynamic coding.
  40541. * @returns "DynamicTexture"
  40542. */
  40543. getClassName(): string;
  40544. /**
  40545. * Gets the current state of canRescale
  40546. */
  40547. readonly canRescale: boolean;
  40548. private _recreate;
  40549. /**
  40550. * Scales the texture
  40551. * @param ratio the scale factor to apply to both width and height
  40552. */
  40553. scale(ratio: number): void;
  40554. /**
  40555. * Resizes the texture
  40556. * @param width the new width
  40557. * @param height the new height
  40558. */
  40559. scaleTo(width: number, height: number): void;
  40560. /**
  40561. * Gets the context of the canvas used by the texture
  40562. * @returns the canvas context of the dynamic texture
  40563. */
  40564. getContext(): CanvasRenderingContext2D;
  40565. /**
  40566. * Clears the texture
  40567. */
  40568. clear(): void;
  40569. /**
  40570. * Updates the texture
  40571. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40572. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40573. */
  40574. update(invertY?: boolean, premulAlpha?: boolean): void;
  40575. /**
  40576. * Draws text onto the texture
  40577. * @param text defines the text to be drawn
  40578. * @param x defines the placement of the text from the left
  40579. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40580. * @param font defines the font to be used with font-style, font-size, font-name
  40581. * @param color defines the color used for the text
  40582. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40583. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40584. * @param update defines whether texture is immediately update (default is true)
  40585. */
  40586. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40587. /**
  40588. * Clones the texture
  40589. * @returns the clone of the texture.
  40590. */
  40591. clone(): DynamicTexture;
  40592. /**
  40593. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40594. * @returns a serialized dynamic texture object
  40595. */
  40596. serialize(): any;
  40597. /** @hidden */
  40598. _rebuild(): void;
  40599. }
  40600. }
  40601. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40602. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40604. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40605. /** @hidden */
  40606. export var imageProcessingPixelShader: {
  40607. name: string;
  40608. shader: string;
  40609. };
  40610. }
  40611. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40612. import { Nullable } from "babylonjs/types";
  40613. import { Color4 } from "babylonjs/Maths/math";
  40614. import { Camera } from "babylonjs/Cameras/camera";
  40615. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40616. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40617. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40618. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40619. import { Engine } from "babylonjs/Engines/engine";
  40620. import "babylonjs/Shaders/imageProcessing.fragment";
  40621. import "babylonjs/Shaders/postprocess.vertex";
  40622. /**
  40623. * ImageProcessingPostProcess
  40624. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40625. */
  40626. export class ImageProcessingPostProcess extends PostProcess {
  40627. /**
  40628. * Default configuration related to image processing available in the PBR Material.
  40629. */
  40630. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40631. /**
  40632. * Gets the image processing configuration used either in this material.
  40633. */
  40634. /**
  40635. * Sets the Default image processing configuration used either in the this material.
  40636. *
  40637. * If sets to null, the scene one is in use.
  40638. */
  40639. imageProcessingConfiguration: ImageProcessingConfiguration;
  40640. /**
  40641. * Keep track of the image processing observer to allow dispose and replace.
  40642. */
  40643. private _imageProcessingObserver;
  40644. /**
  40645. * Attaches a new image processing configuration to the PBR Material.
  40646. * @param configuration
  40647. */
  40648. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40649. /**
  40650. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40651. */
  40652. /**
  40653. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40654. */
  40655. colorCurves: Nullable<ColorCurves>;
  40656. /**
  40657. * Gets wether the color curves effect is enabled.
  40658. */
  40659. /**
  40660. * Sets wether the color curves effect is enabled.
  40661. */
  40662. colorCurvesEnabled: boolean;
  40663. /**
  40664. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40665. */
  40666. /**
  40667. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40668. */
  40669. colorGradingTexture: Nullable<BaseTexture>;
  40670. /**
  40671. * Gets wether the color grading effect is enabled.
  40672. */
  40673. /**
  40674. * Gets wether the color grading effect is enabled.
  40675. */
  40676. colorGradingEnabled: boolean;
  40677. /**
  40678. * Gets exposure used in the effect.
  40679. */
  40680. /**
  40681. * Sets exposure used in the effect.
  40682. */
  40683. exposure: number;
  40684. /**
  40685. * Gets wether tonemapping is enabled or not.
  40686. */
  40687. /**
  40688. * Sets wether tonemapping is enabled or not
  40689. */
  40690. toneMappingEnabled: boolean;
  40691. /**
  40692. * Gets the type of tone mapping effect.
  40693. */
  40694. /**
  40695. * Sets the type of tone mapping effect.
  40696. */
  40697. toneMappingType: number;
  40698. /**
  40699. * Gets contrast used in the effect.
  40700. */
  40701. /**
  40702. * Sets contrast used in the effect.
  40703. */
  40704. contrast: number;
  40705. /**
  40706. * Gets Vignette stretch size.
  40707. */
  40708. /**
  40709. * Sets Vignette stretch size.
  40710. */
  40711. vignetteStretch: number;
  40712. /**
  40713. * Gets Vignette centre X Offset.
  40714. */
  40715. /**
  40716. * Sets Vignette centre X Offset.
  40717. */
  40718. vignetteCentreX: number;
  40719. /**
  40720. * Gets Vignette centre Y Offset.
  40721. */
  40722. /**
  40723. * Sets Vignette centre Y Offset.
  40724. */
  40725. vignetteCentreY: number;
  40726. /**
  40727. * Gets Vignette weight or intensity of the vignette effect.
  40728. */
  40729. /**
  40730. * Sets Vignette weight or intensity of the vignette effect.
  40731. */
  40732. vignetteWeight: number;
  40733. /**
  40734. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40735. * if vignetteEnabled is set to true.
  40736. */
  40737. /**
  40738. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40739. * if vignetteEnabled is set to true.
  40740. */
  40741. vignetteColor: Color4;
  40742. /**
  40743. * Gets Camera field of view used by the Vignette effect.
  40744. */
  40745. /**
  40746. * Sets Camera field of view used by the Vignette effect.
  40747. */
  40748. vignetteCameraFov: number;
  40749. /**
  40750. * Gets the vignette blend mode allowing different kind of effect.
  40751. */
  40752. /**
  40753. * Sets the vignette blend mode allowing different kind of effect.
  40754. */
  40755. vignetteBlendMode: number;
  40756. /**
  40757. * Gets wether the vignette effect is enabled.
  40758. */
  40759. /**
  40760. * Sets wether the vignette effect is enabled.
  40761. */
  40762. vignetteEnabled: boolean;
  40763. private _fromLinearSpace;
  40764. /**
  40765. * Gets wether the input of the processing is in Gamma or Linear Space.
  40766. */
  40767. /**
  40768. * Sets wether the input of the processing is in Gamma or Linear Space.
  40769. */
  40770. fromLinearSpace: boolean;
  40771. /**
  40772. * Defines cache preventing GC.
  40773. */
  40774. private _defines;
  40775. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40776. /**
  40777. * "ImageProcessingPostProcess"
  40778. * @returns "ImageProcessingPostProcess"
  40779. */
  40780. getClassName(): string;
  40781. protected _updateParameters(): void;
  40782. dispose(camera?: Camera): void;
  40783. }
  40784. }
  40785. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40786. import { Scene } from "babylonjs/scene";
  40787. import { Color3 } from "babylonjs/Maths/math";
  40788. import { Mesh } from "babylonjs/Meshes/mesh";
  40789. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40790. import { Nullable } from "babylonjs/types";
  40791. /**
  40792. * Class containing static functions to help procedurally build meshes
  40793. */
  40794. export class GroundBuilder {
  40795. /**
  40796. * Creates a ground mesh
  40797. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40798. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40800. * @param name defines the name of the mesh
  40801. * @param options defines the options used to create the mesh
  40802. * @param scene defines the hosting scene
  40803. * @returns the ground mesh
  40804. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40805. */
  40806. static CreateGround(name: string, options: {
  40807. width?: number;
  40808. height?: number;
  40809. subdivisions?: number;
  40810. subdivisionsX?: number;
  40811. subdivisionsY?: number;
  40812. updatable?: boolean;
  40813. }, scene: any): Mesh;
  40814. /**
  40815. * Creates a tiled ground mesh
  40816. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40817. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40818. * * 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
  40819. * * 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
  40820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40821. * @param name defines the name of the mesh
  40822. * @param options defines the options used to create the mesh
  40823. * @param scene defines the hosting scene
  40824. * @returns the tiled ground mesh
  40825. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40826. */
  40827. static CreateTiledGround(name: string, options: {
  40828. xmin: number;
  40829. zmin: number;
  40830. xmax: number;
  40831. zmax: number;
  40832. subdivisions?: {
  40833. w: number;
  40834. h: number;
  40835. };
  40836. precision?: {
  40837. w: number;
  40838. h: number;
  40839. };
  40840. updatable?: boolean;
  40841. }, scene?: Nullable<Scene>): Mesh;
  40842. /**
  40843. * Creates a ground mesh from a height map
  40844. * * The parameter `url` sets the URL of the height map image resource.
  40845. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40846. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40847. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40848. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40849. * * 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.
  40850. * * 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).
  40851. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40853. * @param name defines the name of the mesh
  40854. * @param url defines the url to the height map
  40855. * @param options defines the options used to create the mesh
  40856. * @param scene defines the hosting scene
  40857. * @returns the ground mesh
  40858. * @see https://doc.babylonjs.com/babylon101/height_map
  40859. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40860. */
  40861. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40862. width?: number;
  40863. height?: number;
  40864. subdivisions?: number;
  40865. minHeight?: number;
  40866. maxHeight?: number;
  40867. colorFilter?: Color3;
  40868. alphaFilter?: number;
  40869. updatable?: boolean;
  40870. onReady?: (mesh: GroundMesh) => void;
  40871. }, scene?: Nullable<Scene>): GroundMesh;
  40872. }
  40873. }
  40874. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40875. import { Vector4 } from "babylonjs/Maths/math";
  40876. import { Mesh } from "babylonjs/Meshes/mesh";
  40877. /**
  40878. * Class containing static functions to help procedurally build meshes
  40879. */
  40880. export class TorusBuilder {
  40881. /**
  40882. * Creates a torus mesh
  40883. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40884. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40885. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40889. * @param name defines the name of the mesh
  40890. * @param options defines the options used to create the mesh
  40891. * @param scene defines the hosting scene
  40892. * @returns the torus mesh
  40893. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40894. */
  40895. static CreateTorus(name: string, options: {
  40896. diameter?: number;
  40897. thickness?: number;
  40898. tessellation?: number;
  40899. updatable?: boolean;
  40900. sideOrientation?: number;
  40901. frontUVs?: Vector4;
  40902. backUVs?: Vector4;
  40903. }, scene: any): Mesh;
  40904. }
  40905. }
  40906. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40907. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40908. import { Mesh } from "babylonjs/Meshes/mesh";
  40909. /**
  40910. * Class containing static functions to help procedurally build meshes
  40911. */
  40912. export class CylinderBuilder {
  40913. /**
  40914. * Creates a cylinder or a cone mesh
  40915. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40916. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40917. * * 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.
  40918. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40919. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40920. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40921. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40922. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40923. * * 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).
  40924. * * 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
  40925. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40926. * * 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
  40927. * * 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.
  40928. * * If `enclose` is false, a ring surface is one element.
  40929. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40930. * * 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
  40931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40934. * @param name defines the name of the mesh
  40935. * @param options defines the options used to create the mesh
  40936. * @param scene defines the hosting scene
  40937. * @returns the cylinder mesh
  40938. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40939. */
  40940. static CreateCylinder(name: string, options: {
  40941. height?: number;
  40942. diameterTop?: number;
  40943. diameterBottom?: number;
  40944. diameter?: number;
  40945. tessellation?: number;
  40946. subdivisions?: number;
  40947. arc?: number;
  40948. faceColors?: Color4[];
  40949. faceUV?: Vector4[];
  40950. updatable?: boolean;
  40951. hasRings?: boolean;
  40952. enclose?: boolean;
  40953. sideOrientation?: number;
  40954. frontUVs?: Vector4;
  40955. backUVs?: Vector4;
  40956. }, scene: any): Mesh;
  40957. }
  40958. }
  40959. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40960. import { Observable } from "babylonjs/Misc/observable";
  40961. import { Nullable } from "babylonjs/types";
  40962. import { Camera } from "babylonjs/Cameras/camera";
  40963. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40964. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40965. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40966. import { Scene } from "babylonjs/scene";
  40967. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40968. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40970. import { Mesh } from "babylonjs/Meshes/mesh";
  40971. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40972. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40973. import "babylonjs/Meshes/Builders/groundBuilder";
  40974. import "babylonjs/Meshes/Builders/torusBuilder";
  40975. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40976. import "babylonjs/Gamepads/gamepadSceneComponent";
  40977. import "babylonjs/Animations/animatable";
  40978. /**
  40979. * Options to modify the vr teleportation behavior.
  40980. */
  40981. export interface VRTeleportationOptions {
  40982. /**
  40983. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40984. */
  40985. floorMeshName?: string;
  40986. /**
  40987. * A list of meshes to be used as the teleportation floor. (default: empty)
  40988. */
  40989. floorMeshes?: Mesh[];
  40990. }
  40991. /**
  40992. * Options to modify the vr experience helper's behavior.
  40993. */
  40994. export interface VRExperienceHelperOptions extends WebVROptions {
  40995. /**
  40996. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40997. */
  40998. createDeviceOrientationCamera?: boolean;
  40999. /**
  41000. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41001. */
  41002. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41003. /**
  41004. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41005. */
  41006. laserToggle?: boolean;
  41007. /**
  41008. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41009. */
  41010. floorMeshes?: Mesh[];
  41011. /**
  41012. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41013. */
  41014. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41015. }
  41016. /**
  41017. * Event containing information after VR has been entered
  41018. */
  41019. export class OnAfterEnteringVRObservableEvent {
  41020. /**
  41021. * If entering vr was successful
  41022. */
  41023. success: boolean;
  41024. }
  41025. /**
  41026. * Helps to quickly add VR support to an existing scene.
  41027. * See http://doc.babylonjs.com/how_to/webvr_helper
  41028. */
  41029. export class VRExperienceHelper {
  41030. /** Options to modify the vr experience helper's behavior. */
  41031. webVROptions: VRExperienceHelperOptions;
  41032. private _scene;
  41033. private _position;
  41034. private _btnVR;
  41035. private _btnVRDisplayed;
  41036. private _webVRsupported;
  41037. private _webVRready;
  41038. private _webVRrequesting;
  41039. private _webVRpresenting;
  41040. private _hasEnteredVR;
  41041. private _fullscreenVRpresenting;
  41042. private _canvas;
  41043. private _webVRCamera;
  41044. private _vrDeviceOrientationCamera;
  41045. private _deviceOrientationCamera;
  41046. private _existingCamera;
  41047. private _onKeyDown;
  41048. private _onVrDisplayPresentChange;
  41049. private _onVRDisplayChanged;
  41050. private _onVRRequestPresentStart;
  41051. private _onVRRequestPresentComplete;
  41052. /**
  41053. * Observable raised right before entering VR.
  41054. */
  41055. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41056. /**
  41057. * Observable raised when entering VR has completed.
  41058. */
  41059. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41060. /**
  41061. * Observable raised when exiting VR.
  41062. */
  41063. onExitingVRObservable: Observable<VRExperienceHelper>;
  41064. /**
  41065. * Observable raised when controller mesh is loaded.
  41066. */
  41067. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41068. /** Return this.onEnteringVRObservable
  41069. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41070. */
  41071. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41072. /** Return this.onExitingVRObservable
  41073. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41074. */
  41075. readonly onExitingVR: Observable<VRExperienceHelper>;
  41076. /** Return this.onControllerMeshLoadedObservable
  41077. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41078. */
  41079. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41080. private _rayLength;
  41081. private _useCustomVRButton;
  41082. private _teleportationRequested;
  41083. private _teleportActive;
  41084. private _floorMeshName;
  41085. private _floorMeshesCollection;
  41086. private _rotationAllowed;
  41087. private _teleportBackwardsVector;
  41088. private _teleportationTarget;
  41089. private _isDefaultTeleportationTarget;
  41090. private _postProcessMove;
  41091. private _teleportationFillColor;
  41092. private _teleportationBorderColor;
  41093. private _rotationAngle;
  41094. private _haloCenter;
  41095. private _cameraGazer;
  41096. private _padSensibilityUp;
  41097. private _padSensibilityDown;
  41098. private _leftController;
  41099. private _rightController;
  41100. /**
  41101. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41102. */
  41103. onNewMeshSelected: Observable<AbstractMesh>;
  41104. /**
  41105. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41106. */
  41107. onNewMeshPicked: Observable<PickingInfo>;
  41108. private _circleEase;
  41109. /**
  41110. * Observable raised before camera teleportation
  41111. */
  41112. onBeforeCameraTeleport: Observable<Vector3>;
  41113. /**
  41114. * Observable raised after camera teleportation
  41115. */
  41116. onAfterCameraTeleport: Observable<Vector3>;
  41117. /**
  41118. * Observable raised when current selected mesh gets unselected
  41119. */
  41120. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41121. private _raySelectionPredicate;
  41122. /**
  41123. * To be optionaly changed by user to define custom ray selection
  41124. */
  41125. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41126. /**
  41127. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41128. */
  41129. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41130. /**
  41131. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41132. */
  41133. teleportationEnabled: boolean;
  41134. private _defaultHeight;
  41135. private _teleportationInitialized;
  41136. private _interactionsEnabled;
  41137. private _interactionsRequested;
  41138. private _displayGaze;
  41139. private _displayLaserPointer;
  41140. /**
  41141. * The mesh used to display where the user is going to teleport.
  41142. */
  41143. /**
  41144. * Sets the mesh to be used to display where the user is going to teleport.
  41145. */
  41146. teleportationTarget: Mesh;
  41147. /**
  41148. * 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
  41149. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41150. * See http://doc.babylonjs.com/resources/baking_transformations
  41151. */
  41152. gazeTrackerMesh: Mesh;
  41153. /**
  41154. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41155. */
  41156. updateGazeTrackerScale: boolean;
  41157. /**
  41158. * If the gaze trackers color should be updated when selecting meshes
  41159. */
  41160. updateGazeTrackerColor: boolean;
  41161. /**
  41162. * The gaze tracking mesh corresponding to the left controller
  41163. */
  41164. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41165. /**
  41166. * The gaze tracking mesh corresponding to the right controller
  41167. */
  41168. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41169. /**
  41170. * If the ray of the gaze should be displayed.
  41171. */
  41172. /**
  41173. * Sets if the ray of the gaze should be displayed.
  41174. */
  41175. displayGaze: boolean;
  41176. /**
  41177. * If the ray of the LaserPointer should be displayed.
  41178. */
  41179. /**
  41180. * Sets if the ray of the LaserPointer should be displayed.
  41181. */
  41182. displayLaserPointer: boolean;
  41183. /**
  41184. * The deviceOrientationCamera used as the camera when not in VR.
  41185. */
  41186. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41187. /**
  41188. * Based on the current WebVR support, returns the current VR camera used.
  41189. */
  41190. readonly currentVRCamera: Nullable<Camera>;
  41191. /**
  41192. * The webVRCamera which is used when in VR.
  41193. */
  41194. readonly webVRCamera: WebVRFreeCamera;
  41195. /**
  41196. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41197. */
  41198. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41199. private readonly _teleportationRequestInitiated;
  41200. /**
  41201. * Defines wether or not Pointer lock should be requested when switching to
  41202. * full screen.
  41203. */
  41204. requestPointerLockOnFullScreen: boolean;
  41205. /**
  41206. * Instantiates a VRExperienceHelper.
  41207. * Helps to quickly add VR support to an existing scene.
  41208. * @param scene The scene the VRExperienceHelper belongs to.
  41209. * @param webVROptions Options to modify the vr experience helper's behavior.
  41210. */
  41211. constructor(scene: Scene,
  41212. /** Options to modify the vr experience helper's behavior. */
  41213. webVROptions?: VRExperienceHelperOptions);
  41214. private _onDefaultMeshLoaded;
  41215. private _onResize;
  41216. private _onFullscreenChange;
  41217. /**
  41218. * Gets a value indicating if we are currently in VR mode.
  41219. */
  41220. readonly isInVRMode: boolean;
  41221. private onVrDisplayPresentChange;
  41222. private onVRDisplayChanged;
  41223. private moveButtonToBottomRight;
  41224. private displayVRButton;
  41225. private updateButtonVisibility;
  41226. private _cachedAngularSensibility;
  41227. /**
  41228. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41229. * Otherwise, will use the fullscreen API.
  41230. */
  41231. enterVR(): void;
  41232. /**
  41233. * Attempt to exit VR, or fullscreen.
  41234. */
  41235. exitVR(): void;
  41236. /**
  41237. * The position of the vr experience helper.
  41238. */
  41239. /**
  41240. * Sets the position of the vr experience helper.
  41241. */
  41242. position: Vector3;
  41243. /**
  41244. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41245. */
  41246. enableInteractions(): void;
  41247. private readonly _noControllerIsActive;
  41248. private beforeRender;
  41249. private _isTeleportationFloor;
  41250. /**
  41251. * Adds a floor mesh to be used for teleportation.
  41252. * @param floorMesh the mesh to be used for teleportation.
  41253. */
  41254. addFloorMesh(floorMesh: Mesh): void;
  41255. /**
  41256. * Removes a floor mesh from being used for teleportation.
  41257. * @param floorMesh the mesh to be removed.
  41258. */
  41259. removeFloorMesh(floorMesh: Mesh): void;
  41260. /**
  41261. * Enables interactions and teleportation using the VR controllers and gaze.
  41262. * @param vrTeleportationOptions options to modify teleportation behavior.
  41263. */
  41264. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41265. private _onNewGamepadConnected;
  41266. private _tryEnableInteractionOnController;
  41267. private _onNewGamepadDisconnected;
  41268. private _enableInteractionOnController;
  41269. private _checkTeleportWithRay;
  41270. private _checkRotate;
  41271. private _checkTeleportBackwards;
  41272. private _enableTeleportationOnController;
  41273. private _createTeleportationCircles;
  41274. private _displayTeleportationTarget;
  41275. private _hideTeleportationTarget;
  41276. private _rotateCamera;
  41277. private _moveTeleportationSelectorTo;
  41278. private _workingVector;
  41279. private _workingQuaternion;
  41280. private _workingMatrix;
  41281. /**
  41282. * Teleports the users feet to the desired location
  41283. * @param location The location where the user's feet should be placed
  41284. */
  41285. teleportCamera(location: Vector3): void;
  41286. private _convertNormalToDirectionOfRay;
  41287. private _castRayAndSelectObject;
  41288. private _notifySelectedMeshUnselected;
  41289. /**
  41290. * Sets the color of the laser ray from the vr controllers.
  41291. * @param color new color for the ray.
  41292. */
  41293. changeLaserColor(color: Color3): void;
  41294. /**
  41295. * Sets the color of the ray from the vr headsets gaze.
  41296. * @param color new color for the ray.
  41297. */
  41298. changeGazeColor(color: Color3): void;
  41299. /**
  41300. * Exits VR and disposes of the vr experience helper
  41301. */
  41302. dispose(): void;
  41303. /**
  41304. * Gets the name of the VRExperienceHelper class
  41305. * @returns "VRExperienceHelper"
  41306. */
  41307. getClassName(): string;
  41308. }
  41309. }
  41310. declare module "babylonjs/Cameras/VR/index" {
  41311. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41312. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41313. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41314. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41315. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41316. export * from "babylonjs/Cameras/VR/webVRCamera";
  41317. }
  41318. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41319. import { Observable } from "babylonjs/Misc/observable";
  41320. import { Nullable } from "babylonjs/types";
  41321. import { IDisposable, Scene } from "babylonjs/scene";
  41322. import { Vector3 } from "babylonjs/Maths/math";
  41323. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41324. import { Ray } from "babylonjs/Culling/ray";
  41325. /**
  41326. * Manages an XRSession
  41327. * @see https://doc.babylonjs.com/how_to/webxr
  41328. */
  41329. export class WebXRSessionManager implements IDisposable {
  41330. private scene;
  41331. /**
  41332. * Fires every time a new xrFrame arrives which can be used to update the camera
  41333. */
  41334. onXRFrameObservable: Observable<any>;
  41335. /**
  41336. * Fires when the xr session is ended either by the device or manually done
  41337. */
  41338. onXRSessionEnded: Observable<any>;
  41339. /** @hidden */
  41340. _xrSession: XRSession;
  41341. /** @hidden */
  41342. _frameOfReference: XRFrameOfReference;
  41343. /** @hidden */
  41344. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41345. /** @hidden */
  41346. _currentXRFrame: Nullable<XRFrame>;
  41347. private _xrNavigator;
  41348. private _xrDevice;
  41349. private _tmpMatrix;
  41350. /**
  41351. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41352. * @param scene The scene which the session should be created for
  41353. */
  41354. constructor(scene: Scene);
  41355. /**
  41356. * Initializes the manager
  41357. * After initialization enterXR can be called to start an XR session
  41358. * @returns Promise which resolves after it is initialized
  41359. */
  41360. initializeAsync(): Promise<void>;
  41361. /**
  41362. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41363. * @param sessionCreationOptions xr options to create the session with
  41364. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41365. * @returns Promise which resolves after it enters XR
  41366. */
  41367. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41368. /**
  41369. * Stops the xrSession and restores the renderloop
  41370. * @returns Promise which resolves after it exits XR
  41371. */
  41372. exitXRAsync(): Promise<void>;
  41373. /**
  41374. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41375. * @param ray ray to cast into the environment
  41376. * @returns Promise which resolves with a collision point in the environment if it exists
  41377. */
  41378. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41379. /**
  41380. * Checks if a session would be supported for the creation options specified
  41381. * @param options creation options to check if they are supported
  41382. * @returns true if supported
  41383. */
  41384. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41385. /**
  41386. * @hidden
  41387. * Converts the render layer of xrSession to a render target
  41388. * @param session session to create render target for
  41389. * @param scene scene the new render target should be created for
  41390. */
  41391. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41392. /**
  41393. * Disposes of the session manager
  41394. */
  41395. dispose(): void;
  41396. }
  41397. }
  41398. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41399. import { Scene } from "babylonjs/scene";
  41400. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41401. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41402. /**
  41403. * WebXR Camera which holds the views for the xrSession
  41404. * @see https://doc.babylonjs.com/how_to/webxr
  41405. */
  41406. export class WebXRCamera extends FreeCamera {
  41407. private static _TmpMatrix;
  41408. /**
  41409. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41410. * @param name the name of the camera
  41411. * @param scene the scene to add the camera to
  41412. */
  41413. constructor(name: string, scene: Scene);
  41414. private _updateNumberOfRigCameras;
  41415. /** @hidden */
  41416. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41417. /**
  41418. * Updates the cameras position from the current pose information of the XR session
  41419. * @param xrSessionManager the session containing pose information
  41420. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41421. */
  41422. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41423. }
  41424. }
  41425. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41426. import { Nullable } from "babylonjs/types";
  41427. import { Observable } from "babylonjs/Misc/observable";
  41428. import { IDisposable, Scene } from "babylonjs/scene";
  41429. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41431. import { Ray } from "babylonjs/Culling/ray";
  41432. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41433. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41434. /**
  41435. * States of the webXR experience
  41436. */
  41437. export enum WebXRState {
  41438. /**
  41439. * Transitioning to being in XR mode
  41440. */
  41441. ENTERING_XR = 0,
  41442. /**
  41443. * Transitioning to non XR mode
  41444. */
  41445. EXITING_XR = 1,
  41446. /**
  41447. * In XR mode and presenting
  41448. */
  41449. IN_XR = 2,
  41450. /**
  41451. * Not entered XR mode
  41452. */
  41453. NOT_IN_XR = 3
  41454. }
  41455. /**
  41456. * Helper class used to enable XR
  41457. * @see https://doc.babylonjs.com/how_to/webxr
  41458. */
  41459. export class WebXRExperienceHelper implements IDisposable {
  41460. private scene;
  41461. /**
  41462. * 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
  41463. */
  41464. container: AbstractMesh;
  41465. /**
  41466. * Camera used to render xr content
  41467. */
  41468. camera: WebXRCamera;
  41469. /**
  41470. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41471. */
  41472. state: WebXRState;
  41473. private _setState;
  41474. private static _TmpVector;
  41475. /**
  41476. * Fires when the state of the experience helper has changed
  41477. */
  41478. onStateChangedObservable: Observable<WebXRState>;
  41479. /** @hidden */
  41480. _sessionManager: WebXRSessionManager;
  41481. private _nonVRCamera;
  41482. private _originalSceneAutoClear;
  41483. private _supported;
  41484. /**
  41485. * Creates the experience helper
  41486. * @param scene the scene to attach the experience helper to
  41487. * @returns a promise for the experience helper
  41488. */
  41489. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41490. /**
  41491. * Creates a WebXRExperienceHelper
  41492. * @param scene The scene the helper should be created in
  41493. */
  41494. private constructor();
  41495. /**
  41496. * Exits XR mode and returns the scene to its original state
  41497. * @returns promise that resolves after xr mode has exited
  41498. */
  41499. exitXRAsync(): Promise<void>;
  41500. /**
  41501. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41502. * @param sessionCreationOptions options for the XR session
  41503. * @param frameOfReference frame of reference of the XR session
  41504. * @returns promise that resolves after xr mode has entered
  41505. */
  41506. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41507. /**
  41508. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41509. * @param ray ray to cast into the environment
  41510. * @returns Promise which resolves with a collision point in the environment if it exists
  41511. */
  41512. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41513. /**
  41514. * Updates the global position of the camera by moving the camera's container
  41515. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41516. * @param position The desired global position of the camera
  41517. */
  41518. setPositionOfCameraUsingContainer(position: Vector3): void;
  41519. /**
  41520. * Rotates the xr camera by rotating the camera's container around the camera's position
  41521. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41522. * @param rotation the desired quaternion rotation to apply to the camera
  41523. */
  41524. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41525. /**
  41526. * Checks if the creation options are supported by the xr session
  41527. * @param options creation options
  41528. * @returns true if supported
  41529. */
  41530. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41531. /**
  41532. * Disposes of the experience helper
  41533. */
  41534. dispose(): void;
  41535. }
  41536. }
  41537. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41538. import { Nullable } from "babylonjs/types";
  41539. import { Observable } from "babylonjs/Misc/observable";
  41540. import { IDisposable, Scene } from "babylonjs/scene";
  41541. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41542. /**
  41543. * Button which can be used to enter a different mode of XR
  41544. */
  41545. export class WebXREnterExitUIButton {
  41546. /** button element */
  41547. element: HTMLElement;
  41548. /** XR initialization options for the button */
  41549. initializationOptions: XRSessionCreationOptions;
  41550. /**
  41551. * Creates a WebXREnterExitUIButton
  41552. * @param element button element
  41553. * @param initializationOptions XR initialization options for the button
  41554. */
  41555. constructor(
  41556. /** button element */
  41557. element: HTMLElement,
  41558. /** XR initialization options for the button */
  41559. initializationOptions: XRSessionCreationOptions);
  41560. /**
  41561. * Overwritable function which can be used to update the button's visuals when the state changes
  41562. * @param activeButton the current active button in the UI
  41563. */
  41564. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41565. }
  41566. /**
  41567. * Options to create the webXR UI
  41568. */
  41569. export class WebXREnterExitUIOptions {
  41570. /**
  41571. * Context to enter xr with
  41572. */
  41573. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41574. /**
  41575. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41576. */
  41577. customButtons?: Array<WebXREnterExitUIButton>;
  41578. }
  41579. /**
  41580. * UI to allow the user to enter/exit XR mode
  41581. */
  41582. export class WebXREnterExitUI implements IDisposable {
  41583. private scene;
  41584. private _overlay;
  41585. private _buttons;
  41586. private _activeButton;
  41587. /**
  41588. * Fired every time the active button is changed.
  41589. *
  41590. * When xr is entered via a button that launches xr that button will be the callback parameter
  41591. *
  41592. * When exiting xr the callback parameter will be null)
  41593. */
  41594. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41595. /**
  41596. * Creates UI to allow the user to enter/exit XR mode
  41597. * @param scene the scene to add the ui to
  41598. * @param helper the xr experience helper to enter/exit xr with
  41599. * @param options options to configure the UI
  41600. * @returns the created ui
  41601. */
  41602. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41603. private constructor();
  41604. private _updateButtons;
  41605. /**
  41606. * Disposes of the object
  41607. */
  41608. dispose(): void;
  41609. }
  41610. }
  41611. declare module "babylonjs/Cameras/XR/webXRInput" {
  41612. import { IDisposable, Scene } from "babylonjs/scene";
  41613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41614. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41615. /**
  41616. * Represents an XR input
  41617. */
  41618. export class WebXRController {
  41619. /**
  41620. * 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
  41621. */
  41622. grip?: AbstractMesh;
  41623. /**
  41624. * Pointer which can be used to select objects or attach a visible laser to
  41625. */
  41626. pointer: AbstractMesh;
  41627. /**
  41628. * Creates the controller
  41629. * @see https://doc.babylonjs.com/how_to/webxr
  41630. * @param scene the scene which the controller should be associated to
  41631. */
  41632. constructor(scene: Scene);
  41633. /**
  41634. * Disposes of the object
  41635. */
  41636. dispose(): void;
  41637. }
  41638. /**
  41639. * XR input used to track XR inputs such as controllers/rays
  41640. */
  41641. export class WebXRInput implements IDisposable {
  41642. private helper;
  41643. /**
  41644. * XR controllers being tracked
  41645. */
  41646. controllers: Array<WebXRController>;
  41647. private _tmpMatrix;
  41648. private _frameObserver;
  41649. /**
  41650. * Initializes the WebXRInput
  41651. * @param helper experience helper which the input should be created for
  41652. */
  41653. constructor(helper: WebXRExperienceHelper);
  41654. /**
  41655. * Disposes of the object
  41656. */
  41657. dispose(): void;
  41658. }
  41659. }
  41660. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41661. import { Nullable } from "babylonjs/types";
  41662. import { IDisposable } from "babylonjs/scene";
  41663. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41664. /**
  41665. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41666. */
  41667. export class WebXRManagedOutputCanvas implements IDisposable {
  41668. private _canvas;
  41669. /**
  41670. * xrpresent context of the canvas which can be used to display/mirror xr content
  41671. */
  41672. canvasContext: Nullable<WebGLRenderingContext>;
  41673. /**
  41674. * Initializes the canvas to be added/removed upon entering/exiting xr
  41675. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41676. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41677. */
  41678. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41679. /**
  41680. * Disposes of the object
  41681. */
  41682. dispose(): void;
  41683. private _setManagedOutputCanvas;
  41684. private _addCanvas;
  41685. private _removeCanvas;
  41686. }
  41687. }
  41688. declare module "babylonjs/Cameras/XR/index" {
  41689. export * from "babylonjs/Cameras/XR/webXRCamera";
  41690. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41691. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41692. export * from "babylonjs/Cameras/XR/webXRInput";
  41693. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41694. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41695. }
  41696. declare module "babylonjs/Cameras/RigModes/index" {
  41697. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41698. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41699. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41700. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41701. }
  41702. declare module "babylonjs/Cameras/index" {
  41703. export * from "babylonjs/Cameras/Inputs/index";
  41704. export * from "babylonjs/Cameras/cameraInputsManager";
  41705. export * from "babylonjs/Cameras/camera";
  41706. export * from "babylonjs/Cameras/targetCamera";
  41707. export * from "babylonjs/Cameras/freeCamera";
  41708. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41709. export * from "babylonjs/Cameras/touchCamera";
  41710. export * from "babylonjs/Cameras/arcRotateCamera";
  41711. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41712. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41713. export * from "babylonjs/Cameras/flyCamera";
  41714. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41715. export * from "babylonjs/Cameras/followCamera";
  41716. export * from "babylonjs/Cameras/gamepadCamera";
  41717. export * from "babylonjs/Cameras/Stereoscopic/index";
  41718. export * from "babylonjs/Cameras/universalCamera";
  41719. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41720. export * from "babylonjs/Cameras/VR/index";
  41721. export * from "babylonjs/Cameras/XR/index";
  41722. export * from "babylonjs/Cameras/RigModes/index";
  41723. }
  41724. declare module "babylonjs/Collisions/index" {
  41725. export * from "babylonjs/Collisions/collider";
  41726. export * from "babylonjs/Collisions/collisionCoordinator";
  41727. export * from "babylonjs/Collisions/pickingInfo";
  41728. export * from "babylonjs/Collisions/intersectionInfo";
  41729. export * from "babylonjs/Collisions/meshCollisionData";
  41730. }
  41731. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41732. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41733. import { Vector3, Plane } from "babylonjs/Maths/math";
  41734. import { Ray } from "babylonjs/Culling/ray";
  41735. /**
  41736. * Contains an array of blocks representing the octree
  41737. */
  41738. export interface IOctreeContainer<T> {
  41739. /**
  41740. * Blocks within the octree
  41741. */
  41742. blocks: Array<OctreeBlock<T>>;
  41743. }
  41744. /**
  41745. * Class used to store a cell in an octree
  41746. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41747. */
  41748. export class OctreeBlock<T> {
  41749. /**
  41750. * Gets the content of the current block
  41751. */
  41752. entries: T[];
  41753. /**
  41754. * Gets the list of block children
  41755. */
  41756. blocks: Array<OctreeBlock<T>>;
  41757. private _depth;
  41758. private _maxDepth;
  41759. private _capacity;
  41760. private _minPoint;
  41761. private _maxPoint;
  41762. private _boundingVectors;
  41763. private _creationFunc;
  41764. /**
  41765. * Creates a new block
  41766. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41767. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41768. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41769. * @param depth defines the current depth of this block in the octree
  41770. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41771. * @param creationFunc defines a callback to call when an element is added to the block
  41772. */
  41773. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41774. /**
  41775. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41776. */
  41777. readonly capacity: number;
  41778. /**
  41779. * Gets the minimum vector (in world space) of the block's bounding box
  41780. */
  41781. readonly minPoint: Vector3;
  41782. /**
  41783. * Gets the maximum vector (in world space) of the block's bounding box
  41784. */
  41785. readonly maxPoint: Vector3;
  41786. /**
  41787. * Add a new element to this block
  41788. * @param entry defines the element to add
  41789. */
  41790. addEntry(entry: T): void;
  41791. /**
  41792. * Remove an element from this block
  41793. * @param entry defines the element to remove
  41794. */
  41795. removeEntry(entry: T): void;
  41796. /**
  41797. * Add an array of elements to this block
  41798. * @param entries defines the array of elements to add
  41799. */
  41800. addEntries(entries: T[]): void;
  41801. /**
  41802. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41803. * @param frustumPlanes defines the frustum planes to test
  41804. * @param selection defines the array to store current content if selection is positive
  41805. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41806. */
  41807. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41808. /**
  41809. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41810. * @param sphereCenter defines the bounding sphere center
  41811. * @param sphereRadius defines the bounding sphere radius
  41812. * @param selection defines the array to store current content if selection is positive
  41813. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41814. */
  41815. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41816. /**
  41817. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41818. * @param ray defines the ray to test with
  41819. * @param selection defines the array to store current content if selection is positive
  41820. */
  41821. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41822. /**
  41823. * Subdivide the content into child blocks (this block will then be empty)
  41824. */
  41825. createInnerBlocks(): void;
  41826. /**
  41827. * @hidden
  41828. */
  41829. 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;
  41830. }
  41831. }
  41832. declare module "babylonjs/Culling/Octrees/octree" {
  41833. import { SmartArray } from "babylonjs/Misc/smartArray";
  41834. import { Vector3, Plane } from "babylonjs/Maths/math";
  41835. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41837. import { Ray } from "babylonjs/Culling/ray";
  41838. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41839. /**
  41840. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41841. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41842. */
  41843. export class Octree<T> {
  41844. /** 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.) */
  41845. maxDepth: number;
  41846. /**
  41847. * Blocks within the octree containing objects
  41848. */
  41849. blocks: Array<OctreeBlock<T>>;
  41850. /**
  41851. * Content stored in the octree
  41852. */
  41853. dynamicContent: T[];
  41854. private _maxBlockCapacity;
  41855. private _selectionContent;
  41856. private _creationFunc;
  41857. /**
  41858. * Creates a octree
  41859. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41860. * @param creationFunc function to be used to instatiate the octree
  41861. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41862. * @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.)
  41863. */
  41864. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41865. /** 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.) */
  41866. maxDepth?: number);
  41867. /**
  41868. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41869. * @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);
  41870. * @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);
  41871. * @param entries meshes to be added to the octree blocks
  41872. */
  41873. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41874. /**
  41875. * Adds a mesh to the octree
  41876. * @param entry Mesh to add to the octree
  41877. */
  41878. addMesh(entry: T): void;
  41879. /**
  41880. * Remove an element from the octree
  41881. * @param entry defines the element to remove
  41882. */
  41883. removeMesh(entry: T): void;
  41884. /**
  41885. * Selects an array of meshes within the frustum
  41886. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41887. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41888. * @returns array of meshes within the frustum
  41889. */
  41890. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41891. /**
  41892. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41893. * @param sphereCenter defines the bounding sphere center
  41894. * @param sphereRadius defines the bounding sphere radius
  41895. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41896. * @returns an array of objects that intersect the sphere
  41897. */
  41898. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41899. /**
  41900. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41901. * @param ray defines the ray to test with
  41902. * @returns array of intersected objects
  41903. */
  41904. intersectsRay(ray: Ray): SmartArray<T>;
  41905. /**
  41906. * Adds a mesh into the octree block if it intersects the block
  41907. */
  41908. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41909. /**
  41910. * Adds a submesh into the octree block if it intersects the block
  41911. */
  41912. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41913. }
  41914. }
  41915. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41916. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41917. import { Scene } from "babylonjs/scene";
  41918. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41920. import { Ray } from "babylonjs/Culling/ray";
  41921. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41922. import { Collider } from "babylonjs/Collisions/collider";
  41923. module "babylonjs/scene" {
  41924. interface Scene {
  41925. /**
  41926. * @hidden
  41927. * Backing Filed
  41928. */
  41929. _selectionOctree: Octree<AbstractMesh>;
  41930. /**
  41931. * Gets the octree used to boost mesh selection (picking)
  41932. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41933. */
  41934. selectionOctree: Octree<AbstractMesh>;
  41935. /**
  41936. * Creates or updates the octree used to boost selection (picking)
  41937. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41938. * @param maxCapacity defines the maximum capacity per leaf
  41939. * @param maxDepth defines the maximum depth of the octree
  41940. * @returns an octree of AbstractMesh
  41941. */
  41942. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41943. }
  41944. }
  41945. module "babylonjs/Meshes/abstractMesh" {
  41946. interface AbstractMesh {
  41947. /**
  41948. * @hidden
  41949. * Backing Field
  41950. */
  41951. _submeshesOctree: Octree<SubMesh>;
  41952. /**
  41953. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41954. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41955. * @param maxCapacity defines the maximum size of each block (64 by default)
  41956. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41957. * @returns the new octree
  41958. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41959. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41960. */
  41961. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41962. }
  41963. }
  41964. /**
  41965. * Defines the octree scene component responsible to manage any octrees
  41966. * in a given scene.
  41967. */
  41968. export class OctreeSceneComponent {
  41969. /**
  41970. * The component name help to identify the component in the list of scene components.
  41971. */
  41972. readonly name: string;
  41973. /**
  41974. * The scene the component belongs to.
  41975. */
  41976. scene: Scene;
  41977. /**
  41978. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41979. */
  41980. readonly checksIsEnabled: boolean;
  41981. /**
  41982. * Creates a new instance of the component for the given scene
  41983. * @param scene Defines the scene to register the component in
  41984. */
  41985. constructor(scene: Scene);
  41986. /**
  41987. * Registers the component in a given scene
  41988. */
  41989. register(): void;
  41990. /**
  41991. * Return the list of active meshes
  41992. * @returns the list of active meshes
  41993. */
  41994. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41995. /**
  41996. * Return the list of active sub meshes
  41997. * @param mesh The mesh to get the candidates sub meshes from
  41998. * @returns the list of active sub meshes
  41999. */
  42000. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42001. private _tempRay;
  42002. /**
  42003. * Return the list of sub meshes intersecting with a given local ray
  42004. * @param mesh defines the mesh to find the submesh for
  42005. * @param localRay defines the ray in local space
  42006. * @returns the list of intersecting sub meshes
  42007. */
  42008. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42009. /**
  42010. * Return the list of sub meshes colliding with a collider
  42011. * @param mesh defines the mesh to find the submesh for
  42012. * @param collider defines the collider to evaluate the collision against
  42013. * @returns the list of colliding sub meshes
  42014. */
  42015. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42016. /**
  42017. * Rebuilds the elements related to this component in case of
  42018. * context lost for instance.
  42019. */
  42020. rebuild(): void;
  42021. /**
  42022. * Disposes the component and the associated ressources.
  42023. */
  42024. dispose(): void;
  42025. }
  42026. }
  42027. declare module "babylonjs/Culling/Octrees/index" {
  42028. export * from "babylonjs/Culling/Octrees/octree";
  42029. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42030. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42031. }
  42032. declare module "babylonjs/Culling/index" {
  42033. export * from "babylonjs/Culling/boundingBox";
  42034. export * from "babylonjs/Culling/boundingInfo";
  42035. export * from "babylonjs/Culling/boundingSphere";
  42036. export * from "babylonjs/Culling/Octrees/index";
  42037. export * from "babylonjs/Culling/ray";
  42038. }
  42039. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42040. import { IDisposable, Scene } from "babylonjs/scene";
  42041. import { Nullable } from "babylonjs/types";
  42042. import { Observable } from "babylonjs/Misc/observable";
  42043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42044. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42045. /**
  42046. * Renders a layer on top of an existing scene
  42047. */
  42048. export class UtilityLayerRenderer implements IDisposable {
  42049. /** the original scene that will be rendered on top of */
  42050. originalScene: Scene;
  42051. private _pointerCaptures;
  42052. private _lastPointerEvents;
  42053. private static _DefaultUtilityLayer;
  42054. private static _DefaultKeepDepthUtilityLayer;
  42055. private _sharedGizmoLight;
  42056. /**
  42057. * @hidden
  42058. * Light which used by gizmos to get light shading
  42059. */
  42060. _getSharedGizmoLight(): HemisphericLight;
  42061. /**
  42062. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42063. */
  42064. pickUtilitySceneFirst: boolean;
  42065. /**
  42066. * 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)
  42067. */
  42068. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42069. /**
  42070. * 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)
  42071. */
  42072. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42073. /**
  42074. * The scene that is rendered on top of the original scene
  42075. */
  42076. utilityLayerScene: Scene;
  42077. /**
  42078. * If the utility layer should automatically be rendered on top of existing scene
  42079. */
  42080. shouldRender: boolean;
  42081. /**
  42082. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42083. */
  42084. onlyCheckPointerDownEvents: boolean;
  42085. /**
  42086. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42087. */
  42088. processAllEvents: boolean;
  42089. /**
  42090. * Observable raised when the pointer move from the utility layer scene to the main scene
  42091. */
  42092. onPointerOutObservable: Observable<number>;
  42093. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42094. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42095. private _afterRenderObserver;
  42096. private _sceneDisposeObserver;
  42097. private _originalPointerObserver;
  42098. /**
  42099. * Instantiates a UtilityLayerRenderer
  42100. * @param originalScene the original scene that will be rendered on top of
  42101. * @param handleEvents boolean indicating if the utility layer should handle events
  42102. */
  42103. constructor(
  42104. /** the original scene that will be rendered on top of */
  42105. originalScene: Scene, handleEvents?: boolean);
  42106. private _notifyObservers;
  42107. /**
  42108. * Renders the utility layers scene on top of the original scene
  42109. */
  42110. render(): void;
  42111. /**
  42112. * Disposes of the renderer
  42113. */
  42114. dispose(): void;
  42115. private _updateCamera;
  42116. }
  42117. }
  42118. declare module "babylonjs/Gizmos/gizmo" {
  42119. import { Nullable } from "babylonjs/types";
  42120. import { IDisposable } from "babylonjs/scene";
  42121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42122. import { Mesh } from "babylonjs/Meshes/mesh";
  42123. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42124. /**
  42125. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42126. */
  42127. export class Gizmo implements IDisposable {
  42128. /** The utility layer the gizmo will be added to */
  42129. gizmoLayer: UtilityLayerRenderer;
  42130. /**
  42131. * The root mesh of the gizmo
  42132. */
  42133. _rootMesh: Mesh;
  42134. private _attachedMesh;
  42135. /**
  42136. * Ratio for the scale of the gizmo (Default: 1)
  42137. */
  42138. scaleRatio: number;
  42139. /**
  42140. * If a custom mesh has been set (Default: false)
  42141. */
  42142. protected _customMeshSet: boolean;
  42143. /**
  42144. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42145. * * When set, interactions will be enabled
  42146. */
  42147. attachedMesh: Nullable<AbstractMesh>;
  42148. /**
  42149. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42150. * @param mesh The mesh to replace the default mesh of the gizmo
  42151. */
  42152. setCustomMesh(mesh: Mesh): void;
  42153. /**
  42154. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42155. */
  42156. updateGizmoRotationToMatchAttachedMesh: boolean;
  42157. /**
  42158. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42159. */
  42160. updateGizmoPositionToMatchAttachedMesh: boolean;
  42161. /**
  42162. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42163. */
  42164. protected _updateScale: boolean;
  42165. protected _interactionsEnabled: boolean;
  42166. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42167. private _beforeRenderObserver;
  42168. private _tempVector;
  42169. /**
  42170. * Creates a gizmo
  42171. * @param gizmoLayer The utility layer the gizmo will be added to
  42172. */
  42173. constructor(
  42174. /** The utility layer the gizmo will be added to */
  42175. gizmoLayer?: UtilityLayerRenderer);
  42176. /**
  42177. * Updates the gizmo to match the attached mesh's position/rotation
  42178. */
  42179. protected _update(): void;
  42180. /**
  42181. * Disposes of the gizmo
  42182. */
  42183. dispose(): void;
  42184. }
  42185. }
  42186. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42187. import { Observable } from "babylonjs/Misc/observable";
  42188. import { Nullable } from "babylonjs/types";
  42189. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42190. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42192. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42193. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42194. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42195. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42196. import { Scene } from "babylonjs/scene";
  42197. /**
  42198. * Single axis drag gizmo
  42199. */
  42200. export class AxisDragGizmo extends Gizmo {
  42201. /**
  42202. * Drag behavior responsible for the gizmos dragging interactions
  42203. */
  42204. dragBehavior: PointerDragBehavior;
  42205. private _pointerObserver;
  42206. /**
  42207. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42208. */
  42209. snapDistance: number;
  42210. /**
  42211. * Event that fires each time the gizmo snaps to a new location.
  42212. * * snapDistance is the the change in distance
  42213. */
  42214. onSnapObservable: Observable<{
  42215. snapDistance: number;
  42216. }>;
  42217. /** @hidden */
  42218. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42219. /** @hidden */
  42220. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42221. /**
  42222. * Creates an AxisDragGizmo
  42223. * @param gizmoLayer The utility layer the gizmo will be added to
  42224. * @param dragAxis The axis which the gizmo will be able to drag on
  42225. * @param color The color of the gizmo
  42226. */
  42227. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42228. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42229. /**
  42230. * Disposes of the gizmo
  42231. */
  42232. dispose(): void;
  42233. }
  42234. }
  42235. declare module "babylonjs/Debug/axesViewer" {
  42236. import { Vector3 } from "babylonjs/Maths/math";
  42237. import { Nullable } from "babylonjs/types";
  42238. import { Scene } from "babylonjs/scene";
  42239. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42240. /**
  42241. * The Axes viewer will show 3 axes in a specific point in space
  42242. */
  42243. export class AxesViewer {
  42244. private _xAxis;
  42245. private _yAxis;
  42246. private _zAxis;
  42247. private _scaleLinesFactor;
  42248. private _instanced;
  42249. /**
  42250. * Gets the hosting scene
  42251. */
  42252. scene: Scene;
  42253. /**
  42254. * Gets or sets a number used to scale line length
  42255. */
  42256. scaleLines: number;
  42257. /** Gets the node hierarchy used to render x-axis */
  42258. readonly xAxis: TransformNode;
  42259. /** Gets the node hierarchy used to render y-axis */
  42260. readonly yAxis: TransformNode;
  42261. /** Gets the node hierarchy used to render z-axis */
  42262. readonly zAxis: TransformNode;
  42263. /**
  42264. * Creates a new AxesViewer
  42265. * @param scene defines the hosting scene
  42266. * @param scaleLines defines a number used to scale line length (1 by default)
  42267. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42268. * @param xAxis defines the node hierarchy used to render the x-axis
  42269. * @param yAxis defines the node hierarchy used to render the y-axis
  42270. * @param zAxis defines the node hierarchy used to render the z-axis
  42271. */
  42272. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42273. /**
  42274. * Force the viewer to update
  42275. * @param position defines the position of the viewer
  42276. * @param xaxis defines the x axis of the viewer
  42277. * @param yaxis defines the y axis of the viewer
  42278. * @param zaxis defines the z axis of the viewer
  42279. */
  42280. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42281. /**
  42282. * Creates an instance of this axes viewer.
  42283. * @returns a new axes viewer with instanced meshes
  42284. */
  42285. createInstance(): AxesViewer;
  42286. /** Releases resources */
  42287. dispose(): void;
  42288. private static _SetRenderingGroupId;
  42289. }
  42290. }
  42291. declare module "babylonjs/Debug/boneAxesViewer" {
  42292. import { Nullable } from "babylonjs/types";
  42293. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42294. import { Vector3 } from "babylonjs/Maths/math";
  42295. import { Mesh } from "babylonjs/Meshes/mesh";
  42296. import { Bone } from "babylonjs/Bones/bone";
  42297. import { Scene } from "babylonjs/scene";
  42298. /**
  42299. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42300. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42301. */
  42302. export class BoneAxesViewer extends AxesViewer {
  42303. /**
  42304. * Gets or sets the target mesh where to display the axes viewer
  42305. */
  42306. mesh: Nullable<Mesh>;
  42307. /**
  42308. * Gets or sets the target bone where to display the axes viewer
  42309. */
  42310. bone: Nullable<Bone>;
  42311. /** Gets current position */
  42312. pos: Vector3;
  42313. /** Gets direction of X axis */
  42314. xaxis: Vector3;
  42315. /** Gets direction of Y axis */
  42316. yaxis: Vector3;
  42317. /** Gets direction of Z axis */
  42318. zaxis: Vector3;
  42319. /**
  42320. * Creates a new BoneAxesViewer
  42321. * @param scene defines the hosting scene
  42322. * @param bone defines the target bone
  42323. * @param mesh defines the target mesh
  42324. * @param scaleLines defines a scaling factor for line length (1 by default)
  42325. */
  42326. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42327. /**
  42328. * Force the viewer to update
  42329. */
  42330. update(): void;
  42331. /** Releases resources */
  42332. dispose(): void;
  42333. }
  42334. }
  42335. declare module "babylonjs/Debug/debugLayer" {
  42336. import { Observable } from "babylonjs/Misc/observable";
  42337. import { Scene } from "babylonjs/scene";
  42338. /**
  42339. * Interface used to define scene explorer extensibility option
  42340. */
  42341. export interface IExplorerExtensibilityOption {
  42342. /**
  42343. * Define the option label
  42344. */
  42345. label: string;
  42346. /**
  42347. * Defines the action to execute on click
  42348. */
  42349. action: (entity: any) => void;
  42350. }
  42351. /**
  42352. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42353. */
  42354. export interface IExplorerExtensibilityGroup {
  42355. /**
  42356. * Defines a predicate to test if a given type mut be extended
  42357. */
  42358. predicate: (entity: any) => boolean;
  42359. /**
  42360. * Gets the list of options added to a type
  42361. */
  42362. entries: IExplorerExtensibilityOption[];
  42363. }
  42364. /**
  42365. * Interface used to define the options to use to create the Inspector
  42366. */
  42367. export interface IInspectorOptions {
  42368. /**
  42369. * Display in overlay mode (default: false)
  42370. */
  42371. overlay?: boolean;
  42372. /**
  42373. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42374. */
  42375. globalRoot?: HTMLElement;
  42376. /**
  42377. * Display the Scene explorer
  42378. */
  42379. showExplorer?: boolean;
  42380. /**
  42381. * Display the property inspector
  42382. */
  42383. showInspector?: boolean;
  42384. /**
  42385. * Display in embed mode (both panes on the right)
  42386. */
  42387. embedMode?: boolean;
  42388. /**
  42389. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42390. */
  42391. handleResize?: boolean;
  42392. /**
  42393. * Allow the panes to popup (default: true)
  42394. */
  42395. enablePopup?: boolean;
  42396. /**
  42397. * Allow the panes to be closed by users (default: true)
  42398. */
  42399. enableClose?: boolean;
  42400. /**
  42401. * Optional list of extensibility entries
  42402. */
  42403. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42404. /**
  42405. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42406. */
  42407. inspectorURL?: string;
  42408. }
  42409. module "babylonjs/scene" {
  42410. interface Scene {
  42411. /**
  42412. * @hidden
  42413. * Backing field
  42414. */
  42415. _debugLayer: DebugLayer;
  42416. /**
  42417. * Gets the debug layer (aka Inspector) associated with the scene
  42418. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42419. */
  42420. debugLayer: DebugLayer;
  42421. }
  42422. }
  42423. /**
  42424. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42425. * what is happening in your scene
  42426. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42427. */
  42428. export class DebugLayer {
  42429. /**
  42430. * Define the url to get the inspector script from.
  42431. * By default it uses the babylonjs CDN.
  42432. * @ignoreNaming
  42433. */
  42434. static InspectorURL: string;
  42435. private _scene;
  42436. private BJSINSPECTOR;
  42437. /**
  42438. * Observable triggered when a property is changed through the inspector.
  42439. */
  42440. onPropertyChangedObservable: Observable<{
  42441. object: any;
  42442. property: string;
  42443. value: any;
  42444. initialValue: any;
  42445. }>;
  42446. /**
  42447. * Instantiates a new debug layer.
  42448. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42449. * what is happening in your scene
  42450. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42451. * @param scene Defines the scene to inspect
  42452. */
  42453. constructor(scene: Scene);
  42454. /** Creates the inspector window. */
  42455. private _createInspector;
  42456. /**
  42457. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42458. * @param entity defines the entity to select
  42459. * @param lineContainerTitle defines the specific block to highlight
  42460. */
  42461. select(entity: any, lineContainerTitle?: string): void;
  42462. /** Get the inspector from bundle or global */
  42463. private _getGlobalInspector;
  42464. /**
  42465. * Get if the inspector is visible or not.
  42466. * @returns true if visible otherwise, false
  42467. */
  42468. isVisible(): boolean;
  42469. /**
  42470. * Hide the inspector and close its window.
  42471. */
  42472. hide(): void;
  42473. /**
  42474. * Launch the debugLayer.
  42475. * @param config Define the configuration of the inspector
  42476. * @return a promise fulfilled when the debug layer is visible
  42477. */
  42478. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42479. }
  42480. }
  42481. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42482. import { Nullable } from "babylonjs/types";
  42483. import { Scene } from "babylonjs/scene";
  42484. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42485. import { Mesh } from "babylonjs/Meshes/mesh";
  42486. /**
  42487. * Class containing static functions to help procedurally build meshes
  42488. */
  42489. export class BoxBuilder {
  42490. /**
  42491. * Creates a box mesh
  42492. * * The parameter `size` sets the size (float) of each box side (default 1)
  42493. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42494. * * 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)
  42495. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42499. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42500. * @param name defines the name of the mesh
  42501. * @param options defines the options used to create the mesh
  42502. * @param scene defines the hosting scene
  42503. * @returns the box mesh
  42504. */
  42505. static CreateBox(name: string, options: {
  42506. size?: number;
  42507. width?: number;
  42508. height?: number;
  42509. depth?: number;
  42510. faceUV?: Vector4[];
  42511. faceColors?: Color4[];
  42512. sideOrientation?: number;
  42513. frontUVs?: Vector4;
  42514. backUVs?: Vector4;
  42515. wrap?: boolean;
  42516. topBaseAt?: number;
  42517. bottomBaseAt?: number;
  42518. updatable?: boolean;
  42519. }, scene?: Nullable<Scene>): Mesh;
  42520. }
  42521. }
  42522. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42523. import { Vector4 } from "babylonjs/Maths/math";
  42524. import { Mesh } from "babylonjs/Meshes/mesh";
  42525. /**
  42526. * Class containing static functions to help procedurally build meshes
  42527. */
  42528. export class SphereBuilder {
  42529. /**
  42530. * Creates a sphere mesh
  42531. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42532. * * 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`)
  42533. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42534. * * 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
  42535. * * 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)
  42536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42539. * @param name defines the name of the mesh
  42540. * @param options defines the options used to create the mesh
  42541. * @param scene defines the hosting scene
  42542. * @returns the sphere mesh
  42543. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42544. */
  42545. static CreateSphere(name: string, options: {
  42546. segments?: number;
  42547. diameter?: number;
  42548. diameterX?: number;
  42549. diameterY?: number;
  42550. diameterZ?: number;
  42551. arc?: number;
  42552. slice?: number;
  42553. sideOrientation?: number;
  42554. frontUVs?: Vector4;
  42555. backUVs?: Vector4;
  42556. updatable?: boolean;
  42557. }, scene: any): Mesh;
  42558. }
  42559. }
  42560. declare module "babylonjs/Debug/physicsViewer" {
  42561. import { Nullable } from "babylonjs/types";
  42562. import { Scene } from "babylonjs/scene";
  42563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42564. import { Mesh } from "babylonjs/Meshes/mesh";
  42565. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42566. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42567. /**
  42568. * Used to show the physics impostor around the specific mesh
  42569. */
  42570. export class PhysicsViewer {
  42571. /** @hidden */
  42572. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42573. /** @hidden */
  42574. protected _meshes: Array<Nullable<AbstractMesh>>;
  42575. /** @hidden */
  42576. protected _scene: Nullable<Scene>;
  42577. /** @hidden */
  42578. protected _numMeshes: number;
  42579. /** @hidden */
  42580. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42581. private _renderFunction;
  42582. private _utilityLayer;
  42583. private _debugBoxMesh;
  42584. private _debugSphereMesh;
  42585. private _debugCylinderMesh;
  42586. private _debugMaterial;
  42587. private _debugMeshMeshes;
  42588. /**
  42589. * Creates a new PhysicsViewer
  42590. * @param scene defines the hosting scene
  42591. */
  42592. constructor(scene: Scene);
  42593. /** @hidden */
  42594. protected _updateDebugMeshes(): void;
  42595. /**
  42596. * Renders a specified physic impostor
  42597. * @param impostor defines the impostor to render
  42598. * @param targetMesh defines the mesh represented by the impostor
  42599. * @returns the new debug mesh used to render the impostor
  42600. */
  42601. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42602. /**
  42603. * Hides a specified physic impostor
  42604. * @param impostor defines the impostor to hide
  42605. */
  42606. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42607. private _getDebugMaterial;
  42608. private _getDebugBoxMesh;
  42609. private _getDebugSphereMesh;
  42610. private _getDebugCylinderMesh;
  42611. private _getDebugMeshMesh;
  42612. private _getDebugMesh;
  42613. /** Releases all resources */
  42614. dispose(): void;
  42615. }
  42616. }
  42617. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42618. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42619. import { Nullable } from "babylonjs/types";
  42620. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42621. import { Scene } from "babylonjs/scene";
  42622. /**
  42623. * Class containing static functions to help procedurally build meshes
  42624. */
  42625. export class LinesBuilder {
  42626. /**
  42627. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42628. * * 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
  42629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42630. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42631. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42632. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42633. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42634. * * 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
  42635. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42637. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42638. * @param name defines the name of the new line system
  42639. * @param options defines the options used to create the line system
  42640. * @param scene defines the hosting scene
  42641. * @returns a new line system mesh
  42642. */
  42643. static CreateLineSystem(name: string, options: {
  42644. lines: Vector3[][];
  42645. updatable?: boolean;
  42646. instance?: Nullable<LinesMesh>;
  42647. colors?: Nullable<Color4[][]>;
  42648. useVertexAlpha?: boolean;
  42649. }, scene: Nullable<Scene>): LinesMesh;
  42650. /**
  42651. * Creates a line mesh
  42652. * 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
  42653. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42654. * * The parameter `points` is an array successive Vector3
  42655. * * 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
  42656. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42657. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42658. * * When updating an instance, remember that only point positions can change, not the number of points
  42659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42661. * @param name defines the name of the new line system
  42662. * @param options defines the options used to create the line system
  42663. * @param scene defines the hosting scene
  42664. * @returns a new line mesh
  42665. */
  42666. static CreateLines(name: string, options: {
  42667. points: Vector3[];
  42668. updatable?: boolean;
  42669. instance?: Nullable<LinesMesh>;
  42670. colors?: Color4[];
  42671. useVertexAlpha?: boolean;
  42672. }, scene?: Nullable<Scene>): LinesMesh;
  42673. /**
  42674. * Creates a dashed line mesh
  42675. * * 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
  42676. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42677. * * The parameter `points` is an array successive Vector3
  42678. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42679. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42680. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42681. * * 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
  42682. * * When updating an instance, remember that only point positions can change, not the number of points
  42683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42684. * @param name defines the name of the mesh
  42685. * @param options defines the options used to create the mesh
  42686. * @param scene defines the hosting scene
  42687. * @returns the dashed line mesh
  42688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42689. */
  42690. static CreateDashedLines(name: string, options: {
  42691. points: Vector3[];
  42692. dashSize?: number;
  42693. gapSize?: number;
  42694. dashNb?: number;
  42695. updatable?: boolean;
  42696. instance?: LinesMesh;
  42697. }, scene?: Nullable<Scene>): LinesMesh;
  42698. }
  42699. }
  42700. declare module "babylonjs/Debug/rayHelper" {
  42701. import { Nullable } from "babylonjs/types";
  42702. import { Ray } from "babylonjs/Culling/ray";
  42703. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42704. import { Scene } from "babylonjs/scene";
  42705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42706. import "babylonjs/Meshes/Builders/linesBuilder";
  42707. /**
  42708. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42709. * in order to better appreciate the issue one might have.
  42710. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42711. */
  42712. export class RayHelper {
  42713. /**
  42714. * Defines the ray we are currently tryin to visualize.
  42715. */
  42716. ray: Nullable<Ray>;
  42717. private _renderPoints;
  42718. private _renderLine;
  42719. private _renderFunction;
  42720. private _scene;
  42721. private _updateToMeshFunction;
  42722. private _attachedToMesh;
  42723. private _meshSpaceDirection;
  42724. private _meshSpaceOrigin;
  42725. /**
  42726. * Helper function to create a colored helper in a scene in one line.
  42727. * @param ray Defines the ray we are currently tryin to visualize
  42728. * @param scene Defines the scene the ray is used in
  42729. * @param color Defines the color we want to see the ray in
  42730. * @returns The newly created ray helper.
  42731. */
  42732. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42733. /**
  42734. * Instantiate a new ray helper.
  42735. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42736. * in order to better appreciate the issue one might have.
  42737. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42738. * @param ray Defines the ray we are currently tryin to visualize
  42739. */
  42740. constructor(ray: Ray);
  42741. /**
  42742. * Shows the ray we are willing to debug.
  42743. * @param scene Defines the scene the ray needs to be rendered in
  42744. * @param color Defines the color the ray needs to be rendered in
  42745. */
  42746. show(scene: Scene, color?: Color3): void;
  42747. /**
  42748. * Hides the ray we are debugging.
  42749. */
  42750. hide(): void;
  42751. private _render;
  42752. /**
  42753. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42754. * @param mesh Defines the mesh we want the helper attached to
  42755. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42756. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42757. * @param length Defines the length of the ray
  42758. */
  42759. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42760. /**
  42761. * Detach the ray helper from the mesh it has previously been attached to.
  42762. */
  42763. detachFromMesh(): void;
  42764. private _updateToMesh;
  42765. /**
  42766. * Dispose the helper and release its associated resources.
  42767. */
  42768. dispose(): void;
  42769. }
  42770. }
  42771. declare module "babylonjs/Debug/skeletonViewer" {
  42772. import { Color3 } from "babylonjs/Maths/math";
  42773. import { Scene } from "babylonjs/scene";
  42774. import { Nullable } from "babylonjs/types";
  42775. import { Skeleton } from "babylonjs/Bones/skeleton";
  42776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42777. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42778. /**
  42779. * Class used to render a debug view of a given skeleton
  42780. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42781. */
  42782. export class SkeletonViewer {
  42783. /** defines the skeleton to render */
  42784. skeleton: Skeleton;
  42785. /** defines the mesh attached to the skeleton */
  42786. mesh: AbstractMesh;
  42787. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42788. autoUpdateBonesMatrices: boolean;
  42789. /** defines the rendering group id to use with the viewer */
  42790. renderingGroupId: number;
  42791. /** Gets or sets the color used to render the skeleton */
  42792. color: Color3;
  42793. private _scene;
  42794. private _debugLines;
  42795. private _debugMesh;
  42796. private _isEnabled;
  42797. private _renderFunction;
  42798. private _utilityLayer;
  42799. /**
  42800. * Returns the mesh used to render the bones
  42801. */
  42802. readonly debugMesh: Nullable<LinesMesh>;
  42803. /**
  42804. * Creates a new SkeletonViewer
  42805. * @param skeleton defines the skeleton to render
  42806. * @param mesh defines the mesh attached to the skeleton
  42807. * @param scene defines the hosting scene
  42808. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42809. * @param renderingGroupId defines the rendering group id to use with the viewer
  42810. */
  42811. constructor(
  42812. /** defines the skeleton to render */
  42813. skeleton: Skeleton,
  42814. /** defines the mesh attached to the skeleton */
  42815. mesh: AbstractMesh, scene: Scene,
  42816. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42817. autoUpdateBonesMatrices?: boolean,
  42818. /** defines the rendering group id to use with the viewer */
  42819. renderingGroupId?: number);
  42820. /** Gets or sets a boolean indicating if the viewer is enabled */
  42821. isEnabled: boolean;
  42822. private _getBonePosition;
  42823. private _getLinesForBonesWithLength;
  42824. private _getLinesForBonesNoLength;
  42825. /** Update the viewer to sync with current skeleton state */
  42826. update(): void;
  42827. /** Release associated resources */
  42828. dispose(): void;
  42829. }
  42830. }
  42831. declare module "babylonjs/Debug/index" {
  42832. export * from "babylonjs/Debug/axesViewer";
  42833. export * from "babylonjs/Debug/boneAxesViewer";
  42834. export * from "babylonjs/Debug/debugLayer";
  42835. export * from "babylonjs/Debug/physicsViewer";
  42836. export * from "babylonjs/Debug/rayHelper";
  42837. export * from "babylonjs/Debug/skeletonViewer";
  42838. }
  42839. declare module "babylonjs/Engines/nullEngine" {
  42840. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42841. import { Scene } from "babylonjs/scene";
  42842. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42843. import { Engine } from "babylonjs/Engines/engine";
  42844. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42845. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42846. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42847. import { Effect } from "babylonjs/Materials/effect";
  42848. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42849. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42850. /**
  42851. * Options to create the null engine
  42852. */
  42853. export class NullEngineOptions {
  42854. /**
  42855. * Render width (Default: 512)
  42856. */
  42857. renderWidth: number;
  42858. /**
  42859. * Render height (Default: 256)
  42860. */
  42861. renderHeight: number;
  42862. /**
  42863. * Texture size (Default: 512)
  42864. */
  42865. textureSize: number;
  42866. /**
  42867. * If delta time between frames should be constant
  42868. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42869. */
  42870. deterministicLockstep: boolean;
  42871. /**
  42872. * Maximum about of steps between frames (Default: 4)
  42873. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42874. */
  42875. lockstepMaxSteps: number;
  42876. }
  42877. /**
  42878. * The null engine class provides support for headless version of babylon.js.
  42879. * This can be used in server side scenario or for testing purposes
  42880. */
  42881. export class NullEngine extends Engine {
  42882. private _options;
  42883. /**
  42884. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42885. */
  42886. isDeterministicLockStep(): boolean;
  42887. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42888. getLockstepMaxSteps(): number;
  42889. /**
  42890. * Sets hardware scaling, used to save performance if needed
  42891. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42892. */
  42893. getHardwareScalingLevel(): number;
  42894. constructor(options?: NullEngineOptions);
  42895. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42896. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42897. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42898. getRenderWidth(useScreen?: boolean): number;
  42899. getRenderHeight(useScreen?: boolean): number;
  42900. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42901. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42902. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42903. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42904. bindSamplers(effect: Effect): void;
  42905. enableEffect(effect: Effect): void;
  42906. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42907. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42908. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42909. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42910. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42911. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42912. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42913. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42914. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42915. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42916. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42917. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42918. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42919. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42920. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42921. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42922. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42923. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42924. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42925. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42926. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42927. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42928. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42929. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42930. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42931. bindBuffers(vertexBuffers: {
  42932. [key: string]: VertexBuffer;
  42933. }, indexBuffer: DataBuffer, effect: Effect): void;
  42934. wipeCaches(bruteForce?: boolean): void;
  42935. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42936. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42937. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42938. /** @hidden */
  42939. _createTexture(): WebGLTexture;
  42940. /** @hidden */
  42941. _releaseTexture(texture: InternalTexture): void;
  42942. 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;
  42943. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42944. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42945. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42946. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42947. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42948. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42949. areAllEffectsReady(): boolean;
  42950. /**
  42951. * @hidden
  42952. * Get the current error code of the webGL context
  42953. * @returns the error code
  42954. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42955. */
  42956. getError(): number;
  42957. /** @hidden */
  42958. _getUnpackAlignement(): number;
  42959. /** @hidden */
  42960. _unpackFlipY(value: boolean): void;
  42961. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42962. /**
  42963. * Updates a dynamic vertex buffer.
  42964. * @param vertexBuffer the vertex buffer to update
  42965. * @param data the data used to update the vertex buffer
  42966. * @param byteOffset the byte offset of the data (optional)
  42967. * @param byteLength the byte length of the data (optional)
  42968. */
  42969. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42970. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42971. /** @hidden */
  42972. _bindTexture(channel: number, texture: InternalTexture): void;
  42973. /** @hidden */
  42974. _releaseBuffer(buffer: DataBuffer): boolean;
  42975. releaseEffects(): void;
  42976. displayLoadingUI(): void;
  42977. hideLoadingUI(): void;
  42978. /** @hidden */
  42979. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42980. /** @hidden */
  42981. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42982. /** @hidden */
  42983. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42984. /** @hidden */
  42985. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42986. }
  42987. }
  42988. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42989. import { Nullable, int } from "babylonjs/types";
  42990. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42991. /** @hidden */
  42992. export class _OcclusionDataStorage {
  42993. /** @hidden */
  42994. occlusionInternalRetryCounter: number;
  42995. /** @hidden */
  42996. isOcclusionQueryInProgress: boolean;
  42997. /** @hidden */
  42998. isOccluded: boolean;
  42999. /** @hidden */
  43000. occlusionRetryCount: number;
  43001. /** @hidden */
  43002. occlusionType: number;
  43003. /** @hidden */
  43004. occlusionQueryAlgorithmType: number;
  43005. }
  43006. module "babylonjs/Engines/engine" {
  43007. interface Engine {
  43008. /**
  43009. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43010. * @return the new query
  43011. */
  43012. createQuery(): WebGLQuery;
  43013. /**
  43014. * Delete and release a webGL query
  43015. * @param query defines the query to delete
  43016. * @return the current engine
  43017. */
  43018. deleteQuery(query: WebGLQuery): Engine;
  43019. /**
  43020. * Check if a given query has resolved and got its value
  43021. * @param query defines the query to check
  43022. * @returns true if the query got its value
  43023. */
  43024. isQueryResultAvailable(query: WebGLQuery): boolean;
  43025. /**
  43026. * Gets the value of a given query
  43027. * @param query defines the query to check
  43028. * @returns the value of the query
  43029. */
  43030. getQueryResult(query: WebGLQuery): number;
  43031. /**
  43032. * Initiates an occlusion query
  43033. * @param algorithmType defines the algorithm to use
  43034. * @param query defines the query to use
  43035. * @returns the current engine
  43036. * @see http://doc.babylonjs.com/features/occlusionquery
  43037. */
  43038. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43039. /**
  43040. * Ends an occlusion query
  43041. * @see http://doc.babylonjs.com/features/occlusionquery
  43042. * @param algorithmType defines the algorithm to use
  43043. * @returns the current engine
  43044. */
  43045. endOcclusionQuery(algorithmType: number): Engine;
  43046. /**
  43047. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43048. * Please note that only one query can be issued at a time
  43049. * @returns a time token used to track the time span
  43050. */
  43051. startTimeQuery(): Nullable<_TimeToken>;
  43052. /**
  43053. * Ends a time query
  43054. * @param token defines the token used to measure the time span
  43055. * @returns the time spent (in ns)
  43056. */
  43057. endTimeQuery(token: _TimeToken): int;
  43058. /** @hidden */
  43059. _currentNonTimestampToken: Nullable<_TimeToken>;
  43060. /** @hidden */
  43061. _createTimeQuery(): WebGLQuery;
  43062. /** @hidden */
  43063. _deleteTimeQuery(query: WebGLQuery): void;
  43064. /** @hidden */
  43065. _getGlAlgorithmType(algorithmType: number): number;
  43066. /** @hidden */
  43067. _getTimeQueryResult(query: WebGLQuery): any;
  43068. /** @hidden */
  43069. _getTimeQueryAvailability(query: WebGLQuery): any;
  43070. }
  43071. }
  43072. module "babylonjs/Meshes/abstractMesh" {
  43073. interface AbstractMesh {
  43074. /**
  43075. * Backing filed
  43076. * @hidden
  43077. */
  43078. __occlusionDataStorage: _OcclusionDataStorage;
  43079. /**
  43080. * Access property
  43081. * @hidden
  43082. */
  43083. _occlusionDataStorage: _OcclusionDataStorage;
  43084. /**
  43085. * 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.
  43086. * The default value is -1 which means don't break the query and wait till the result
  43087. * @see http://doc.babylonjs.com/features/occlusionquery
  43088. */
  43089. occlusionRetryCount: number;
  43090. /**
  43091. * 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:
  43092. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43093. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43094. * * 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.
  43095. * @see http://doc.babylonjs.com/features/occlusionquery
  43096. */
  43097. occlusionType: number;
  43098. /**
  43099. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43100. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43101. * * 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.
  43102. * @see http://doc.babylonjs.com/features/occlusionquery
  43103. */
  43104. occlusionQueryAlgorithmType: number;
  43105. /**
  43106. * 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
  43107. * @see http://doc.babylonjs.com/features/occlusionquery
  43108. */
  43109. isOccluded: boolean;
  43110. /**
  43111. * Flag to check the progress status of the query
  43112. * @see http://doc.babylonjs.com/features/occlusionquery
  43113. */
  43114. isOcclusionQueryInProgress: boolean;
  43115. }
  43116. }
  43117. }
  43118. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43119. import { Nullable } from "babylonjs/types";
  43120. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43121. /** @hidden */
  43122. export var _forceTransformFeedbackToBundle: boolean;
  43123. module "babylonjs/Engines/engine" {
  43124. interface Engine {
  43125. /**
  43126. * Creates a webGL transform feedback object
  43127. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43128. * @returns the webGL transform feedback object
  43129. */
  43130. createTransformFeedback(): WebGLTransformFeedback;
  43131. /**
  43132. * Delete a webGL transform feedback object
  43133. * @param value defines the webGL transform feedback object to delete
  43134. */
  43135. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43136. /**
  43137. * Bind a webGL transform feedback object to the webgl context
  43138. * @param value defines the webGL transform feedback object to bind
  43139. */
  43140. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43141. /**
  43142. * Begins a transform feedback operation
  43143. * @param usePoints defines if points or triangles must be used
  43144. */
  43145. beginTransformFeedback(usePoints: boolean): void;
  43146. /**
  43147. * Ends a transform feedback operation
  43148. */
  43149. endTransformFeedback(): void;
  43150. /**
  43151. * Specify the varyings to use with transform feedback
  43152. * @param program defines the associated webGL program
  43153. * @param value defines the list of strings representing the varying names
  43154. */
  43155. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43156. /**
  43157. * Bind a webGL buffer for a transform feedback operation
  43158. * @param value defines the webGL buffer to bind
  43159. */
  43160. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43161. }
  43162. }
  43163. }
  43164. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43165. import { Scene } from "babylonjs/scene";
  43166. import { Engine } from "babylonjs/Engines/engine";
  43167. import { Texture } from "babylonjs/Materials/Textures/texture";
  43168. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43169. import "babylonjs/Engines/Extensions/engine.multiRender";
  43170. /**
  43171. * Creation options of the multi render target texture.
  43172. */
  43173. export interface IMultiRenderTargetOptions {
  43174. /**
  43175. * Define if the texture needs to create mip maps after render.
  43176. */
  43177. generateMipMaps?: boolean;
  43178. /**
  43179. * Define the types of all the draw buffers we want to create
  43180. */
  43181. types?: number[];
  43182. /**
  43183. * Define the sampling modes of all the draw buffers we want to create
  43184. */
  43185. samplingModes?: number[];
  43186. /**
  43187. * Define if a depth buffer is required
  43188. */
  43189. generateDepthBuffer?: boolean;
  43190. /**
  43191. * Define if a stencil buffer is required
  43192. */
  43193. generateStencilBuffer?: boolean;
  43194. /**
  43195. * Define if a depth texture is required instead of a depth buffer
  43196. */
  43197. generateDepthTexture?: boolean;
  43198. /**
  43199. * Define the number of desired draw buffers
  43200. */
  43201. textureCount?: number;
  43202. /**
  43203. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43204. */
  43205. doNotChangeAspectRatio?: boolean;
  43206. /**
  43207. * Define the default type of the buffers we are creating
  43208. */
  43209. defaultType?: number;
  43210. }
  43211. /**
  43212. * A multi render target, like a render target provides the ability to render to a texture.
  43213. * Unlike the render target, it can render to several draw buffers in one draw.
  43214. * This is specially interesting in deferred rendering or for any effects requiring more than
  43215. * just one color from a single pass.
  43216. */
  43217. export class MultiRenderTarget extends RenderTargetTexture {
  43218. private _internalTextures;
  43219. private _textures;
  43220. private _multiRenderTargetOptions;
  43221. /**
  43222. * Get if draw buffers are currently supported by the used hardware and browser.
  43223. */
  43224. readonly isSupported: boolean;
  43225. /**
  43226. * Get the list of textures generated by the multi render target.
  43227. */
  43228. readonly textures: Texture[];
  43229. /**
  43230. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43231. */
  43232. readonly depthTexture: Texture;
  43233. /**
  43234. * Set the wrapping mode on U of all the textures we are rendering to.
  43235. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43236. */
  43237. wrapU: number;
  43238. /**
  43239. * Set the wrapping mode on V of all the textures we are rendering to.
  43240. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43241. */
  43242. wrapV: number;
  43243. /**
  43244. * Instantiate a new multi render target texture.
  43245. * A multi render target, like a render target provides the ability to render to a texture.
  43246. * Unlike the render target, it can render to several draw buffers in one draw.
  43247. * This is specially interesting in deferred rendering or for any effects requiring more than
  43248. * just one color from a single pass.
  43249. * @param name Define the name of the texture
  43250. * @param size Define the size of the buffers to render to
  43251. * @param count Define the number of target we are rendering into
  43252. * @param scene Define the scene the texture belongs to
  43253. * @param options Define the options used to create the multi render target
  43254. */
  43255. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43256. /** @hidden */
  43257. _rebuild(): void;
  43258. private _createInternalTextures;
  43259. private _createTextures;
  43260. /**
  43261. * Define the number of samples used if MSAA is enabled.
  43262. */
  43263. samples: number;
  43264. /**
  43265. * Resize all the textures in the multi render target.
  43266. * Be carrefull as it will recreate all the data in the new texture.
  43267. * @param size Define the new size
  43268. */
  43269. resize(size: any): void;
  43270. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43271. /**
  43272. * Dispose the render targets and their associated resources
  43273. */
  43274. dispose(): void;
  43275. /**
  43276. * Release all the underlying texture used as draw buffers.
  43277. */
  43278. releaseInternalTextures(): void;
  43279. }
  43280. }
  43281. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43282. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43283. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43284. import { Nullable } from "babylonjs/types";
  43285. module "babylonjs/Engines/engine" {
  43286. interface Engine {
  43287. /**
  43288. * Unbind a list of render target textures from the webGL context
  43289. * This is used only when drawBuffer extension or webGL2 are active
  43290. * @param textures defines the render target textures to unbind
  43291. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43292. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43293. */
  43294. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43295. /**
  43296. * Create a multi render target texture
  43297. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43298. * @param size defines the size of the texture
  43299. * @param options defines the creation options
  43300. * @returns the cube texture as an InternalTexture
  43301. */
  43302. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43303. /**
  43304. * Update the sample count for a given multiple render target texture
  43305. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43306. * @param textures defines the textures to update
  43307. * @param samples defines the sample count to set
  43308. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43309. */
  43310. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43311. }
  43312. }
  43313. }
  43314. declare module "babylonjs/Engines/Extensions/index" {
  43315. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43316. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43317. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43318. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43319. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43320. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43321. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43322. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43323. }
  43324. declare module "babylonjs/Engines/index" {
  43325. export * from "babylonjs/Engines/constants";
  43326. export * from "babylonjs/Engines/engine";
  43327. export * from "babylonjs/Engines/engineStore";
  43328. export * from "babylonjs/Engines/nullEngine";
  43329. export * from "babylonjs/Engines/Extensions/index";
  43330. export * from "babylonjs/Engines/IPipelineContext";
  43331. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43332. }
  43333. declare module "babylonjs/Events/clipboardEvents" {
  43334. /**
  43335. * Gather the list of clipboard event types as constants.
  43336. */
  43337. export class ClipboardEventTypes {
  43338. /**
  43339. * The clipboard event is fired when a copy command is active (pressed).
  43340. */
  43341. static readonly COPY: number;
  43342. /**
  43343. * The clipboard event is fired when a cut command is active (pressed).
  43344. */
  43345. static readonly CUT: number;
  43346. /**
  43347. * The clipboard event is fired when a paste command is active (pressed).
  43348. */
  43349. static readonly PASTE: number;
  43350. }
  43351. /**
  43352. * This class is used to store clipboard related info for the onClipboardObservable event.
  43353. */
  43354. export class ClipboardInfo {
  43355. /**
  43356. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43357. */
  43358. type: number;
  43359. /**
  43360. * Defines the related dom event
  43361. */
  43362. event: ClipboardEvent;
  43363. /**
  43364. *Creates an instance of ClipboardInfo.
  43365. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43366. * @param event Defines the related dom event
  43367. */
  43368. constructor(
  43369. /**
  43370. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43371. */
  43372. type: number,
  43373. /**
  43374. * Defines the related dom event
  43375. */
  43376. event: ClipboardEvent);
  43377. /**
  43378. * Get the clipboard event's type from the keycode.
  43379. * @param keyCode Defines the keyCode for the current keyboard event.
  43380. * @return {number}
  43381. */
  43382. static GetTypeFromCharacter(keyCode: number): number;
  43383. }
  43384. }
  43385. declare module "babylonjs/Events/index" {
  43386. export * from "babylonjs/Events/keyboardEvents";
  43387. export * from "babylonjs/Events/pointerEvents";
  43388. export * from "babylonjs/Events/clipboardEvents";
  43389. }
  43390. declare module "babylonjs/Loading/sceneLoader" {
  43391. import { Observable } from "babylonjs/Misc/observable";
  43392. import { Nullable } from "babylonjs/types";
  43393. import { Scene } from "babylonjs/scene";
  43394. import { Engine } from "babylonjs/Engines/engine";
  43395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43396. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43397. import { AssetContainer } from "babylonjs/assetContainer";
  43398. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43399. import { Skeleton } from "babylonjs/Bones/skeleton";
  43400. /**
  43401. * Class used to represent data loading progression
  43402. */
  43403. export class SceneLoaderProgressEvent {
  43404. /** defines if data length to load can be evaluated */
  43405. readonly lengthComputable: boolean;
  43406. /** defines the loaded data length */
  43407. readonly loaded: number;
  43408. /** defines the data length to load */
  43409. readonly total: number;
  43410. /**
  43411. * Create a new progress event
  43412. * @param lengthComputable defines if data length to load can be evaluated
  43413. * @param loaded defines the loaded data length
  43414. * @param total defines the data length to load
  43415. */
  43416. constructor(
  43417. /** defines if data length to load can be evaluated */
  43418. lengthComputable: boolean,
  43419. /** defines the loaded data length */
  43420. loaded: number,
  43421. /** defines the data length to load */
  43422. total: number);
  43423. /**
  43424. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43425. * @param event defines the source event
  43426. * @returns a new SceneLoaderProgressEvent
  43427. */
  43428. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43429. }
  43430. /**
  43431. * Interface used by SceneLoader plugins to define supported file extensions
  43432. */
  43433. export interface ISceneLoaderPluginExtensions {
  43434. /**
  43435. * Defines the list of supported extensions
  43436. */
  43437. [extension: string]: {
  43438. isBinary: boolean;
  43439. };
  43440. }
  43441. /**
  43442. * Interface used by SceneLoader plugin factory
  43443. */
  43444. export interface ISceneLoaderPluginFactory {
  43445. /**
  43446. * Defines the name of the factory
  43447. */
  43448. name: string;
  43449. /**
  43450. * Function called to create a new plugin
  43451. * @return the new plugin
  43452. */
  43453. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43454. /**
  43455. * Boolean indicating if the plugin can direct load specific data
  43456. */
  43457. canDirectLoad?: (data: string) => boolean;
  43458. }
  43459. /**
  43460. * Interface used to define a SceneLoader plugin
  43461. */
  43462. export interface ISceneLoaderPlugin {
  43463. /**
  43464. * The friendly name of this plugin.
  43465. */
  43466. name: string;
  43467. /**
  43468. * The file extensions supported by this plugin.
  43469. */
  43470. extensions: string | ISceneLoaderPluginExtensions;
  43471. /**
  43472. * Import meshes into a scene.
  43473. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43474. * @param scene The scene to import into
  43475. * @param data The data to import
  43476. * @param rootUrl The root url for scene and resources
  43477. * @param meshes The meshes array to import into
  43478. * @param particleSystems The particle systems array to import into
  43479. * @param skeletons The skeletons array to import into
  43480. * @param onError The callback when import fails
  43481. * @returns True if successful or false otherwise
  43482. */
  43483. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43484. /**
  43485. * Load into a scene.
  43486. * @param scene The scene to load into
  43487. * @param data The data to import
  43488. * @param rootUrl The root url for scene and resources
  43489. * @param onError The callback when import fails
  43490. * @returns true if successful or false otherwise
  43491. */
  43492. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43493. /**
  43494. * The callback that returns true if the data can be directly loaded.
  43495. */
  43496. canDirectLoad?: (data: string) => boolean;
  43497. /**
  43498. * The callback that allows custom handling of the root url based on the response url.
  43499. */
  43500. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43501. /**
  43502. * Load into an asset container.
  43503. * @param scene The scene to load into
  43504. * @param data The data to import
  43505. * @param rootUrl The root url for scene and resources
  43506. * @param onError The callback when import fails
  43507. * @returns The loaded asset container
  43508. */
  43509. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43510. }
  43511. /**
  43512. * Interface used to define an async SceneLoader plugin
  43513. */
  43514. export interface ISceneLoaderPluginAsync {
  43515. /**
  43516. * The friendly name of this plugin.
  43517. */
  43518. name: string;
  43519. /**
  43520. * The file extensions supported by this plugin.
  43521. */
  43522. extensions: string | ISceneLoaderPluginExtensions;
  43523. /**
  43524. * Import meshes into a scene.
  43525. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43526. * @param scene The scene to import into
  43527. * @param data The data to import
  43528. * @param rootUrl The root url for scene and resources
  43529. * @param onProgress The callback when the load progresses
  43530. * @param fileName Defines the name of the file to load
  43531. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43532. */
  43533. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43534. meshes: AbstractMesh[];
  43535. particleSystems: IParticleSystem[];
  43536. skeletons: Skeleton[];
  43537. animationGroups: AnimationGroup[];
  43538. }>;
  43539. /**
  43540. * Load into a scene.
  43541. * @param scene The scene to load into
  43542. * @param data The data to import
  43543. * @param rootUrl The root url for scene and resources
  43544. * @param onProgress The callback when the load progresses
  43545. * @param fileName Defines the name of the file to load
  43546. * @returns Nothing
  43547. */
  43548. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43549. /**
  43550. * The callback that returns true if the data can be directly loaded.
  43551. */
  43552. canDirectLoad?: (data: string) => boolean;
  43553. /**
  43554. * The callback that allows custom handling of the root url based on the response url.
  43555. */
  43556. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43557. /**
  43558. * Load into an asset container.
  43559. * @param scene The scene to load into
  43560. * @param data The data to import
  43561. * @param rootUrl The root url for scene and resources
  43562. * @param onProgress The callback when the load progresses
  43563. * @param fileName Defines the name of the file to load
  43564. * @returns The loaded asset container
  43565. */
  43566. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43567. }
  43568. /**
  43569. * Class used to load scene from various file formats using registered plugins
  43570. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43571. */
  43572. export class SceneLoader {
  43573. /**
  43574. * No logging while loading
  43575. */
  43576. static readonly NO_LOGGING: number;
  43577. /**
  43578. * Minimal logging while loading
  43579. */
  43580. static readonly MINIMAL_LOGGING: number;
  43581. /**
  43582. * Summary logging while loading
  43583. */
  43584. static readonly SUMMARY_LOGGING: number;
  43585. /**
  43586. * Detailled logging while loading
  43587. */
  43588. static readonly DETAILED_LOGGING: number;
  43589. /**
  43590. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43591. */
  43592. static ForceFullSceneLoadingForIncremental: boolean;
  43593. /**
  43594. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43595. */
  43596. static ShowLoadingScreen: boolean;
  43597. /**
  43598. * Defines the current logging level (while loading the scene)
  43599. * @ignorenaming
  43600. */
  43601. static loggingLevel: number;
  43602. /**
  43603. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43604. */
  43605. static CleanBoneMatrixWeights: boolean;
  43606. /**
  43607. * Event raised when a plugin is used to load a scene
  43608. */
  43609. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43610. private static _registeredPlugins;
  43611. private static _getDefaultPlugin;
  43612. private static _getPluginForExtension;
  43613. private static _getPluginForDirectLoad;
  43614. private static _getPluginForFilename;
  43615. private static _getDirectLoad;
  43616. private static _loadData;
  43617. private static _getFileInfo;
  43618. /**
  43619. * Gets a plugin that can load the given extension
  43620. * @param extension defines the extension to load
  43621. * @returns a plugin or null if none works
  43622. */
  43623. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43624. /**
  43625. * Gets a boolean indicating that the given extension can be loaded
  43626. * @param extension defines the extension to load
  43627. * @returns true if the extension is supported
  43628. */
  43629. static IsPluginForExtensionAvailable(extension: string): boolean;
  43630. /**
  43631. * Adds a new plugin to the list of registered plugins
  43632. * @param plugin defines the plugin to add
  43633. */
  43634. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43635. /**
  43636. * Import meshes into a scene
  43637. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43638. * @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)
  43639. * @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)
  43640. * @param scene the instance of BABYLON.Scene to append to
  43641. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43642. * @param onProgress a callback with a progress event for each file being loaded
  43643. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43644. * @param pluginExtension the extension used to determine the plugin
  43645. * @returns The loaded plugin
  43646. */
  43647. 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>;
  43648. /**
  43649. * Import meshes into a scene
  43650. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43651. * @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)
  43652. * @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)
  43653. * @param scene the instance of BABYLON.Scene to append to
  43654. * @param onProgress a callback with a progress event for each file being loaded
  43655. * @param pluginExtension the extension used to determine the plugin
  43656. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43657. */
  43658. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43659. meshes: AbstractMesh[];
  43660. particleSystems: IParticleSystem[];
  43661. skeletons: Skeleton[];
  43662. animationGroups: AnimationGroup[];
  43663. }>;
  43664. /**
  43665. * Load a scene
  43666. * @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)
  43667. * @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)
  43668. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43669. * @param onSuccess a callback with the scene when import succeeds
  43670. * @param onProgress a callback with a progress event for each file being loaded
  43671. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43672. * @param pluginExtension the extension used to determine the plugin
  43673. * @returns The loaded plugin
  43674. */
  43675. 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>;
  43676. /**
  43677. * Load a scene
  43678. * @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)
  43679. * @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)
  43680. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43681. * @param onProgress a callback with a progress event for each file being loaded
  43682. * @param pluginExtension the extension used to determine the plugin
  43683. * @returns The loaded scene
  43684. */
  43685. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43686. /**
  43687. * Append a scene
  43688. * @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)
  43689. * @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)
  43690. * @param scene is the instance of BABYLON.Scene to append to
  43691. * @param onSuccess a callback with the scene when import succeeds
  43692. * @param onProgress a callback with a progress event for each file being loaded
  43693. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43694. * @param pluginExtension the extension used to determine the plugin
  43695. * @returns The loaded plugin
  43696. */
  43697. 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>;
  43698. /**
  43699. * Append a scene
  43700. * @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)
  43701. * @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)
  43702. * @param scene is the instance of BABYLON.Scene to append to
  43703. * @param onProgress a callback with a progress event for each file being loaded
  43704. * @param pluginExtension the extension used to determine the plugin
  43705. * @returns The given scene
  43706. */
  43707. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43708. /**
  43709. * Load a scene into an asset container
  43710. * @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)
  43711. * @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)
  43712. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43713. * @param onSuccess a callback with the scene when import succeeds
  43714. * @param onProgress a callback with a progress event for each file being loaded
  43715. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43716. * @param pluginExtension the extension used to determine the plugin
  43717. * @returns The loaded plugin
  43718. */
  43719. 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>;
  43720. /**
  43721. * Load a scene into an asset container
  43722. * @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)
  43723. * @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)
  43724. * @param scene is the instance of Scene to append to
  43725. * @param onProgress a callback with a progress event for each file being loaded
  43726. * @param pluginExtension the extension used to determine the plugin
  43727. * @returns The loaded asset container
  43728. */
  43729. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43730. }
  43731. }
  43732. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43733. import { Scene } from "babylonjs/scene";
  43734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43735. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43736. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43737. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43738. /**
  43739. * Google Daydream controller
  43740. */
  43741. export class DaydreamController extends WebVRController {
  43742. /**
  43743. * Base Url for the controller model.
  43744. */
  43745. static MODEL_BASE_URL: string;
  43746. /**
  43747. * File name for the controller model.
  43748. */
  43749. static MODEL_FILENAME: string;
  43750. /**
  43751. * Gamepad Id prefix used to identify Daydream Controller.
  43752. */
  43753. static readonly GAMEPAD_ID_PREFIX: string;
  43754. /**
  43755. * Creates a new DaydreamController from a gamepad
  43756. * @param vrGamepad the gamepad that the controller should be created from
  43757. */
  43758. constructor(vrGamepad: any);
  43759. /**
  43760. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43761. * @param scene scene in which to add meshes
  43762. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43763. */
  43764. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43765. /**
  43766. * Called once for each button that changed state since the last frame
  43767. * @param buttonIdx Which button index changed
  43768. * @param state New state of the button
  43769. * @param changes Which properties on the state changed since last frame
  43770. */
  43771. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43772. }
  43773. }
  43774. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43775. import { Scene } from "babylonjs/scene";
  43776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43777. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43778. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43779. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43780. /**
  43781. * Gear VR Controller
  43782. */
  43783. export class GearVRController extends WebVRController {
  43784. /**
  43785. * Base Url for the controller model.
  43786. */
  43787. static MODEL_BASE_URL: string;
  43788. /**
  43789. * File name for the controller model.
  43790. */
  43791. static MODEL_FILENAME: string;
  43792. /**
  43793. * Gamepad Id prefix used to identify this controller.
  43794. */
  43795. static readonly GAMEPAD_ID_PREFIX: string;
  43796. private readonly _buttonIndexToObservableNameMap;
  43797. /**
  43798. * Creates a new GearVRController from a gamepad
  43799. * @param vrGamepad the gamepad that the controller should be created from
  43800. */
  43801. constructor(vrGamepad: any);
  43802. /**
  43803. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43804. * @param scene scene in which to add meshes
  43805. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43806. */
  43807. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43808. /**
  43809. * Called once for each button that changed state since the last frame
  43810. * @param buttonIdx Which button index changed
  43811. * @param state New state of the button
  43812. * @param changes Which properties on the state changed since last frame
  43813. */
  43814. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43815. }
  43816. }
  43817. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43818. import { Scene } from "babylonjs/scene";
  43819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43820. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43821. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43822. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43823. /**
  43824. * Generic Controller
  43825. */
  43826. export class GenericController extends WebVRController {
  43827. /**
  43828. * Base Url for the controller model.
  43829. */
  43830. static readonly MODEL_BASE_URL: string;
  43831. /**
  43832. * File name for the controller model.
  43833. */
  43834. static readonly MODEL_FILENAME: string;
  43835. /**
  43836. * Creates a new GenericController from a gamepad
  43837. * @param vrGamepad the gamepad that the controller should be created from
  43838. */
  43839. constructor(vrGamepad: any);
  43840. /**
  43841. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43842. * @param scene scene in which to add meshes
  43843. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43844. */
  43845. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43846. /**
  43847. * Called once for each button that changed state since the last frame
  43848. * @param buttonIdx Which button index changed
  43849. * @param state New state of the button
  43850. * @param changes Which properties on the state changed since last frame
  43851. */
  43852. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43853. }
  43854. }
  43855. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43856. import { Observable } from "babylonjs/Misc/observable";
  43857. import { Scene } from "babylonjs/scene";
  43858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43859. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43860. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43861. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43862. /**
  43863. * Oculus Touch Controller
  43864. */
  43865. export class OculusTouchController extends WebVRController {
  43866. /**
  43867. * Base Url for the controller model.
  43868. */
  43869. static MODEL_BASE_URL: string;
  43870. /**
  43871. * File name for the left controller model.
  43872. */
  43873. static MODEL_LEFT_FILENAME: string;
  43874. /**
  43875. * File name for the right controller model.
  43876. */
  43877. static MODEL_RIGHT_FILENAME: string;
  43878. /**
  43879. * Fired when the secondary trigger on this controller is modified
  43880. */
  43881. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43882. /**
  43883. * Fired when the thumb rest on this controller is modified
  43884. */
  43885. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43886. /**
  43887. * Creates a new OculusTouchController from a gamepad
  43888. * @param vrGamepad the gamepad that the controller should be created from
  43889. */
  43890. constructor(vrGamepad: any);
  43891. /**
  43892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43893. * @param scene scene in which to add meshes
  43894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43895. */
  43896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43897. /**
  43898. * Fired when the A button on this controller is modified
  43899. */
  43900. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43901. /**
  43902. * Fired when the B button on this controller is modified
  43903. */
  43904. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43905. /**
  43906. * Fired when the X button on this controller is modified
  43907. */
  43908. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43909. /**
  43910. * Fired when the Y button on this controller is modified
  43911. */
  43912. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43913. /**
  43914. * Called once for each button that changed state since the last frame
  43915. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43916. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43917. * 2) secondary trigger (same)
  43918. * 3) A (right) X (left), touch, pressed = value
  43919. * 4) B / Y
  43920. * 5) thumb rest
  43921. * @param buttonIdx Which button index changed
  43922. * @param state New state of the button
  43923. * @param changes Which properties on the state changed since last frame
  43924. */
  43925. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43926. }
  43927. }
  43928. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43929. import { Scene } from "babylonjs/scene";
  43930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43931. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43932. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43933. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43934. import { Observable } from "babylonjs/Misc/observable";
  43935. /**
  43936. * Vive Controller
  43937. */
  43938. export class ViveController extends WebVRController {
  43939. /**
  43940. * Base Url for the controller model.
  43941. */
  43942. static MODEL_BASE_URL: string;
  43943. /**
  43944. * File name for the controller model.
  43945. */
  43946. static MODEL_FILENAME: string;
  43947. /**
  43948. * Creates a new ViveController from a gamepad
  43949. * @param vrGamepad the gamepad that the controller should be created from
  43950. */
  43951. constructor(vrGamepad: any);
  43952. /**
  43953. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43954. * @param scene scene in which to add meshes
  43955. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43956. */
  43957. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43958. /**
  43959. * Fired when the left button on this controller is modified
  43960. */
  43961. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43962. /**
  43963. * Fired when the right button on this controller is modified
  43964. */
  43965. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43966. /**
  43967. * Fired when the menu button on this controller is modified
  43968. */
  43969. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43970. /**
  43971. * Called once for each button that changed state since the last frame
  43972. * Vive mapping:
  43973. * 0: touchpad
  43974. * 1: trigger
  43975. * 2: left AND right buttons
  43976. * 3: menu button
  43977. * @param buttonIdx Which button index changed
  43978. * @param state New state of the button
  43979. * @param changes Which properties on the state changed since last frame
  43980. */
  43981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43982. }
  43983. }
  43984. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43985. import { Observable } from "babylonjs/Misc/observable";
  43986. import { Scene } from "babylonjs/scene";
  43987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43988. import { Ray } from "babylonjs/Culling/ray";
  43989. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43990. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43991. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43992. /**
  43993. * Defines the WindowsMotionController object that the state of the windows motion controller
  43994. */
  43995. export class WindowsMotionController extends WebVRController {
  43996. /**
  43997. * The base url used to load the left and right controller models
  43998. */
  43999. static MODEL_BASE_URL: string;
  44000. /**
  44001. * The name of the left controller model file
  44002. */
  44003. static MODEL_LEFT_FILENAME: string;
  44004. /**
  44005. * The name of the right controller model file
  44006. */
  44007. static MODEL_RIGHT_FILENAME: string;
  44008. /**
  44009. * The controller name prefix for this controller type
  44010. */
  44011. static readonly GAMEPAD_ID_PREFIX: string;
  44012. /**
  44013. * The controller id pattern for this controller type
  44014. */
  44015. private static readonly GAMEPAD_ID_PATTERN;
  44016. private _loadedMeshInfo;
  44017. private readonly _mapping;
  44018. /**
  44019. * Fired when the trackpad on this controller is clicked
  44020. */
  44021. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44022. /**
  44023. * Fired when the trackpad on this controller is modified
  44024. */
  44025. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44026. /**
  44027. * The current x and y values of this controller's trackpad
  44028. */
  44029. trackpad: StickValues;
  44030. /**
  44031. * Creates a new WindowsMotionController from a gamepad
  44032. * @param vrGamepad the gamepad that the controller should be created from
  44033. */
  44034. constructor(vrGamepad: any);
  44035. /**
  44036. * Fired when the trigger on this controller is modified
  44037. */
  44038. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44039. /**
  44040. * Fired when the menu button on this controller is modified
  44041. */
  44042. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44043. /**
  44044. * Fired when the grip button on this controller is modified
  44045. */
  44046. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44047. /**
  44048. * Fired when the thumbstick button on this controller is modified
  44049. */
  44050. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44051. /**
  44052. * Fired when the touchpad button on this controller is modified
  44053. */
  44054. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44055. /**
  44056. * Fired when the touchpad values on this controller are modified
  44057. */
  44058. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44059. private _updateTrackpad;
  44060. /**
  44061. * Called once per frame by the engine.
  44062. */
  44063. update(): void;
  44064. /**
  44065. * Called once for each button that changed state since the last frame
  44066. * @param buttonIdx Which button index changed
  44067. * @param state New state of the button
  44068. * @param changes Which properties on the state changed since last frame
  44069. */
  44070. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44071. /**
  44072. * Moves the buttons on the controller mesh based on their current state
  44073. * @param buttonName the name of the button to move
  44074. * @param buttonValue the value of the button which determines the buttons new position
  44075. */
  44076. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44077. /**
  44078. * Moves the axis on the controller mesh based on its current state
  44079. * @param axis the index of the axis
  44080. * @param axisValue the value of the axis which determines the meshes new position
  44081. * @hidden
  44082. */
  44083. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44084. /**
  44085. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44086. * @param scene scene in which to add meshes
  44087. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44088. */
  44089. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44090. /**
  44091. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44092. * can be transformed by button presses and axes values, based on this._mapping.
  44093. *
  44094. * @param scene scene in which the meshes exist
  44095. * @param meshes list of meshes that make up the controller model to process
  44096. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44097. */
  44098. private processModel;
  44099. private createMeshInfo;
  44100. /**
  44101. * Gets the ray of the controller in the direction the controller is pointing
  44102. * @param length the length the resulting ray should be
  44103. * @returns a ray in the direction the controller is pointing
  44104. */
  44105. getForwardRay(length?: number): Ray;
  44106. /**
  44107. * Disposes of the controller
  44108. */
  44109. dispose(): void;
  44110. }
  44111. }
  44112. declare module "babylonjs/Gamepads/Controllers/index" {
  44113. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44114. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44115. export * from "babylonjs/Gamepads/Controllers/genericController";
  44116. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44117. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44118. export * from "babylonjs/Gamepads/Controllers/viveController";
  44119. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44120. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44121. }
  44122. declare module "babylonjs/Gamepads/index" {
  44123. export * from "babylonjs/Gamepads/Controllers/index";
  44124. export * from "babylonjs/Gamepads/gamepad";
  44125. export * from "babylonjs/Gamepads/gamepadManager";
  44126. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44127. export * from "babylonjs/Gamepads/xboxGamepad";
  44128. }
  44129. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44130. import { Observable } from "babylonjs/Misc/observable";
  44131. import { Nullable } from "babylonjs/types";
  44132. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44134. import { Mesh } from "babylonjs/Meshes/mesh";
  44135. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44136. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44137. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44138. /**
  44139. * Single axis scale gizmo
  44140. */
  44141. export class AxisScaleGizmo extends Gizmo {
  44142. private _coloredMaterial;
  44143. /**
  44144. * Drag behavior responsible for the gizmos dragging interactions
  44145. */
  44146. dragBehavior: PointerDragBehavior;
  44147. private _pointerObserver;
  44148. /**
  44149. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44150. */
  44151. snapDistance: number;
  44152. /**
  44153. * Event that fires each time the gizmo snaps to a new location.
  44154. * * snapDistance is the the change in distance
  44155. */
  44156. onSnapObservable: Observable<{
  44157. snapDistance: number;
  44158. }>;
  44159. /**
  44160. * If the scaling operation should be done on all axis (default: false)
  44161. */
  44162. uniformScaling: boolean;
  44163. /**
  44164. * Creates an AxisScaleGizmo
  44165. * @param gizmoLayer The utility layer the gizmo will be added to
  44166. * @param dragAxis The axis which the gizmo will be able to scale on
  44167. * @param color The color of the gizmo
  44168. */
  44169. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44170. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44171. /**
  44172. * Disposes of the gizmo
  44173. */
  44174. dispose(): void;
  44175. /**
  44176. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44177. * @param mesh The mesh to replace the default mesh of the gizmo
  44178. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44179. */
  44180. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44181. }
  44182. }
  44183. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44184. import { Observable } from "babylonjs/Misc/observable";
  44185. import { Nullable } from "babylonjs/types";
  44186. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44188. import { Mesh } from "babylonjs/Meshes/mesh";
  44189. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44190. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44191. import "babylonjs/Meshes/Builders/boxBuilder";
  44192. /**
  44193. * Bounding box gizmo
  44194. */
  44195. export class BoundingBoxGizmo extends Gizmo {
  44196. private _lineBoundingBox;
  44197. private _rotateSpheresParent;
  44198. private _scaleBoxesParent;
  44199. private _boundingDimensions;
  44200. private _renderObserver;
  44201. private _pointerObserver;
  44202. private _scaleDragSpeed;
  44203. private _tmpQuaternion;
  44204. private _tmpVector;
  44205. private _tmpRotationMatrix;
  44206. /**
  44207. * 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)
  44208. */
  44209. ignoreChildren: boolean;
  44210. /**
  44211. * 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)
  44212. */
  44213. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44214. /**
  44215. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44216. */
  44217. rotationSphereSize: number;
  44218. /**
  44219. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44220. */
  44221. scaleBoxSize: number;
  44222. /**
  44223. * 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)
  44224. */
  44225. fixedDragMeshScreenSize: boolean;
  44226. /**
  44227. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44228. */
  44229. fixedDragMeshScreenSizeDistanceFactor: number;
  44230. /**
  44231. * Fired when a rotation sphere or scale box is dragged
  44232. */
  44233. onDragStartObservable: Observable<{}>;
  44234. /**
  44235. * Fired when a scale box is dragged
  44236. */
  44237. onScaleBoxDragObservable: Observable<{}>;
  44238. /**
  44239. * Fired when a scale box drag is ended
  44240. */
  44241. onScaleBoxDragEndObservable: Observable<{}>;
  44242. /**
  44243. * Fired when a rotation sphere is dragged
  44244. */
  44245. onRotationSphereDragObservable: Observable<{}>;
  44246. /**
  44247. * Fired when a rotation sphere drag is ended
  44248. */
  44249. onRotationSphereDragEndObservable: Observable<{}>;
  44250. /**
  44251. * 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)
  44252. */
  44253. scalePivot: Nullable<Vector3>;
  44254. /**
  44255. * Mesh used as a pivot to rotate the attached mesh
  44256. */
  44257. private _anchorMesh;
  44258. private _existingMeshScale;
  44259. private _dragMesh;
  44260. private pointerDragBehavior;
  44261. private coloredMaterial;
  44262. private hoverColoredMaterial;
  44263. /**
  44264. * Sets the color of the bounding box gizmo
  44265. * @param color the color to set
  44266. */
  44267. setColor(color: Color3): void;
  44268. /**
  44269. * Creates an BoundingBoxGizmo
  44270. * @param gizmoLayer The utility layer the gizmo will be added to
  44271. * @param color The color of the gizmo
  44272. */
  44273. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44274. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44275. private _selectNode;
  44276. /**
  44277. * Updates the bounding box information for the Gizmo
  44278. */
  44279. updateBoundingBox(): void;
  44280. private _updateRotationSpheres;
  44281. private _updateScaleBoxes;
  44282. /**
  44283. * Enables rotation on the specified axis and disables rotation on the others
  44284. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44285. */
  44286. setEnabledRotationAxis(axis: string): void;
  44287. /**
  44288. * Enables/disables scaling
  44289. * @param enable if scaling should be enabled
  44290. */
  44291. setEnabledScaling(enable: boolean): void;
  44292. private _updateDummy;
  44293. /**
  44294. * Enables a pointer drag behavior on the bounding box of the gizmo
  44295. */
  44296. enableDragBehavior(): void;
  44297. /**
  44298. * Disposes of the gizmo
  44299. */
  44300. dispose(): void;
  44301. /**
  44302. * 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)
  44303. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44304. * @returns the bounding box mesh with the passed in mesh as a child
  44305. */
  44306. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44307. /**
  44308. * CustomMeshes are not supported by this gizmo
  44309. * @param mesh The mesh to replace the default mesh of the gizmo
  44310. */
  44311. setCustomMesh(mesh: Mesh): void;
  44312. }
  44313. }
  44314. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44315. import { Observable } from "babylonjs/Misc/observable";
  44316. import { Nullable } from "babylonjs/types";
  44317. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44319. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44320. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44321. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44322. import "babylonjs/Meshes/Builders/linesBuilder";
  44323. /**
  44324. * Single plane rotation gizmo
  44325. */
  44326. export class PlaneRotationGizmo extends Gizmo {
  44327. /**
  44328. * Drag behavior responsible for the gizmos dragging interactions
  44329. */
  44330. dragBehavior: PointerDragBehavior;
  44331. private _pointerObserver;
  44332. /**
  44333. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44334. */
  44335. snapDistance: number;
  44336. /**
  44337. * Event that fires each time the gizmo snaps to a new location.
  44338. * * snapDistance is the the change in distance
  44339. */
  44340. onSnapObservable: Observable<{
  44341. snapDistance: number;
  44342. }>;
  44343. /**
  44344. * Creates a PlaneRotationGizmo
  44345. * @param gizmoLayer The utility layer the gizmo will be added to
  44346. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44347. * @param color The color of the gizmo
  44348. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44349. */
  44350. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44351. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44352. /**
  44353. * Disposes of the gizmo
  44354. */
  44355. dispose(): void;
  44356. }
  44357. }
  44358. declare module "babylonjs/Gizmos/rotationGizmo" {
  44359. import { Observable } from "babylonjs/Misc/observable";
  44360. import { Nullable } from "babylonjs/types";
  44361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44362. import { Mesh } from "babylonjs/Meshes/mesh";
  44363. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44364. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44365. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44366. /**
  44367. * Gizmo that enables rotating a mesh along 3 axis
  44368. */
  44369. export class RotationGizmo extends Gizmo {
  44370. /**
  44371. * Internal gizmo used for interactions on the x axis
  44372. */
  44373. xGizmo: PlaneRotationGizmo;
  44374. /**
  44375. * Internal gizmo used for interactions on the y axis
  44376. */
  44377. yGizmo: PlaneRotationGizmo;
  44378. /**
  44379. * Internal gizmo used for interactions on the z axis
  44380. */
  44381. zGizmo: PlaneRotationGizmo;
  44382. /** Fires an event when any of it's sub gizmos are dragged */
  44383. onDragStartObservable: Observable<{}>;
  44384. /** Fires an event when any of it's sub gizmos are released from dragging */
  44385. onDragEndObservable: Observable<{}>;
  44386. attachedMesh: Nullable<AbstractMesh>;
  44387. /**
  44388. * Creates a RotationGizmo
  44389. * @param gizmoLayer The utility layer the gizmo will be added to
  44390. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44391. */
  44392. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44393. updateGizmoRotationToMatchAttachedMesh: boolean;
  44394. /**
  44395. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44396. */
  44397. snapDistance: number;
  44398. /**
  44399. * Ratio for the scale of the gizmo (Default: 1)
  44400. */
  44401. scaleRatio: number;
  44402. /**
  44403. * Disposes of the gizmo
  44404. */
  44405. dispose(): void;
  44406. /**
  44407. * CustomMeshes are not supported by this gizmo
  44408. * @param mesh The mesh to replace the default mesh of the gizmo
  44409. */
  44410. setCustomMesh(mesh: Mesh): void;
  44411. }
  44412. }
  44413. declare module "babylonjs/Gizmos/positionGizmo" {
  44414. import { Observable } from "babylonjs/Misc/observable";
  44415. import { Nullable } from "babylonjs/types";
  44416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44417. import { Mesh } from "babylonjs/Meshes/mesh";
  44418. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44419. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44420. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44421. /**
  44422. * Gizmo that enables dragging a mesh along 3 axis
  44423. */
  44424. export class PositionGizmo extends Gizmo {
  44425. /**
  44426. * Internal gizmo used for interactions on the x axis
  44427. */
  44428. xGizmo: AxisDragGizmo;
  44429. /**
  44430. * Internal gizmo used for interactions on the y axis
  44431. */
  44432. yGizmo: AxisDragGizmo;
  44433. /**
  44434. * Internal gizmo used for interactions on the z axis
  44435. */
  44436. zGizmo: AxisDragGizmo;
  44437. /** Fires an event when any of it's sub gizmos are dragged */
  44438. onDragStartObservable: Observable<{}>;
  44439. /** Fires an event when any of it's sub gizmos are released from dragging */
  44440. onDragEndObservable: Observable<{}>;
  44441. attachedMesh: Nullable<AbstractMesh>;
  44442. /**
  44443. * Creates a PositionGizmo
  44444. * @param gizmoLayer The utility layer the gizmo will be added to
  44445. */
  44446. constructor(gizmoLayer?: UtilityLayerRenderer);
  44447. updateGizmoRotationToMatchAttachedMesh: boolean;
  44448. /**
  44449. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44450. */
  44451. snapDistance: number;
  44452. /**
  44453. * Ratio for the scale of the gizmo (Default: 1)
  44454. */
  44455. scaleRatio: number;
  44456. /**
  44457. * Disposes of the gizmo
  44458. */
  44459. dispose(): void;
  44460. /**
  44461. * CustomMeshes are not supported by this gizmo
  44462. * @param mesh The mesh to replace the default mesh of the gizmo
  44463. */
  44464. setCustomMesh(mesh: Mesh): void;
  44465. }
  44466. }
  44467. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44468. import { Scene } from "babylonjs/scene";
  44469. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44470. import { Mesh } from "babylonjs/Meshes/mesh";
  44471. import { Nullable } from "babylonjs/types";
  44472. /**
  44473. * Class containing static functions to help procedurally build meshes
  44474. */
  44475. export class PolyhedronBuilder {
  44476. /**
  44477. * Creates a polyhedron mesh
  44478. * * 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
  44479. * * The parameter `size` (positive float, default 1) sets the polygon size
  44480. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44481. * * 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`
  44482. * * 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
  44483. * * 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)`)
  44484. * * 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
  44485. * * 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
  44486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44489. * @param name defines the name of the mesh
  44490. * @param options defines the options used to create the mesh
  44491. * @param scene defines the hosting scene
  44492. * @returns the polyhedron mesh
  44493. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44494. */
  44495. static CreatePolyhedron(name: string, options: {
  44496. type?: number;
  44497. size?: number;
  44498. sizeX?: number;
  44499. sizeY?: number;
  44500. sizeZ?: number;
  44501. custom?: any;
  44502. faceUV?: Vector4[];
  44503. faceColors?: Color4[];
  44504. flat?: boolean;
  44505. updatable?: boolean;
  44506. sideOrientation?: number;
  44507. frontUVs?: Vector4;
  44508. backUVs?: Vector4;
  44509. }, scene?: Nullable<Scene>): Mesh;
  44510. }
  44511. }
  44512. declare module "babylonjs/Gizmos/scaleGizmo" {
  44513. import { Observable } from "babylonjs/Misc/observable";
  44514. import { Nullable } from "babylonjs/types";
  44515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44516. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44517. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44518. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44519. /**
  44520. * Gizmo that enables scaling a mesh along 3 axis
  44521. */
  44522. export class ScaleGizmo extends Gizmo {
  44523. /**
  44524. * Internal gizmo used for interactions on the x axis
  44525. */
  44526. xGizmo: AxisScaleGizmo;
  44527. /**
  44528. * Internal gizmo used for interactions on the y axis
  44529. */
  44530. yGizmo: AxisScaleGizmo;
  44531. /**
  44532. * Internal gizmo used for interactions on the z axis
  44533. */
  44534. zGizmo: AxisScaleGizmo;
  44535. /**
  44536. * Internal gizmo used to scale all axis equally
  44537. */
  44538. uniformScaleGizmo: AxisScaleGizmo;
  44539. /** Fires an event when any of it's sub gizmos are dragged */
  44540. onDragStartObservable: Observable<{}>;
  44541. /** Fires an event when any of it's sub gizmos are released from dragging */
  44542. onDragEndObservable: Observable<{}>;
  44543. attachedMesh: Nullable<AbstractMesh>;
  44544. /**
  44545. * Creates a ScaleGizmo
  44546. * @param gizmoLayer The utility layer the gizmo will be added to
  44547. */
  44548. constructor(gizmoLayer?: UtilityLayerRenderer);
  44549. updateGizmoRotationToMatchAttachedMesh: boolean;
  44550. /**
  44551. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44552. */
  44553. snapDistance: number;
  44554. /**
  44555. * Ratio for the scale of the gizmo (Default: 1)
  44556. */
  44557. scaleRatio: number;
  44558. /**
  44559. * Disposes of the gizmo
  44560. */
  44561. dispose(): void;
  44562. }
  44563. }
  44564. declare module "babylonjs/Gizmos/gizmoManager" {
  44565. import { Observable } from "babylonjs/Misc/observable";
  44566. import { Nullable } from "babylonjs/types";
  44567. import { Scene, IDisposable } from "babylonjs/scene";
  44568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44569. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44570. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44571. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44572. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44573. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44574. /**
  44575. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44576. */
  44577. export class GizmoManager implements IDisposable {
  44578. private scene;
  44579. /**
  44580. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44581. */
  44582. gizmos: {
  44583. positionGizmo: Nullable<PositionGizmo>;
  44584. rotationGizmo: Nullable<RotationGizmo>;
  44585. scaleGizmo: Nullable<ScaleGizmo>;
  44586. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44587. };
  44588. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44589. clearGizmoOnEmptyPointerEvent: boolean;
  44590. /** Fires an event when the manager is attached to a mesh */
  44591. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44592. private _gizmosEnabled;
  44593. private _pointerObserver;
  44594. private _attachedMesh;
  44595. private _boundingBoxColor;
  44596. private _defaultUtilityLayer;
  44597. private _defaultKeepDepthUtilityLayer;
  44598. /**
  44599. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44600. */
  44601. boundingBoxDragBehavior: SixDofDragBehavior;
  44602. /**
  44603. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44604. */
  44605. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44606. /**
  44607. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44608. */
  44609. usePointerToAttachGizmos: boolean;
  44610. /**
  44611. * Instatiates a gizmo manager
  44612. * @param scene the scene to overlay the gizmos on top of
  44613. */
  44614. constructor(scene: Scene);
  44615. /**
  44616. * Attaches a set of gizmos to the specified mesh
  44617. * @param mesh The mesh the gizmo's should be attached to
  44618. */
  44619. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44620. /**
  44621. * If the position gizmo is enabled
  44622. */
  44623. positionGizmoEnabled: boolean;
  44624. /**
  44625. * If the rotation gizmo is enabled
  44626. */
  44627. rotationGizmoEnabled: boolean;
  44628. /**
  44629. * If the scale gizmo is enabled
  44630. */
  44631. scaleGizmoEnabled: boolean;
  44632. /**
  44633. * If the boundingBox gizmo is enabled
  44634. */
  44635. boundingBoxGizmoEnabled: boolean;
  44636. /**
  44637. * Disposes of the gizmo manager
  44638. */
  44639. dispose(): void;
  44640. }
  44641. }
  44642. declare module "babylonjs/Lights/directionalLight" {
  44643. import { Camera } from "babylonjs/Cameras/camera";
  44644. import { Scene } from "babylonjs/scene";
  44645. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44647. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44648. import { Effect } from "babylonjs/Materials/effect";
  44649. /**
  44650. * A directional light is defined by a direction (what a surprise!).
  44651. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44652. * 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.
  44653. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44654. */
  44655. export class DirectionalLight extends ShadowLight {
  44656. private _shadowFrustumSize;
  44657. /**
  44658. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44659. */
  44660. /**
  44661. * Specifies a fix frustum size for the shadow generation.
  44662. */
  44663. shadowFrustumSize: number;
  44664. private _shadowOrthoScale;
  44665. /**
  44666. * Gets the shadow projection scale against the optimal computed one.
  44667. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44668. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44669. */
  44670. /**
  44671. * Sets the shadow projection scale against the optimal computed one.
  44672. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44673. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44674. */
  44675. shadowOrthoScale: number;
  44676. /**
  44677. * Automatically compute the projection matrix to best fit (including all the casters)
  44678. * on each frame.
  44679. */
  44680. autoUpdateExtends: boolean;
  44681. private _orthoLeft;
  44682. private _orthoRight;
  44683. private _orthoTop;
  44684. private _orthoBottom;
  44685. /**
  44686. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44687. * The directional light is emitted from everywhere in the given direction.
  44688. * It can cast shadows.
  44689. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44690. * @param name The friendly name of the light
  44691. * @param direction The direction of the light
  44692. * @param scene The scene the light belongs to
  44693. */
  44694. constructor(name: string, direction: Vector3, scene: Scene);
  44695. /**
  44696. * Returns the string "DirectionalLight".
  44697. * @return The class name
  44698. */
  44699. getClassName(): string;
  44700. /**
  44701. * Returns the integer 1.
  44702. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44703. */
  44704. getTypeID(): number;
  44705. /**
  44706. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44707. * Returns the DirectionalLight Shadow projection matrix.
  44708. */
  44709. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44710. /**
  44711. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44712. * Returns the DirectionalLight Shadow projection matrix.
  44713. */
  44714. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44715. /**
  44716. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44717. * Returns the DirectionalLight Shadow projection matrix.
  44718. */
  44719. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44720. protected _buildUniformLayout(): void;
  44721. /**
  44722. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44723. * @param effect The effect to update
  44724. * @param lightIndex The index of the light in the effect to update
  44725. * @returns The directional light
  44726. */
  44727. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44728. /**
  44729. * Gets the minZ used for shadow according to both the scene and the light.
  44730. *
  44731. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44732. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44733. * @param activeCamera The camera we are returning the min for
  44734. * @returns the depth min z
  44735. */
  44736. getDepthMinZ(activeCamera: Camera): number;
  44737. /**
  44738. * Gets the maxZ used for shadow according to both the scene and the light.
  44739. *
  44740. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44741. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44742. * @param activeCamera The camera we are returning the max for
  44743. * @returns the depth max z
  44744. */
  44745. getDepthMaxZ(activeCamera: Camera): number;
  44746. /**
  44747. * Prepares the list of defines specific to the light type.
  44748. * @param defines the list of defines
  44749. * @param lightIndex defines the index of the light for the effect
  44750. */
  44751. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44752. }
  44753. }
  44754. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44755. import { Mesh } from "babylonjs/Meshes/mesh";
  44756. /**
  44757. * Class containing static functions to help procedurally build meshes
  44758. */
  44759. export class HemisphereBuilder {
  44760. /**
  44761. * Creates a hemisphere mesh
  44762. * @param name defines the name of the mesh
  44763. * @param options defines the options used to create the mesh
  44764. * @param scene defines the hosting scene
  44765. * @returns the hemisphere mesh
  44766. */
  44767. static CreateHemisphere(name: string, options: {
  44768. segments?: number;
  44769. diameter?: number;
  44770. sideOrientation?: number;
  44771. }, scene: any): Mesh;
  44772. }
  44773. }
  44774. declare module "babylonjs/Lights/spotLight" {
  44775. import { Nullable } from "babylonjs/types";
  44776. import { Scene } from "babylonjs/scene";
  44777. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44779. import { Effect } from "babylonjs/Materials/effect";
  44780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44781. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44782. /**
  44783. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44784. * These values define a cone of light starting from the position, emitting toward the direction.
  44785. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44786. * and the exponent defines the speed of the decay of the light with distance (reach).
  44787. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44788. */
  44789. export class SpotLight extends ShadowLight {
  44790. private _angle;
  44791. private _innerAngle;
  44792. private _cosHalfAngle;
  44793. private _lightAngleScale;
  44794. private _lightAngleOffset;
  44795. /**
  44796. * Gets the cone angle of the spot light in Radians.
  44797. */
  44798. /**
  44799. * Sets the cone angle of the spot light in Radians.
  44800. */
  44801. angle: number;
  44802. /**
  44803. * Only used in gltf falloff mode, this defines the angle where
  44804. * the directional falloff will start before cutting at angle which could be seen
  44805. * as outer angle.
  44806. */
  44807. /**
  44808. * Only used in gltf falloff mode, this defines the angle where
  44809. * the directional falloff will start before cutting at angle which could be seen
  44810. * as outer angle.
  44811. */
  44812. innerAngle: number;
  44813. private _shadowAngleScale;
  44814. /**
  44815. * Allows scaling the angle of the light for shadow generation only.
  44816. */
  44817. /**
  44818. * Allows scaling the angle of the light for shadow generation only.
  44819. */
  44820. shadowAngleScale: number;
  44821. /**
  44822. * The light decay speed with the distance from the emission spot.
  44823. */
  44824. exponent: number;
  44825. private _projectionTextureMatrix;
  44826. /**
  44827. * Allows reading the projecton texture
  44828. */
  44829. readonly projectionTextureMatrix: Matrix;
  44830. protected _projectionTextureLightNear: number;
  44831. /**
  44832. * Gets the near clip of the Spotlight for texture projection.
  44833. */
  44834. /**
  44835. * Sets the near clip of the Spotlight for texture projection.
  44836. */
  44837. projectionTextureLightNear: number;
  44838. protected _projectionTextureLightFar: number;
  44839. /**
  44840. * Gets the far clip of the Spotlight for texture projection.
  44841. */
  44842. /**
  44843. * Sets the far clip of the Spotlight for texture projection.
  44844. */
  44845. projectionTextureLightFar: number;
  44846. protected _projectionTextureUpDirection: Vector3;
  44847. /**
  44848. * Gets the Up vector of the Spotlight for texture projection.
  44849. */
  44850. /**
  44851. * Sets the Up vector of the Spotlight for texture projection.
  44852. */
  44853. projectionTextureUpDirection: Vector3;
  44854. private _projectionTexture;
  44855. /**
  44856. * Gets the projection texture of the light.
  44857. */
  44858. /**
  44859. * Sets the projection texture of the light.
  44860. */
  44861. projectionTexture: Nullable<BaseTexture>;
  44862. private _projectionTextureViewLightDirty;
  44863. private _projectionTextureProjectionLightDirty;
  44864. private _projectionTextureDirty;
  44865. private _projectionTextureViewTargetVector;
  44866. private _projectionTextureViewLightMatrix;
  44867. private _projectionTextureProjectionLightMatrix;
  44868. private _projectionTextureScalingMatrix;
  44869. /**
  44870. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44871. * It can cast shadows.
  44872. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44873. * @param name The light friendly name
  44874. * @param position The position of the spot light in the scene
  44875. * @param direction The direction of the light in the scene
  44876. * @param angle The cone angle of the light in Radians
  44877. * @param exponent The light decay speed with the distance from the emission spot
  44878. * @param scene The scene the lights belongs to
  44879. */
  44880. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44881. /**
  44882. * Returns the string "SpotLight".
  44883. * @returns the class name
  44884. */
  44885. getClassName(): string;
  44886. /**
  44887. * Returns the integer 2.
  44888. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44889. */
  44890. getTypeID(): number;
  44891. /**
  44892. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44893. */
  44894. protected _setDirection(value: Vector3): void;
  44895. /**
  44896. * Overrides the position setter to recompute the projection texture view light Matrix.
  44897. */
  44898. protected _setPosition(value: Vector3): void;
  44899. /**
  44900. * 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.
  44901. * Returns the SpotLight.
  44902. */
  44903. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44904. protected _computeProjectionTextureViewLightMatrix(): void;
  44905. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44906. /**
  44907. * Main function for light texture projection matrix computing.
  44908. */
  44909. protected _computeProjectionTextureMatrix(): void;
  44910. protected _buildUniformLayout(): void;
  44911. private _computeAngleValues;
  44912. /**
  44913. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44914. * @param effect The effect to update
  44915. * @param lightIndex The index of the light in the effect to update
  44916. * @returns The spot light
  44917. */
  44918. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44919. /**
  44920. * Disposes the light and the associated resources.
  44921. */
  44922. dispose(): void;
  44923. /**
  44924. * Prepares the list of defines specific to the light type.
  44925. * @param defines the list of defines
  44926. * @param lightIndex defines the index of the light for the effect
  44927. */
  44928. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44929. }
  44930. }
  44931. declare module "babylonjs/Gizmos/lightGizmo" {
  44932. import { Nullable } from "babylonjs/types";
  44933. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44934. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44935. import { Light } from "babylonjs/Lights/light";
  44936. /**
  44937. * Gizmo that enables viewing a light
  44938. */
  44939. export class LightGizmo extends Gizmo {
  44940. private _lightMesh;
  44941. private _material;
  44942. private cachedPosition;
  44943. private cachedForward;
  44944. /**
  44945. * Creates a LightGizmo
  44946. * @param gizmoLayer The utility layer the gizmo will be added to
  44947. */
  44948. constructor(gizmoLayer?: UtilityLayerRenderer);
  44949. private _light;
  44950. /**
  44951. * The light that the gizmo is attached to
  44952. */
  44953. light: Nullable<Light>;
  44954. /**
  44955. * @hidden
  44956. * Updates the gizmo to match the attached mesh's position/rotation
  44957. */
  44958. protected _update(): void;
  44959. private static _Scale;
  44960. /**
  44961. * Creates the lines for a light mesh
  44962. */
  44963. private static _createLightLines;
  44964. private static _CreateHemisphericLightMesh;
  44965. private static _CreatePointLightMesh;
  44966. private static _CreateSpotLightMesh;
  44967. private static _CreateDirectionalLightMesh;
  44968. }
  44969. }
  44970. declare module "babylonjs/Gizmos/index" {
  44971. export * from "babylonjs/Gizmos/axisDragGizmo";
  44972. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44973. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44974. export * from "babylonjs/Gizmos/gizmo";
  44975. export * from "babylonjs/Gizmos/gizmoManager";
  44976. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44977. export * from "babylonjs/Gizmos/positionGizmo";
  44978. export * from "babylonjs/Gizmos/rotationGizmo";
  44979. export * from "babylonjs/Gizmos/scaleGizmo";
  44980. export * from "babylonjs/Gizmos/lightGizmo";
  44981. }
  44982. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44983. /** @hidden */
  44984. export var backgroundFragmentDeclaration: {
  44985. name: string;
  44986. shader: string;
  44987. };
  44988. }
  44989. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44990. /** @hidden */
  44991. export var backgroundUboDeclaration: {
  44992. name: string;
  44993. shader: string;
  44994. };
  44995. }
  44996. declare module "babylonjs/Shaders/background.fragment" {
  44997. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44998. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44999. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45000. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45001. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45002. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45003. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45004. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45005. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45006. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45007. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45008. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45009. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45010. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45011. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45012. /** @hidden */
  45013. export var backgroundPixelShader: {
  45014. name: string;
  45015. shader: string;
  45016. };
  45017. }
  45018. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45019. /** @hidden */
  45020. export var backgroundVertexDeclaration: {
  45021. name: string;
  45022. shader: string;
  45023. };
  45024. }
  45025. declare module "babylonjs/Shaders/background.vertex" {
  45026. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45027. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45028. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45029. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45030. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45031. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45032. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45033. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45034. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45035. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45036. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45037. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45038. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45039. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45040. /** @hidden */
  45041. export var backgroundVertexShader: {
  45042. name: string;
  45043. shader: string;
  45044. };
  45045. }
  45046. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45047. import { Nullable, int, float } from "babylonjs/types";
  45048. import { Scene } from "babylonjs/scene";
  45049. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45050. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45052. import { Mesh } from "babylonjs/Meshes/mesh";
  45053. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45054. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45055. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45056. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45057. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45058. import "babylonjs/Shaders/background.fragment";
  45059. import "babylonjs/Shaders/background.vertex";
  45060. /**
  45061. * Background material used to create an efficient environement around your scene.
  45062. */
  45063. export class BackgroundMaterial extends PushMaterial {
  45064. /**
  45065. * Standard reflectance value at parallel view angle.
  45066. */
  45067. static StandardReflectance0: number;
  45068. /**
  45069. * Standard reflectance value at grazing angle.
  45070. */
  45071. static StandardReflectance90: number;
  45072. protected _primaryColor: Color3;
  45073. /**
  45074. * Key light Color (multiply against the environement texture)
  45075. */
  45076. primaryColor: Color3;
  45077. protected __perceptualColor: Nullable<Color3>;
  45078. /**
  45079. * Experimental Internal Use Only.
  45080. *
  45081. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45082. * This acts as a helper to set the primary color to a more "human friendly" value.
  45083. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45084. * output color as close as possible from the chosen value.
  45085. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45086. * part of lighting setup.)
  45087. */
  45088. _perceptualColor: Nullable<Color3>;
  45089. protected _primaryColorShadowLevel: float;
  45090. /**
  45091. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45092. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45093. */
  45094. primaryColorShadowLevel: float;
  45095. protected _primaryColorHighlightLevel: float;
  45096. /**
  45097. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45098. * The primary color is used at the level chosen to define what the white area would look.
  45099. */
  45100. primaryColorHighlightLevel: float;
  45101. protected _reflectionTexture: Nullable<BaseTexture>;
  45102. /**
  45103. * Reflection Texture used in the material.
  45104. * Should be author in a specific way for the best result (refer to the documentation).
  45105. */
  45106. reflectionTexture: Nullable<BaseTexture>;
  45107. protected _reflectionBlur: float;
  45108. /**
  45109. * Reflection Texture level of blur.
  45110. *
  45111. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45112. * texture twice.
  45113. */
  45114. reflectionBlur: float;
  45115. protected _diffuseTexture: Nullable<BaseTexture>;
  45116. /**
  45117. * Diffuse Texture used in the material.
  45118. * Should be author in a specific way for the best result (refer to the documentation).
  45119. */
  45120. diffuseTexture: Nullable<BaseTexture>;
  45121. protected _shadowLights: Nullable<IShadowLight[]>;
  45122. /**
  45123. * Specify the list of lights casting shadow on the material.
  45124. * All scene shadow lights will be included if null.
  45125. */
  45126. shadowLights: Nullable<IShadowLight[]>;
  45127. protected _shadowLevel: float;
  45128. /**
  45129. * Helps adjusting the shadow to a softer level if required.
  45130. * 0 means black shadows and 1 means no shadows.
  45131. */
  45132. shadowLevel: float;
  45133. protected _sceneCenter: Vector3;
  45134. /**
  45135. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45136. * It is usually zero but might be interesting to modify according to your setup.
  45137. */
  45138. sceneCenter: Vector3;
  45139. protected _opacityFresnel: boolean;
  45140. /**
  45141. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45142. * This helps ensuring a nice transition when the camera goes under the ground.
  45143. */
  45144. opacityFresnel: boolean;
  45145. protected _reflectionFresnel: boolean;
  45146. /**
  45147. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45148. * This helps adding a mirror texture on the ground.
  45149. */
  45150. reflectionFresnel: boolean;
  45151. protected _reflectionFalloffDistance: number;
  45152. /**
  45153. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45154. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45155. */
  45156. reflectionFalloffDistance: number;
  45157. protected _reflectionAmount: number;
  45158. /**
  45159. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45160. */
  45161. reflectionAmount: number;
  45162. protected _reflectionReflectance0: number;
  45163. /**
  45164. * This specifies the weight of the reflection at grazing angle.
  45165. */
  45166. reflectionReflectance0: number;
  45167. protected _reflectionReflectance90: number;
  45168. /**
  45169. * This specifies the weight of the reflection at a perpendicular point of view.
  45170. */
  45171. reflectionReflectance90: number;
  45172. /**
  45173. * Sets the reflection reflectance fresnel values according to the default standard
  45174. * empirically know to work well :-)
  45175. */
  45176. reflectionStandardFresnelWeight: number;
  45177. protected _useRGBColor: boolean;
  45178. /**
  45179. * Helps to directly use the maps channels instead of their level.
  45180. */
  45181. useRGBColor: boolean;
  45182. protected _enableNoise: boolean;
  45183. /**
  45184. * This helps reducing the banding effect that could occur on the background.
  45185. */
  45186. enableNoise: boolean;
  45187. /**
  45188. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45189. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45190. * Recommended to be keep at 1.0 except for special cases.
  45191. */
  45192. fovMultiplier: number;
  45193. private _fovMultiplier;
  45194. /**
  45195. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45196. */
  45197. useEquirectangularFOV: boolean;
  45198. private _maxSimultaneousLights;
  45199. /**
  45200. * Number of Simultaneous lights allowed on the material.
  45201. */
  45202. maxSimultaneousLights: int;
  45203. /**
  45204. * Default configuration related to image processing available in the Background Material.
  45205. */
  45206. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45207. /**
  45208. * Keep track of the image processing observer to allow dispose and replace.
  45209. */
  45210. private _imageProcessingObserver;
  45211. /**
  45212. * Attaches a new image processing configuration to the PBR Material.
  45213. * @param configuration (if null the scene configuration will be use)
  45214. */
  45215. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45216. /**
  45217. * Gets the image processing configuration used either in this material.
  45218. */
  45219. /**
  45220. * Sets the Default image processing configuration used either in the this material.
  45221. *
  45222. * If sets to null, the scene one is in use.
  45223. */
  45224. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45225. /**
  45226. * Gets wether the color curves effect is enabled.
  45227. */
  45228. /**
  45229. * Sets wether the color curves effect is enabled.
  45230. */
  45231. cameraColorCurvesEnabled: boolean;
  45232. /**
  45233. * Gets wether the color grading effect is enabled.
  45234. */
  45235. /**
  45236. * Gets wether the color grading effect is enabled.
  45237. */
  45238. cameraColorGradingEnabled: boolean;
  45239. /**
  45240. * Gets wether tonemapping is enabled or not.
  45241. */
  45242. /**
  45243. * Sets wether tonemapping is enabled or not
  45244. */
  45245. cameraToneMappingEnabled: boolean;
  45246. /**
  45247. * The camera exposure used on this material.
  45248. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45249. * This corresponds to a photographic exposure.
  45250. */
  45251. /**
  45252. * The camera exposure used on this material.
  45253. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45254. * This corresponds to a photographic exposure.
  45255. */
  45256. cameraExposure: float;
  45257. /**
  45258. * Gets The camera contrast used on this material.
  45259. */
  45260. /**
  45261. * Sets The camera contrast used on this material.
  45262. */
  45263. cameraContrast: float;
  45264. /**
  45265. * Gets the Color Grading 2D Lookup Texture.
  45266. */
  45267. /**
  45268. * Sets the Color Grading 2D Lookup Texture.
  45269. */
  45270. cameraColorGradingTexture: Nullable<BaseTexture>;
  45271. /**
  45272. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45273. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45274. * 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;
  45275. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45276. */
  45277. /**
  45278. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45279. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45280. * 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;
  45281. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45282. */
  45283. cameraColorCurves: Nullable<ColorCurves>;
  45284. /**
  45285. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45286. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45287. */
  45288. switchToBGR: boolean;
  45289. private _renderTargets;
  45290. private _reflectionControls;
  45291. private _white;
  45292. private _primaryShadowColor;
  45293. private _primaryHighlightColor;
  45294. /**
  45295. * Instantiates a Background Material in the given scene
  45296. * @param name The friendly name of the material
  45297. * @param scene The scene to add the material to
  45298. */
  45299. constructor(name: string, scene: Scene);
  45300. /**
  45301. * Gets a boolean indicating that current material needs to register RTT
  45302. */
  45303. readonly hasRenderTargetTextures: boolean;
  45304. /**
  45305. * The entire material has been created in order to prevent overdraw.
  45306. * @returns false
  45307. */
  45308. needAlphaTesting(): boolean;
  45309. /**
  45310. * The entire material has been created in order to prevent overdraw.
  45311. * @returns true if blending is enable
  45312. */
  45313. needAlphaBlending(): boolean;
  45314. /**
  45315. * Checks wether the material is ready to be rendered for a given mesh.
  45316. * @param mesh The mesh to render
  45317. * @param subMesh The submesh to check against
  45318. * @param useInstances Specify wether or not the material is used with instances
  45319. * @returns true if all the dependencies are ready (Textures, Effects...)
  45320. */
  45321. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45322. /**
  45323. * Compute the primary color according to the chosen perceptual color.
  45324. */
  45325. private _computePrimaryColorFromPerceptualColor;
  45326. /**
  45327. * Compute the highlights and shadow colors according to their chosen levels.
  45328. */
  45329. private _computePrimaryColors;
  45330. /**
  45331. * Build the uniform buffer used in the material.
  45332. */
  45333. buildUniformLayout(): void;
  45334. /**
  45335. * Unbind the material.
  45336. */
  45337. unbind(): void;
  45338. /**
  45339. * Bind only the world matrix to the material.
  45340. * @param world The world matrix to bind.
  45341. */
  45342. bindOnlyWorldMatrix(world: Matrix): void;
  45343. /**
  45344. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45345. * @param world The world matrix to bind.
  45346. * @param subMesh The submesh to bind for.
  45347. */
  45348. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45349. /**
  45350. * Dispose the material.
  45351. * @param forceDisposeEffect Force disposal of the associated effect.
  45352. * @param forceDisposeTextures Force disposal of the associated textures.
  45353. */
  45354. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45355. /**
  45356. * Clones the material.
  45357. * @param name The cloned name.
  45358. * @returns The cloned material.
  45359. */
  45360. clone(name: string): BackgroundMaterial;
  45361. /**
  45362. * Serializes the current material to its JSON representation.
  45363. * @returns The JSON representation.
  45364. */
  45365. serialize(): any;
  45366. /**
  45367. * Gets the class name of the material
  45368. * @returns "BackgroundMaterial"
  45369. */
  45370. getClassName(): string;
  45371. /**
  45372. * Parse a JSON input to create back a background material.
  45373. * @param source The JSON data to parse
  45374. * @param scene The scene to create the parsed material in
  45375. * @param rootUrl The root url of the assets the material depends upon
  45376. * @returns the instantiated BackgroundMaterial.
  45377. */
  45378. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45379. }
  45380. }
  45381. declare module "babylonjs/Helpers/environmentHelper" {
  45382. import { Observable } from "babylonjs/Misc/observable";
  45383. import { Nullable } from "babylonjs/types";
  45384. import { Scene } from "babylonjs/scene";
  45385. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45387. import { Mesh } from "babylonjs/Meshes/mesh";
  45388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45389. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45390. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45391. import "babylonjs/Meshes/Builders/planeBuilder";
  45392. import "babylonjs/Meshes/Builders/boxBuilder";
  45393. /**
  45394. * Represents the different options available during the creation of
  45395. * a Environment helper.
  45396. *
  45397. * This can control the default ground, skybox and image processing setup of your scene.
  45398. */
  45399. export interface IEnvironmentHelperOptions {
  45400. /**
  45401. * Specifies wether or not to create a ground.
  45402. * True by default.
  45403. */
  45404. createGround: boolean;
  45405. /**
  45406. * Specifies the ground size.
  45407. * 15 by default.
  45408. */
  45409. groundSize: number;
  45410. /**
  45411. * The texture used on the ground for the main color.
  45412. * Comes from the BabylonJS CDN by default.
  45413. *
  45414. * Remarks: Can be either a texture or a url.
  45415. */
  45416. groundTexture: string | BaseTexture;
  45417. /**
  45418. * The color mixed in the ground texture by default.
  45419. * BabylonJS clearColor by default.
  45420. */
  45421. groundColor: Color3;
  45422. /**
  45423. * Specifies the ground opacity.
  45424. * 1 by default.
  45425. */
  45426. groundOpacity: number;
  45427. /**
  45428. * Enables the ground to receive shadows.
  45429. * True by default.
  45430. */
  45431. enableGroundShadow: boolean;
  45432. /**
  45433. * Helps preventing the shadow to be fully black on the ground.
  45434. * 0.5 by default.
  45435. */
  45436. groundShadowLevel: number;
  45437. /**
  45438. * Creates a mirror texture attach to the ground.
  45439. * false by default.
  45440. */
  45441. enableGroundMirror: boolean;
  45442. /**
  45443. * Specifies the ground mirror size ratio.
  45444. * 0.3 by default as the default kernel is 64.
  45445. */
  45446. groundMirrorSizeRatio: number;
  45447. /**
  45448. * Specifies the ground mirror blur kernel size.
  45449. * 64 by default.
  45450. */
  45451. groundMirrorBlurKernel: number;
  45452. /**
  45453. * Specifies the ground mirror visibility amount.
  45454. * 1 by default
  45455. */
  45456. groundMirrorAmount: number;
  45457. /**
  45458. * Specifies the ground mirror reflectance weight.
  45459. * This uses the standard weight of the background material to setup the fresnel effect
  45460. * of the mirror.
  45461. * 1 by default.
  45462. */
  45463. groundMirrorFresnelWeight: number;
  45464. /**
  45465. * Specifies the ground mirror Falloff distance.
  45466. * This can helps reducing the size of the reflection.
  45467. * 0 by Default.
  45468. */
  45469. groundMirrorFallOffDistance: number;
  45470. /**
  45471. * Specifies the ground mirror texture type.
  45472. * Unsigned Int by Default.
  45473. */
  45474. groundMirrorTextureType: number;
  45475. /**
  45476. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45477. * the shown objects.
  45478. */
  45479. groundYBias: number;
  45480. /**
  45481. * Specifies wether or not to create a skybox.
  45482. * True by default.
  45483. */
  45484. createSkybox: boolean;
  45485. /**
  45486. * Specifies the skybox size.
  45487. * 20 by default.
  45488. */
  45489. skyboxSize: number;
  45490. /**
  45491. * The texture used on the skybox for the main color.
  45492. * Comes from the BabylonJS CDN by default.
  45493. *
  45494. * Remarks: Can be either a texture or a url.
  45495. */
  45496. skyboxTexture: string | BaseTexture;
  45497. /**
  45498. * The color mixed in the skybox texture by default.
  45499. * BabylonJS clearColor by default.
  45500. */
  45501. skyboxColor: Color3;
  45502. /**
  45503. * The background rotation around the Y axis of the scene.
  45504. * This helps aligning the key lights of your scene with the background.
  45505. * 0 by default.
  45506. */
  45507. backgroundYRotation: number;
  45508. /**
  45509. * Compute automatically the size of the elements to best fit with the scene.
  45510. */
  45511. sizeAuto: boolean;
  45512. /**
  45513. * Default position of the rootMesh if autoSize is not true.
  45514. */
  45515. rootPosition: Vector3;
  45516. /**
  45517. * Sets up the image processing in the scene.
  45518. * true by default.
  45519. */
  45520. setupImageProcessing: boolean;
  45521. /**
  45522. * The texture used as your environment texture in the scene.
  45523. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45524. *
  45525. * Remarks: Can be either a texture or a url.
  45526. */
  45527. environmentTexture: string | BaseTexture;
  45528. /**
  45529. * The value of the exposure to apply to the scene.
  45530. * 0.6 by default if setupImageProcessing is true.
  45531. */
  45532. cameraExposure: number;
  45533. /**
  45534. * The value of the contrast to apply to the scene.
  45535. * 1.6 by default if setupImageProcessing is true.
  45536. */
  45537. cameraContrast: number;
  45538. /**
  45539. * Specifies wether or not tonemapping should be enabled in the scene.
  45540. * true by default if setupImageProcessing is true.
  45541. */
  45542. toneMappingEnabled: boolean;
  45543. }
  45544. /**
  45545. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45546. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45547. * It also helps with the default setup of your imageProcessing configuration.
  45548. */
  45549. export class EnvironmentHelper {
  45550. /**
  45551. * Default ground texture URL.
  45552. */
  45553. private static _groundTextureCDNUrl;
  45554. /**
  45555. * Default skybox texture URL.
  45556. */
  45557. private static _skyboxTextureCDNUrl;
  45558. /**
  45559. * Default environment texture URL.
  45560. */
  45561. private static _environmentTextureCDNUrl;
  45562. /**
  45563. * Creates the default options for the helper.
  45564. */
  45565. private static _getDefaultOptions;
  45566. private _rootMesh;
  45567. /**
  45568. * Gets the root mesh created by the helper.
  45569. */
  45570. readonly rootMesh: Mesh;
  45571. private _skybox;
  45572. /**
  45573. * Gets the skybox created by the helper.
  45574. */
  45575. readonly skybox: Nullable<Mesh>;
  45576. private _skyboxTexture;
  45577. /**
  45578. * Gets the skybox texture created by the helper.
  45579. */
  45580. readonly skyboxTexture: Nullable<BaseTexture>;
  45581. private _skyboxMaterial;
  45582. /**
  45583. * Gets the skybox material created by the helper.
  45584. */
  45585. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45586. private _ground;
  45587. /**
  45588. * Gets the ground mesh created by the helper.
  45589. */
  45590. readonly ground: Nullable<Mesh>;
  45591. private _groundTexture;
  45592. /**
  45593. * Gets the ground texture created by the helper.
  45594. */
  45595. readonly groundTexture: Nullable<BaseTexture>;
  45596. private _groundMirror;
  45597. /**
  45598. * Gets the ground mirror created by the helper.
  45599. */
  45600. readonly groundMirror: Nullable<MirrorTexture>;
  45601. /**
  45602. * Gets the ground mirror render list to helps pushing the meshes
  45603. * you wish in the ground reflection.
  45604. */
  45605. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45606. private _groundMaterial;
  45607. /**
  45608. * Gets the ground material created by the helper.
  45609. */
  45610. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45611. /**
  45612. * Stores the creation options.
  45613. */
  45614. private readonly _scene;
  45615. private _options;
  45616. /**
  45617. * This observable will be notified with any error during the creation of the environment,
  45618. * mainly texture creation errors.
  45619. */
  45620. onErrorObservable: Observable<{
  45621. message?: string;
  45622. exception?: any;
  45623. }>;
  45624. /**
  45625. * constructor
  45626. * @param options Defines the options we want to customize the helper
  45627. * @param scene The scene to add the material to
  45628. */
  45629. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45630. /**
  45631. * Updates the background according to the new options
  45632. * @param options
  45633. */
  45634. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45635. /**
  45636. * Sets the primary color of all the available elements.
  45637. * @param color the main color to affect to the ground and the background
  45638. */
  45639. setMainColor(color: Color3): void;
  45640. /**
  45641. * Setup the image processing according to the specified options.
  45642. */
  45643. private _setupImageProcessing;
  45644. /**
  45645. * Setup the environment texture according to the specified options.
  45646. */
  45647. private _setupEnvironmentTexture;
  45648. /**
  45649. * Setup the background according to the specified options.
  45650. */
  45651. private _setupBackground;
  45652. /**
  45653. * Get the scene sizes according to the setup.
  45654. */
  45655. private _getSceneSize;
  45656. /**
  45657. * Setup the ground according to the specified options.
  45658. */
  45659. private _setupGround;
  45660. /**
  45661. * Setup the ground material according to the specified options.
  45662. */
  45663. private _setupGroundMaterial;
  45664. /**
  45665. * Setup the ground diffuse texture according to the specified options.
  45666. */
  45667. private _setupGroundDiffuseTexture;
  45668. /**
  45669. * Setup the ground mirror texture according to the specified options.
  45670. */
  45671. private _setupGroundMirrorTexture;
  45672. /**
  45673. * Setup the ground to receive the mirror texture.
  45674. */
  45675. private _setupMirrorInGroundMaterial;
  45676. /**
  45677. * Setup the skybox according to the specified options.
  45678. */
  45679. private _setupSkybox;
  45680. /**
  45681. * Setup the skybox material according to the specified options.
  45682. */
  45683. private _setupSkyboxMaterial;
  45684. /**
  45685. * Setup the skybox reflection texture according to the specified options.
  45686. */
  45687. private _setupSkyboxReflectionTexture;
  45688. private _errorHandler;
  45689. /**
  45690. * Dispose all the elements created by the Helper.
  45691. */
  45692. dispose(): void;
  45693. }
  45694. }
  45695. declare module "babylonjs/Helpers/photoDome" {
  45696. import { Observable } from "babylonjs/Misc/observable";
  45697. import { Nullable } from "babylonjs/types";
  45698. import { Scene } from "babylonjs/scene";
  45699. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45700. import { Mesh } from "babylonjs/Meshes/mesh";
  45701. import { Texture } from "babylonjs/Materials/Textures/texture";
  45702. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45703. import "babylonjs/Meshes/Builders/sphereBuilder";
  45704. /**
  45705. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45706. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45707. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45708. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45709. */
  45710. export class PhotoDome extends TransformNode {
  45711. private _useDirectMapping;
  45712. /**
  45713. * The texture being displayed on the sphere
  45714. */
  45715. protected _photoTexture: Texture;
  45716. /**
  45717. * Gets or sets the texture being displayed on the sphere
  45718. */
  45719. photoTexture: Texture;
  45720. /**
  45721. * Observable raised when an error occured while loading the 360 image
  45722. */
  45723. onLoadErrorObservable: Observable<string>;
  45724. /**
  45725. * The skybox material
  45726. */
  45727. protected _material: BackgroundMaterial;
  45728. /**
  45729. * The surface used for the skybox
  45730. */
  45731. protected _mesh: Mesh;
  45732. /**
  45733. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45734. * Also see the options.resolution property.
  45735. */
  45736. fovMultiplier: number;
  45737. /**
  45738. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45739. * @param name Element's name, child elements will append suffixes for their own names.
  45740. * @param urlsOfPhoto defines the url of the photo to display
  45741. * @param options defines an object containing optional or exposed sub element properties
  45742. * @param onError defines a callback called when an error occured while loading the texture
  45743. */
  45744. constructor(name: string, urlOfPhoto: string, options: {
  45745. resolution?: number;
  45746. size?: number;
  45747. useDirectMapping?: boolean;
  45748. faceForward?: boolean;
  45749. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45750. /**
  45751. * Releases resources associated with this node.
  45752. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45753. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45754. */
  45755. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45756. }
  45757. }
  45758. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45759. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45760. /** @hidden */
  45761. export var rgbdDecodePixelShader: {
  45762. name: string;
  45763. shader: string;
  45764. };
  45765. }
  45766. declare module "babylonjs/Misc/brdfTextureTools" {
  45767. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45768. import { Scene } from "babylonjs/scene";
  45769. import "babylonjs/Shaders/rgbdDecode.fragment";
  45770. /**
  45771. * Class used to host texture specific utilities
  45772. */
  45773. export class BRDFTextureTools {
  45774. /**
  45775. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45776. * @param texture the texture to expand.
  45777. */
  45778. private static _ExpandDefaultBRDFTexture;
  45779. /**
  45780. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45781. * @param scene defines the hosting scene
  45782. * @returns the environment BRDF texture
  45783. */
  45784. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45785. private static _environmentBRDFBase64Texture;
  45786. }
  45787. }
  45788. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45789. import { Nullable } from "babylonjs/types";
  45790. import { IAnimatable } from "babylonjs/Misc/tools";
  45791. import { Color3 } from "babylonjs/Maths/math";
  45792. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45793. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45794. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45795. import { Engine } from "babylonjs/Engines/engine";
  45796. import { Scene } from "babylonjs/scene";
  45797. /**
  45798. * @hidden
  45799. */
  45800. export interface IMaterialClearCoatDefines {
  45801. CLEARCOAT: boolean;
  45802. CLEARCOAT_DEFAULTIOR: boolean;
  45803. CLEARCOAT_TEXTURE: boolean;
  45804. CLEARCOAT_TEXTUREDIRECTUV: number;
  45805. CLEARCOAT_BUMP: boolean;
  45806. CLEARCOAT_BUMPDIRECTUV: number;
  45807. CLEARCOAT_TINT: boolean;
  45808. CLEARCOAT_TINT_TEXTURE: boolean;
  45809. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45810. /** @hidden */
  45811. _areTexturesDirty: boolean;
  45812. }
  45813. /**
  45814. * Define the code related to the clear coat parameters of the pbr material.
  45815. */
  45816. export class PBRClearCoatConfiguration {
  45817. /**
  45818. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45819. * The default fits with a polyurethane material.
  45820. */
  45821. private static readonly _DefaultIndiceOfRefraction;
  45822. private _isEnabled;
  45823. /**
  45824. * Defines if the clear coat is enabled in the material.
  45825. */
  45826. isEnabled: boolean;
  45827. /**
  45828. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45829. */
  45830. intensity: number;
  45831. /**
  45832. * Defines the clear coat layer roughness.
  45833. */
  45834. roughness: number;
  45835. private _indiceOfRefraction;
  45836. /**
  45837. * Defines the indice of refraction of the clear coat.
  45838. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45839. * The default fits with a polyurethane material.
  45840. * Changing the default value is more performance intensive.
  45841. */
  45842. indiceOfRefraction: number;
  45843. private _texture;
  45844. /**
  45845. * Stores the clear coat values in a texture.
  45846. */
  45847. texture: Nullable<BaseTexture>;
  45848. private _bumpTexture;
  45849. /**
  45850. * Define the clear coat specific bump texture.
  45851. */
  45852. bumpTexture: Nullable<BaseTexture>;
  45853. private _isTintEnabled;
  45854. /**
  45855. * Defines if the clear coat tint is enabled in the material.
  45856. */
  45857. isTintEnabled: boolean;
  45858. /**
  45859. * Defines the clear coat tint of the material.
  45860. * This is only use if tint is enabled
  45861. */
  45862. tintColor: Color3;
  45863. /**
  45864. * Defines the distance at which the tint color should be found in the
  45865. * clear coat media.
  45866. * This is only use if tint is enabled
  45867. */
  45868. tintColorAtDistance: number;
  45869. /**
  45870. * Defines the clear coat layer thickness.
  45871. * This is only use if tint is enabled
  45872. */
  45873. tintThickness: number;
  45874. private _tintTexture;
  45875. /**
  45876. * Stores the clear tint values in a texture.
  45877. * rgb is tint
  45878. * a is a thickness factor
  45879. */
  45880. tintTexture: Nullable<BaseTexture>;
  45881. /** @hidden */
  45882. private _internalMarkAllSubMeshesAsTexturesDirty;
  45883. /** @hidden */
  45884. _markAllSubMeshesAsTexturesDirty(): void;
  45885. /**
  45886. * Instantiate a new istance of clear coat configuration.
  45887. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45888. */
  45889. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45890. /**
  45891. * Gets wehter the submesh is ready to be used or not.
  45892. * @param defines the list of "defines" to update.
  45893. * @param scene defines the scene the material belongs to.
  45894. * @param engine defines the engine the material belongs to.
  45895. * @param disableBumpMap defines wether the material disables bump or not.
  45896. * @returns - boolean indicating that the submesh is ready or not.
  45897. */
  45898. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45899. /**
  45900. * Checks to see if a texture is used in the material.
  45901. * @param defines the list of "defines" to update.
  45902. * @param scene defines the scene to the material belongs to.
  45903. */
  45904. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45905. /**
  45906. * Binds the material data.
  45907. * @param uniformBuffer defines the Uniform buffer to fill in.
  45908. * @param scene defines the scene the material belongs to.
  45909. * @param engine defines the engine the material belongs to.
  45910. * @param disableBumpMap defines wether the material disables bump or not.
  45911. * @param isFrozen defines wether the material is frozen or not.
  45912. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45913. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45914. */
  45915. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45916. /**
  45917. * Checks to see if a texture is used in the material.
  45918. * @param texture - Base texture to use.
  45919. * @returns - Boolean specifying if a texture is used in the material.
  45920. */
  45921. hasTexture(texture: BaseTexture): boolean;
  45922. /**
  45923. * Returns an array of the actively used textures.
  45924. * @param activeTextures Array of BaseTextures
  45925. */
  45926. getActiveTextures(activeTextures: BaseTexture[]): void;
  45927. /**
  45928. * Returns the animatable textures.
  45929. * @param animatables Array of animatable textures.
  45930. */
  45931. getAnimatables(animatables: IAnimatable[]): void;
  45932. /**
  45933. * Disposes the resources of the material.
  45934. * @param forceDisposeTextures - Forces the disposal of all textures.
  45935. */
  45936. dispose(forceDisposeTextures?: boolean): void;
  45937. /**
  45938. * Get the current class name of the texture useful for serialization or dynamic coding.
  45939. * @returns "PBRClearCoatConfiguration"
  45940. */
  45941. getClassName(): string;
  45942. /**
  45943. * Add fallbacks to the effect fallbacks list.
  45944. * @param defines defines the Base texture to use.
  45945. * @param fallbacks defines the current fallback list.
  45946. * @param currentRank defines the current fallback rank.
  45947. * @returns the new fallback rank.
  45948. */
  45949. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45950. /**
  45951. * Add the required uniforms to the current list.
  45952. * @param uniforms defines the current uniform list.
  45953. */
  45954. static AddUniforms(uniforms: string[]): void;
  45955. /**
  45956. * Add the required samplers to the current list.
  45957. * @param samplers defines the current sampler list.
  45958. */
  45959. static AddSamplers(samplers: string[]): void;
  45960. /**
  45961. * Add the required uniforms to the current buffer.
  45962. * @param uniformBuffer defines the current uniform buffer.
  45963. */
  45964. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45965. /**
  45966. * Makes a duplicate of the current configuration into another one.
  45967. * @param clearCoatConfiguration define the config where to copy the info
  45968. */
  45969. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45970. /**
  45971. * Serializes this clear coat configuration.
  45972. * @returns - An object with the serialized config.
  45973. */
  45974. serialize(): any;
  45975. /**
  45976. * Parses a Clear Coat Configuration from a serialized object.
  45977. * @param source - Serialized object.
  45978. */
  45979. parse(source: any): void;
  45980. }
  45981. }
  45982. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45983. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45984. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45986. import { Vector2 } from "babylonjs/Maths/math";
  45987. import { Scene } from "babylonjs/scene";
  45988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45989. import { IAnimatable } from "babylonjs/Misc/tools";
  45990. import { Nullable } from "babylonjs/types";
  45991. /**
  45992. * @hidden
  45993. */
  45994. export interface IMaterialAnisotropicDefines {
  45995. ANISOTROPIC: boolean;
  45996. ANISOTROPIC_TEXTURE: boolean;
  45997. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45998. MAINUV1: boolean;
  45999. _areTexturesDirty: boolean;
  46000. _needUVs: boolean;
  46001. }
  46002. /**
  46003. * Define the code related to the anisotropic parameters of the pbr material.
  46004. */
  46005. export class PBRAnisotropicConfiguration {
  46006. private _isEnabled;
  46007. /**
  46008. * Defines if the anisotropy is enabled in the material.
  46009. */
  46010. isEnabled: boolean;
  46011. /**
  46012. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46013. */
  46014. intensity: number;
  46015. /**
  46016. * Defines if the effect is along the tangents, bitangents or in between.
  46017. * By default, the effect is "strectching" the highlights along the tangents.
  46018. */
  46019. direction: Vector2;
  46020. private _texture;
  46021. /**
  46022. * Stores the anisotropy values in a texture.
  46023. * rg is direction (like normal from -1 to 1)
  46024. * b is a intensity
  46025. */
  46026. texture: Nullable<BaseTexture>;
  46027. /** @hidden */
  46028. private _internalMarkAllSubMeshesAsTexturesDirty;
  46029. /** @hidden */
  46030. _markAllSubMeshesAsTexturesDirty(): void;
  46031. /**
  46032. * Instantiate a new istance of anisotropy configuration.
  46033. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46034. */
  46035. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46036. /**
  46037. * Specifies that the submesh is ready to be used.
  46038. * @param defines the list of "defines" to update.
  46039. * @param scene defines the scene the material belongs to.
  46040. * @returns - boolean indicating that the submesh is ready or not.
  46041. */
  46042. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46043. /**
  46044. * Checks to see if a texture is used in the material.
  46045. * @param defines the list of "defines" to update.
  46046. * @param mesh the mesh we are preparing the defines for.
  46047. * @param scene defines the scene the material belongs to.
  46048. */
  46049. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46050. /**
  46051. * Binds the material data.
  46052. * @param uniformBuffer defines the Uniform buffer to fill in.
  46053. * @param scene defines the scene the material belongs to.
  46054. * @param isFrozen defines wether the material is frozen or not.
  46055. */
  46056. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46057. /**
  46058. * Checks to see if a texture is used in the material.
  46059. * @param texture - Base texture to use.
  46060. * @returns - Boolean specifying if a texture is used in the material.
  46061. */
  46062. hasTexture(texture: BaseTexture): boolean;
  46063. /**
  46064. * Returns an array of the actively used textures.
  46065. * @param activeTextures Array of BaseTextures
  46066. */
  46067. getActiveTextures(activeTextures: BaseTexture[]): void;
  46068. /**
  46069. * Returns the animatable textures.
  46070. * @param animatables Array of animatable textures.
  46071. */
  46072. getAnimatables(animatables: IAnimatable[]): void;
  46073. /**
  46074. * Disposes the resources of the material.
  46075. * @param forceDisposeTextures - Forces the disposal of all textures.
  46076. */
  46077. dispose(forceDisposeTextures?: boolean): void;
  46078. /**
  46079. * Get the current class name of the texture useful for serialization or dynamic coding.
  46080. * @returns "PBRAnisotropicConfiguration"
  46081. */
  46082. getClassName(): string;
  46083. /**
  46084. * Add fallbacks to the effect fallbacks list.
  46085. * @param defines defines the Base texture to use.
  46086. * @param fallbacks defines the current fallback list.
  46087. * @param currentRank defines the current fallback rank.
  46088. * @returns the new fallback rank.
  46089. */
  46090. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46091. /**
  46092. * Add the required uniforms to the current list.
  46093. * @param uniforms defines the current uniform list.
  46094. */
  46095. static AddUniforms(uniforms: string[]): void;
  46096. /**
  46097. * Add the required uniforms to the current buffer.
  46098. * @param uniformBuffer defines the current uniform buffer.
  46099. */
  46100. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46101. /**
  46102. * Add the required samplers to the current list.
  46103. * @param samplers defines the current sampler list.
  46104. */
  46105. static AddSamplers(samplers: string[]): void;
  46106. /**
  46107. * Makes a duplicate of the current configuration into another one.
  46108. * @param anisotropicConfiguration define the config where to copy the info
  46109. */
  46110. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46111. /**
  46112. * Serializes this anisotropy configuration.
  46113. * @returns - An object with the serialized config.
  46114. */
  46115. serialize(): any;
  46116. /**
  46117. * Parses a anisotropy Configuration from a serialized object.
  46118. * @param source - Serialized object.
  46119. */
  46120. parse(source: any): void;
  46121. }
  46122. }
  46123. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46124. /**
  46125. * @hidden
  46126. */
  46127. export interface IMaterialBRDFDefines {
  46128. BRDF_V_HEIGHT_CORRELATED: boolean;
  46129. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46130. SPHERICAL_HARMONICS: boolean;
  46131. /** @hidden */
  46132. _areMiscDirty: boolean;
  46133. }
  46134. /**
  46135. * Define the code related to the BRDF parameters of the pbr material.
  46136. */
  46137. export class PBRBRDFConfiguration {
  46138. /**
  46139. * Default value used for the energy conservation.
  46140. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46141. */
  46142. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46143. /**
  46144. * Default value used for the Smith Visibility Height Correlated mode.
  46145. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46146. */
  46147. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46148. /**
  46149. * Default value used for the IBL diffuse part.
  46150. * This can help switching back to the polynomials mode globally which is a tiny bit
  46151. * less GPU intensive at the drawback of a lower quality.
  46152. */
  46153. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46154. private _useEnergyConservation;
  46155. /**
  46156. * Defines if the material uses energy conservation.
  46157. */
  46158. useEnergyConservation: boolean;
  46159. private _useSmithVisibilityHeightCorrelated;
  46160. /**
  46161. * LEGACY Mode set to false
  46162. * Defines if the material uses height smith correlated visibility term.
  46163. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46164. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46165. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46166. * Not relying on height correlated will also disable energy conservation.
  46167. */
  46168. useSmithVisibilityHeightCorrelated: boolean;
  46169. private _useSphericalHarmonics;
  46170. /**
  46171. * LEGACY Mode set to false
  46172. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46173. * diffuse part of the IBL.
  46174. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46175. * to the ground truth.
  46176. */
  46177. useSphericalHarmonics: boolean;
  46178. /** @hidden */
  46179. private _internalMarkAllSubMeshesAsMiscDirty;
  46180. /** @hidden */
  46181. _markAllSubMeshesAsMiscDirty(): void;
  46182. /**
  46183. * Instantiate a new istance of clear coat configuration.
  46184. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46185. */
  46186. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46187. /**
  46188. * Checks to see if a texture is used in the material.
  46189. * @param defines the list of "defines" to update.
  46190. */
  46191. prepareDefines(defines: IMaterialBRDFDefines): void;
  46192. /**
  46193. * Get the current class name of the texture useful for serialization or dynamic coding.
  46194. * @returns "PBRClearCoatConfiguration"
  46195. */
  46196. getClassName(): string;
  46197. /**
  46198. * Makes a duplicate of the current configuration into another one.
  46199. * @param brdfConfiguration define the config where to copy the info
  46200. */
  46201. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46202. /**
  46203. * Serializes this BRDF configuration.
  46204. * @returns - An object with the serialized config.
  46205. */
  46206. serialize(): any;
  46207. /**
  46208. * Parses a BRDF Configuration from a serialized object.
  46209. * @param source - Serialized object.
  46210. */
  46211. parse(source: any): void;
  46212. }
  46213. }
  46214. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46215. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46216. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46217. import { Color3 } from "babylonjs/Maths/math";
  46218. import { Scene } from "babylonjs/scene";
  46219. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46220. import { IAnimatable } from "babylonjs/Misc/tools";
  46221. import { Nullable } from "babylonjs/types";
  46222. /**
  46223. * @hidden
  46224. */
  46225. export interface IMaterialSheenDefines {
  46226. SHEEN: boolean;
  46227. SHEEN_TEXTURE: boolean;
  46228. SHEEN_TEXTUREDIRECTUV: number;
  46229. SHEEN_LINKWITHALBEDO: boolean;
  46230. /** @hidden */
  46231. _areTexturesDirty: boolean;
  46232. }
  46233. /**
  46234. * Define the code related to the Sheen parameters of the pbr material.
  46235. */
  46236. export class PBRSheenConfiguration {
  46237. private _isEnabled;
  46238. /**
  46239. * Defines if the material uses sheen.
  46240. */
  46241. isEnabled: boolean;
  46242. private _linkSheenWithAlbedo;
  46243. /**
  46244. * Defines if the sheen is linked to the sheen color.
  46245. */
  46246. linkSheenWithAlbedo: boolean;
  46247. /**
  46248. * Defines the sheen intensity.
  46249. */
  46250. intensity: number;
  46251. /**
  46252. * Defines the sheen color.
  46253. */
  46254. color: Color3;
  46255. private _texture;
  46256. /**
  46257. * Stores the sheen tint values in a texture.
  46258. * rgb is tint
  46259. * a is a intensity
  46260. */
  46261. texture: Nullable<BaseTexture>;
  46262. /** @hidden */
  46263. private _internalMarkAllSubMeshesAsTexturesDirty;
  46264. /** @hidden */
  46265. _markAllSubMeshesAsTexturesDirty(): void;
  46266. /**
  46267. * Instantiate a new istance of clear coat configuration.
  46268. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46269. */
  46270. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46271. /**
  46272. * Specifies that the submesh is ready to be used.
  46273. * @param defines the list of "defines" to update.
  46274. * @param scene defines the scene the material belongs to.
  46275. * @returns - boolean indicating that the submesh is ready or not.
  46276. */
  46277. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46278. /**
  46279. * Checks to see if a texture is used in the material.
  46280. * @param defines the list of "defines" to update.
  46281. * @param scene defines the scene the material belongs to.
  46282. */
  46283. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46284. /**
  46285. * Binds the material data.
  46286. * @param uniformBuffer defines the Uniform buffer to fill in.
  46287. * @param scene defines the scene the material belongs to.
  46288. * @param isFrozen defines wether the material is frozen or not.
  46289. */
  46290. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46291. /**
  46292. * Checks to see if a texture is used in the material.
  46293. * @param texture - Base texture to use.
  46294. * @returns - Boolean specifying if a texture is used in the material.
  46295. */
  46296. hasTexture(texture: BaseTexture): boolean;
  46297. /**
  46298. * Returns an array of the actively used textures.
  46299. * @param activeTextures Array of BaseTextures
  46300. */
  46301. getActiveTextures(activeTextures: BaseTexture[]): void;
  46302. /**
  46303. * Returns the animatable textures.
  46304. * @param animatables Array of animatable textures.
  46305. */
  46306. getAnimatables(animatables: IAnimatable[]): void;
  46307. /**
  46308. * Disposes the resources of the material.
  46309. * @param forceDisposeTextures - Forces the disposal of all textures.
  46310. */
  46311. dispose(forceDisposeTextures?: boolean): void;
  46312. /**
  46313. * Get the current class name of the texture useful for serialization or dynamic coding.
  46314. * @returns "PBRSheenConfiguration"
  46315. */
  46316. getClassName(): string;
  46317. /**
  46318. * Add fallbacks to the effect fallbacks list.
  46319. * @param defines defines the Base texture to use.
  46320. * @param fallbacks defines the current fallback list.
  46321. * @param currentRank defines the current fallback rank.
  46322. * @returns the new fallback rank.
  46323. */
  46324. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46325. /**
  46326. * Add the required uniforms to the current list.
  46327. * @param uniforms defines the current uniform list.
  46328. */
  46329. static AddUniforms(uniforms: string[]): void;
  46330. /**
  46331. * Add the required uniforms to the current buffer.
  46332. * @param uniformBuffer defines the current uniform buffer.
  46333. */
  46334. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46335. /**
  46336. * Add the required samplers to the current list.
  46337. * @param samplers defines the current sampler list.
  46338. */
  46339. static AddSamplers(samplers: string[]): void;
  46340. /**
  46341. * Makes a duplicate of the current configuration into another one.
  46342. * @param sheenConfiguration define the config where to copy the info
  46343. */
  46344. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46345. /**
  46346. * Serializes this BRDF configuration.
  46347. * @returns - An object with the serialized config.
  46348. */
  46349. serialize(): any;
  46350. /**
  46351. * Parses a Sheen Configuration from a serialized object.
  46352. * @param source - Serialized object.
  46353. */
  46354. parse(source: any): void;
  46355. }
  46356. }
  46357. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46358. import { Nullable } from "babylonjs/types";
  46359. import { IAnimatable } from "babylonjs/Misc/tools";
  46360. import { Color3 } from "babylonjs/Maths/math";
  46361. import { SmartArray } from "babylonjs/Misc/smartArray";
  46362. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46364. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46365. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46366. import { Engine } from "babylonjs/Engines/engine";
  46367. import { Scene } from "babylonjs/scene";
  46368. /**
  46369. * @hidden
  46370. */
  46371. export interface IMaterialSubSurfaceDefines {
  46372. SUBSURFACE: boolean;
  46373. SS_REFRACTION: boolean;
  46374. SS_TRANSLUCENCY: boolean;
  46375. SS_SCATERRING: boolean;
  46376. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46377. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46378. SS_REFRACTIONMAP_3D: boolean;
  46379. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46380. SS_LODINREFRACTIONALPHA: boolean;
  46381. SS_GAMMAREFRACTION: boolean;
  46382. SS_RGBDREFRACTION: boolean;
  46383. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46384. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46385. /** @hidden */
  46386. _areTexturesDirty: boolean;
  46387. }
  46388. /**
  46389. * Define the code related to the sub surface parameters of the pbr material.
  46390. */
  46391. export class PBRSubSurfaceConfiguration {
  46392. private _isRefractionEnabled;
  46393. /**
  46394. * Defines if the refraction is enabled in the material.
  46395. */
  46396. isRefractionEnabled: boolean;
  46397. private _isTranslucencyEnabled;
  46398. /**
  46399. * Defines if the translucency is enabled in the material.
  46400. */
  46401. isTranslucencyEnabled: boolean;
  46402. private _isScatteringEnabled;
  46403. /**
  46404. * Defines the refraction intensity of the material.
  46405. * The refraction when enabled replaces the Diffuse part of the material.
  46406. * The intensity helps transitionning between diffuse and refraction.
  46407. */
  46408. refractionIntensity: number;
  46409. /**
  46410. * Defines the translucency intensity of the material.
  46411. * When translucency has been enabled, this defines how much of the "translucency"
  46412. * is addded to the diffuse part of the material.
  46413. */
  46414. translucencyIntensity: number;
  46415. /**
  46416. * Defines the scattering intensity of the material.
  46417. * When scattering has been enabled, this defines how much of the "scattered light"
  46418. * is addded to the diffuse part of the material.
  46419. */
  46420. scatteringIntensity: number;
  46421. private _thicknessTexture;
  46422. /**
  46423. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46424. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46425. * 0 would mean minimumThickness
  46426. * 1 would mean maximumThickness
  46427. * The other channels might be use as a mask to vary the different effects intensity.
  46428. */
  46429. thicknessTexture: Nullable<BaseTexture>;
  46430. private _refractionTexture;
  46431. /**
  46432. * Defines the texture to use for refraction.
  46433. */
  46434. refractionTexture: Nullable<BaseTexture>;
  46435. private _indexOfRefraction;
  46436. /**
  46437. * Defines the indice of refraction used in the material.
  46438. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46439. */
  46440. indexOfRefraction: number;
  46441. private _invertRefractionY;
  46442. /**
  46443. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46444. */
  46445. invertRefractionY: boolean;
  46446. private _linkRefractionWithTransparency;
  46447. /**
  46448. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46449. * Materials half opaque for instance using refraction could benefit from this control.
  46450. */
  46451. linkRefractionWithTransparency: boolean;
  46452. /**
  46453. * Defines the minimum thickness stored in the thickness map.
  46454. * If no thickness map is defined, this value will be used to simulate thickness.
  46455. */
  46456. minimumThickness: number;
  46457. /**
  46458. * Defines the maximum thickness stored in the thickness map.
  46459. */
  46460. maximumThickness: number;
  46461. /**
  46462. * Defines the volume tint of the material.
  46463. * This is used for both translucency and scattering.
  46464. */
  46465. tintColor: Color3;
  46466. /**
  46467. * Defines the distance at which the tint color should be found in the media.
  46468. * This is used for refraction only.
  46469. */
  46470. tintColorAtDistance: number;
  46471. /**
  46472. * Defines how far each channel transmit through the media.
  46473. * It is defined as a color to simplify it selection.
  46474. */
  46475. diffusionDistance: Color3;
  46476. private _useMaskFromThicknessTexture;
  46477. /**
  46478. * Stores the intensity of the different subsurface effects in the thickness texture.
  46479. * * the green channel is the translucency intensity.
  46480. * * the blue channel is the scattering intensity.
  46481. * * the alpha channel is the refraction intensity.
  46482. */
  46483. useMaskFromThicknessTexture: boolean;
  46484. /** @hidden */
  46485. private _internalMarkAllSubMeshesAsTexturesDirty;
  46486. /** @hidden */
  46487. _markAllSubMeshesAsTexturesDirty(): void;
  46488. /**
  46489. * Instantiate a new istance of sub surface configuration.
  46490. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46491. */
  46492. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46493. /**
  46494. * Gets wehter the submesh is ready to be used or not.
  46495. * @param defines the list of "defines" to update.
  46496. * @param scene defines the scene the material belongs to.
  46497. * @returns - boolean indicating that the submesh is ready or not.
  46498. */
  46499. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46500. /**
  46501. * Checks to see if a texture is used in the material.
  46502. * @param defines the list of "defines" to update.
  46503. * @param scene defines the scene to the material belongs to.
  46504. */
  46505. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46506. /**
  46507. * Binds the material data.
  46508. * @param uniformBuffer defines the Uniform buffer to fill in.
  46509. * @param scene defines the scene the material belongs to.
  46510. * @param engine defines the engine the material belongs to.
  46511. * @param isFrozen defines wether the material is frozen or not.
  46512. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46513. */
  46514. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46515. /**
  46516. * Unbinds the material from the mesh.
  46517. * @param activeEffect defines the effect that should be unbound from.
  46518. * @returns true if unbound, otherwise false
  46519. */
  46520. unbind(activeEffect: Effect): boolean;
  46521. /**
  46522. * Returns the texture used for refraction or null if none is used.
  46523. * @param scene defines the scene the material belongs to.
  46524. * @returns - Refraction texture if present. If no refraction texture and refraction
  46525. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46526. */
  46527. private _getRefractionTexture;
  46528. /**
  46529. * Returns true if alpha blending should be disabled.
  46530. */
  46531. readonly disableAlphaBlending: boolean;
  46532. /**
  46533. * Fills the list of render target textures.
  46534. * @param renderTargets the list of render targets to update
  46535. */
  46536. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46537. /**
  46538. * Checks to see if a texture is used in the material.
  46539. * @param texture - Base texture to use.
  46540. * @returns - Boolean specifying if a texture is used in the material.
  46541. */
  46542. hasTexture(texture: BaseTexture): boolean;
  46543. /**
  46544. * Gets a boolean indicating that current material needs to register RTT
  46545. * @returns true if this uses a render target otherwise false.
  46546. */
  46547. hasRenderTargetTextures(): boolean;
  46548. /**
  46549. * Returns an array of the actively used textures.
  46550. * @param activeTextures Array of BaseTextures
  46551. */
  46552. getActiveTextures(activeTextures: BaseTexture[]): void;
  46553. /**
  46554. * Returns the animatable textures.
  46555. * @param animatables Array of animatable textures.
  46556. */
  46557. getAnimatables(animatables: IAnimatable[]): void;
  46558. /**
  46559. * Disposes the resources of the material.
  46560. * @param forceDisposeTextures - Forces the disposal of all textures.
  46561. */
  46562. dispose(forceDisposeTextures?: boolean): void;
  46563. /**
  46564. * Get the current class name of the texture useful for serialization or dynamic coding.
  46565. * @returns "PBRSubSurfaceConfiguration"
  46566. */
  46567. getClassName(): string;
  46568. /**
  46569. * Add fallbacks to the effect fallbacks list.
  46570. * @param defines defines the Base texture to use.
  46571. * @param fallbacks defines the current fallback list.
  46572. * @param currentRank defines the current fallback rank.
  46573. * @returns the new fallback rank.
  46574. */
  46575. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46576. /**
  46577. * Add the required uniforms to the current list.
  46578. * @param uniforms defines the current uniform list.
  46579. */
  46580. static AddUniforms(uniforms: string[]): void;
  46581. /**
  46582. * Add the required samplers to the current list.
  46583. * @param samplers defines the current sampler list.
  46584. */
  46585. static AddSamplers(samplers: string[]): void;
  46586. /**
  46587. * Add the required uniforms to the current buffer.
  46588. * @param uniformBuffer defines the current uniform buffer.
  46589. */
  46590. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46591. /**
  46592. * Makes a duplicate of the current configuration into another one.
  46593. * @param configuration define the config where to copy the info
  46594. */
  46595. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46596. /**
  46597. * Serializes this Sub Surface configuration.
  46598. * @returns - An object with the serialized config.
  46599. */
  46600. serialize(): any;
  46601. /**
  46602. * Parses a Sub Surface Configuration from a serialized object.
  46603. * @param source - Serialized object.
  46604. */
  46605. parse(source: any): void;
  46606. }
  46607. }
  46608. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46609. /** @hidden */
  46610. export var pbrFragmentDeclaration: {
  46611. name: string;
  46612. shader: string;
  46613. };
  46614. }
  46615. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46616. /** @hidden */
  46617. export var pbrUboDeclaration: {
  46618. name: string;
  46619. shader: string;
  46620. };
  46621. }
  46622. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46623. /** @hidden */
  46624. export var pbrFragmentExtraDeclaration: {
  46625. name: string;
  46626. shader: string;
  46627. };
  46628. }
  46629. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46630. /** @hidden */
  46631. export var pbrFragmentSamplersDeclaration: {
  46632. name: string;
  46633. shader: string;
  46634. };
  46635. }
  46636. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46637. /** @hidden */
  46638. export var pbrHelperFunctions: {
  46639. name: string;
  46640. shader: string;
  46641. };
  46642. }
  46643. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46644. /** @hidden */
  46645. export var harmonicsFunctions: {
  46646. name: string;
  46647. shader: string;
  46648. };
  46649. }
  46650. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46651. /** @hidden */
  46652. export var pbrDirectLightingSetupFunctions: {
  46653. name: string;
  46654. shader: string;
  46655. };
  46656. }
  46657. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46658. /** @hidden */
  46659. export var pbrDirectLightingFalloffFunctions: {
  46660. name: string;
  46661. shader: string;
  46662. };
  46663. }
  46664. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46665. /** @hidden */
  46666. export var pbrBRDFFunctions: {
  46667. name: string;
  46668. shader: string;
  46669. };
  46670. }
  46671. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46672. /** @hidden */
  46673. export var pbrDirectLightingFunctions: {
  46674. name: string;
  46675. shader: string;
  46676. };
  46677. }
  46678. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46679. /** @hidden */
  46680. export var pbrIBLFunctions: {
  46681. name: string;
  46682. shader: string;
  46683. };
  46684. }
  46685. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46686. /** @hidden */
  46687. export var pbrDebug: {
  46688. name: string;
  46689. shader: string;
  46690. };
  46691. }
  46692. declare module "babylonjs/Shaders/pbr.fragment" {
  46693. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46694. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46695. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46696. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46697. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46698. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46699. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46700. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46701. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46702. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46703. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46704. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46705. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46706. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46707. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46708. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46709. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46710. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46711. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46712. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46713. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46714. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46715. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46716. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46717. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46718. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46719. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46720. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46721. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46722. /** @hidden */
  46723. export var pbrPixelShader: {
  46724. name: string;
  46725. shader: string;
  46726. };
  46727. }
  46728. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46729. /** @hidden */
  46730. export var pbrVertexDeclaration: {
  46731. name: string;
  46732. shader: string;
  46733. };
  46734. }
  46735. declare module "babylonjs/Shaders/pbr.vertex" {
  46736. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46737. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46738. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46739. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46740. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46741. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46742. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46743. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46744. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46745. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46746. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46747. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46748. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46749. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46750. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46751. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46752. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46753. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46754. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46755. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46756. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46757. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46758. /** @hidden */
  46759. export var pbrVertexShader: {
  46760. name: string;
  46761. shader: string;
  46762. };
  46763. }
  46764. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46765. import { IAnimatable } from "babylonjs/Misc/tools";
  46766. import { Nullable } from "babylonjs/types";
  46767. import { Scene } from "babylonjs/scene";
  46768. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46769. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46771. import { Mesh } from "babylonjs/Meshes/mesh";
  46772. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46773. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46774. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46775. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46776. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46777. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46778. import { Material } from "babylonjs/Materials/material";
  46779. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46780. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46781. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46782. import "babylonjs/Shaders/pbr.fragment";
  46783. import "babylonjs/Shaders/pbr.vertex";
  46784. /**
  46785. * Manages the defines for the PBR Material.
  46786. * @hidden
  46787. */
  46788. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46789. PBR: boolean;
  46790. MAINUV1: boolean;
  46791. MAINUV2: boolean;
  46792. UV1: boolean;
  46793. UV2: boolean;
  46794. ALBEDO: boolean;
  46795. ALBEDODIRECTUV: number;
  46796. VERTEXCOLOR: boolean;
  46797. AMBIENT: boolean;
  46798. AMBIENTDIRECTUV: number;
  46799. AMBIENTINGRAYSCALE: boolean;
  46800. OPACITY: boolean;
  46801. VERTEXALPHA: boolean;
  46802. OPACITYDIRECTUV: number;
  46803. OPACITYRGB: boolean;
  46804. ALPHATEST: boolean;
  46805. DEPTHPREPASS: boolean;
  46806. ALPHABLEND: boolean;
  46807. ALPHAFROMALBEDO: boolean;
  46808. ALPHATESTVALUE: string;
  46809. SPECULAROVERALPHA: boolean;
  46810. RADIANCEOVERALPHA: boolean;
  46811. ALPHAFRESNEL: boolean;
  46812. LINEARALPHAFRESNEL: boolean;
  46813. PREMULTIPLYALPHA: boolean;
  46814. EMISSIVE: boolean;
  46815. EMISSIVEDIRECTUV: number;
  46816. REFLECTIVITY: boolean;
  46817. REFLECTIVITYDIRECTUV: number;
  46818. SPECULARTERM: boolean;
  46819. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46820. MICROSURFACEAUTOMATIC: boolean;
  46821. LODBASEDMICROSFURACE: boolean;
  46822. MICROSURFACEMAP: boolean;
  46823. MICROSURFACEMAPDIRECTUV: number;
  46824. METALLICWORKFLOW: boolean;
  46825. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46826. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46827. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46828. AOSTOREINMETALMAPRED: boolean;
  46829. ENVIRONMENTBRDF: boolean;
  46830. ENVIRONMENTBRDF_RGBD: boolean;
  46831. NORMAL: boolean;
  46832. TANGENT: boolean;
  46833. BUMP: boolean;
  46834. BUMPDIRECTUV: number;
  46835. OBJECTSPACE_NORMALMAP: boolean;
  46836. PARALLAX: boolean;
  46837. PARALLAXOCCLUSION: boolean;
  46838. NORMALXYSCALE: boolean;
  46839. LIGHTMAP: boolean;
  46840. LIGHTMAPDIRECTUV: number;
  46841. USELIGHTMAPASSHADOWMAP: boolean;
  46842. GAMMALIGHTMAP: boolean;
  46843. REFLECTION: boolean;
  46844. REFLECTIONMAP_3D: boolean;
  46845. REFLECTIONMAP_SPHERICAL: boolean;
  46846. REFLECTIONMAP_PLANAR: boolean;
  46847. REFLECTIONMAP_CUBIC: boolean;
  46848. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46849. REFLECTIONMAP_PROJECTION: boolean;
  46850. REFLECTIONMAP_SKYBOX: boolean;
  46851. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46852. REFLECTIONMAP_EXPLICIT: boolean;
  46853. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46854. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46855. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46856. INVERTCUBICMAP: boolean;
  46857. USESPHERICALFROMREFLECTIONMAP: boolean;
  46858. SPHERICAL_HARMONICS: boolean;
  46859. USESPHERICALINVERTEX: boolean;
  46860. REFLECTIONMAP_OPPOSITEZ: boolean;
  46861. LODINREFLECTIONALPHA: boolean;
  46862. GAMMAREFLECTION: boolean;
  46863. RGBDREFLECTION: boolean;
  46864. RADIANCEOCCLUSION: boolean;
  46865. HORIZONOCCLUSION: boolean;
  46866. INSTANCES: boolean;
  46867. NUM_BONE_INFLUENCERS: number;
  46868. BonesPerMesh: number;
  46869. BONETEXTURE: boolean;
  46870. NONUNIFORMSCALING: boolean;
  46871. MORPHTARGETS: boolean;
  46872. MORPHTARGETS_NORMAL: boolean;
  46873. MORPHTARGETS_TANGENT: boolean;
  46874. NUM_MORPH_INFLUENCERS: number;
  46875. IMAGEPROCESSING: boolean;
  46876. VIGNETTE: boolean;
  46877. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46878. VIGNETTEBLENDMODEOPAQUE: boolean;
  46879. TONEMAPPING: boolean;
  46880. TONEMAPPING_ACES: boolean;
  46881. CONTRAST: boolean;
  46882. COLORCURVES: boolean;
  46883. COLORGRADING: boolean;
  46884. COLORGRADING3D: boolean;
  46885. SAMPLER3DGREENDEPTH: boolean;
  46886. SAMPLER3DBGRMAP: boolean;
  46887. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46888. EXPOSURE: boolean;
  46889. MULTIVIEW: boolean;
  46890. USEPHYSICALLIGHTFALLOFF: boolean;
  46891. USEGLTFLIGHTFALLOFF: boolean;
  46892. TWOSIDEDLIGHTING: boolean;
  46893. SHADOWFLOAT: boolean;
  46894. CLIPPLANE: boolean;
  46895. CLIPPLANE2: boolean;
  46896. CLIPPLANE3: boolean;
  46897. CLIPPLANE4: boolean;
  46898. POINTSIZE: boolean;
  46899. FOG: boolean;
  46900. LOGARITHMICDEPTH: boolean;
  46901. FORCENORMALFORWARD: boolean;
  46902. SPECULARAA: boolean;
  46903. CLEARCOAT: boolean;
  46904. CLEARCOAT_DEFAULTIOR: boolean;
  46905. CLEARCOAT_TEXTURE: boolean;
  46906. CLEARCOAT_TEXTUREDIRECTUV: number;
  46907. CLEARCOAT_BUMP: boolean;
  46908. CLEARCOAT_BUMPDIRECTUV: number;
  46909. CLEARCOAT_TINT: boolean;
  46910. CLEARCOAT_TINT_TEXTURE: boolean;
  46911. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46912. ANISOTROPIC: boolean;
  46913. ANISOTROPIC_TEXTURE: boolean;
  46914. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46915. BRDF_V_HEIGHT_CORRELATED: boolean;
  46916. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46917. SHEEN: boolean;
  46918. SHEEN_TEXTURE: boolean;
  46919. SHEEN_TEXTUREDIRECTUV: number;
  46920. SHEEN_LINKWITHALBEDO: boolean;
  46921. SUBSURFACE: boolean;
  46922. SS_REFRACTION: boolean;
  46923. SS_TRANSLUCENCY: boolean;
  46924. SS_SCATERRING: boolean;
  46925. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46926. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46927. SS_REFRACTIONMAP_3D: boolean;
  46928. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46929. SS_LODINREFRACTIONALPHA: boolean;
  46930. SS_GAMMAREFRACTION: boolean;
  46931. SS_RGBDREFRACTION: boolean;
  46932. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46933. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46934. UNLIT: boolean;
  46935. DEBUGMODE: number;
  46936. /**
  46937. * Initializes the PBR Material defines.
  46938. */
  46939. constructor();
  46940. /**
  46941. * Resets the PBR Material defines.
  46942. */
  46943. reset(): void;
  46944. }
  46945. /**
  46946. * The Physically based material base class of BJS.
  46947. *
  46948. * This offers the main features of a standard PBR material.
  46949. * For more information, please refer to the documentation :
  46950. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46951. */
  46952. export abstract class PBRBaseMaterial extends PushMaterial {
  46953. /**
  46954. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46955. */
  46956. static readonly PBRMATERIAL_OPAQUE: number;
  46957. /**
  46958. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46959. */
  46960. static readonly PBRMATERIAL_ALPHATEST: number;
  46961. /**
  46962. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46963. */
  46964. static readonly PBRMATERIAL_ALPHABLEND: number;
  46965. /**
  46966. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46967. * They are also discarded below the alpha cutoff threshold to improve performances.
  46968. */
  46969. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46970. /**
  46971. * Defines the default value of how much AO map is occluding the analytical lights
  46972. * (point spot...).
  46973. */
  46974. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46975. /**
  46976. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46977. */
  46978. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46979. /**
  46980. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46981. * to enhance interoperability with other engines.
  46982. */
  46983. static readonly LIGHTFALLOFF_GLTF: number;
  46984. /**
  46985. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46986. * to enhance interoperability with other materials.
  46987. */
  46988. static readonly LIGHTFALLOFF_STANDARD: number;
  46989. /**
  46990. * Intensity of the direct lights e.g. the four lights available in your scene.
  46991. * This impacts both the direct diffuse and specular highlights.
  46992. */
  46993. protected _directIntensity: number;
  46994. /**
  46995. * Intensity of the emissive part of the material.
  46996. * This helps controlling the emissive effect without modifying the emissive color.
  46997. */
  46998. protected _emissiveIntensity: number;
  46999. /**
  47000. * Intensity of the environment e.g. how much the environment will light the object
  47001. * either through harmonics for rough material or through the refelction for shiny ones.
  47002. */
  47003. protected _environmentIntensity: number;
  47004. /**
  47005. * This is a special control allowing the reduction of the specular highlights coming from the
  47006. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47007. */
  47008. protected _specularIntensity: number;
  47009. /**
  47010. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47011. */
  47012. private _lightingInfos;
  47013. /**
  47014. * Debug Control allowing disabling the bump map on this material.
  47015. */
  47016. protected _disableBumpMap: boolean;
  47017. /**
  47018. * AKA Diffuse Texture in standard nomenclature.
  47019. */
  47020. protected _albedoTexture: Nullable<BaseTexture>;
  47021. /**
  47022. * AKA Occlusion Texture in other nomenclature.
  47023. */
  47024. protected _ambientTexture: Nullable<BaseTexture>;
  47025. /**
  47026. * AKA Occlusion Texture Intensity in other nomenclature.
  47027. */
  47028. protected _ambientTextureStrength: number;
  47029. /**
  47030. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47031. * 1 means it completely occludes it
  47032. * 0 mean it has no impact
  47033. */
  47034. protected _ambientTextureImpactOnAnalyticalLights: number;
  47035. /**
  47036. * Stores the alpha values in a texture.
  47037. */
  47038. protected _opacityTexture: Nullable<BaseTexture>;
  47039. /**
  47040. * Stores the reflection values in a texture.
  47041. */
  47042. protected _reflectionTexture: Nullable<BaseTexture>;
  47043. /**
  47044. * Stores the emissive values in a texture.
  47045. */
  47046. protected _emissiveTexture: Nullable<BaseTexture>;
  47047. /**
  47048. * AKA Specular texture in other nomenclature.
  47049. */
  47050. protected _reflectivityTexture: Nullable<BaseTexture>;
  47051. /**
  47052. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47053. */
  47054. protected _metallicTexture: Nullable<BaseTexture>;
  47055. /**
  47056. * Specifies the metallic scalar of the metallic/roughness workflow.
  47057. * Can also be used to scale the metalness values of the metallic texture.
  47058. */
  47059. protected _metallic: Nullable<number>;
  47060. /**
  47061. * Specifies the roughness scalar of the metallic/roughness workflow.
  47062. * Can also be used to scale the roughness values of the metallic texture.
  47063. */
  47064. protected _roughness: Nullable<number>;
  47065. /**
  47066. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47067. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47068. */
  47069. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47070. /**
  47071. * Stores surface normal data used to displace a mesh in a texture.
  47072. */
  47073. protected _bumpTexture: Nullable<BaseTexture>;
  47074. /**
  47075. * Stores the pre-calculated light information of a mesh in a texture.
  47076. */
  47077. protected _lightmapTexture: Nullable<BaseTexture>;
  47078. /**
  47079. * The color of a material in ambient lighting.
  47080. */
  47081. protected _ambientColor: Color3;
  47082. /**
  47083. * AKA Diffuse Color in other nomenclature.
  47084. */
  47085. protected _albedoColor: Color3;
  47086. /**
  47087. * AKA Specular Color in other nomenclature.
  47088. */
  47089. protected _reflectivityColor: Color3;
  47090. /**
  47091. * The color applied when light is reflected from a material.
  47092. */
  47093. protected _reflectionColor: Color3;
  47094. /**
  47095. * The color applied when light is emitted from a material.
  47096. */
  47097. protected _emissiveColor: Color3;
  47098. /**
  47099. * AKA Glossiness in other nomenclature.
  47100. */
  47101. protected _microSurface: number;
  47102. /**
  47103. * Specifies that the material will use the light map as a show map.
  47104. */
  47105. protected _useLightmapAsShadowmap: boolean;
  47106. /**
  47107. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47108. * makes the reflect vector face the model (under horizon).
  47109. */
  47110. protected _useHorizonOcclusion: boolean;
  47111. /**
  47112. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47113. * too much the area relying on ambient texture to define their ambient occlusion.
  47114. */
  47115. protected _useRadianceOcclusion: boolean;
  47116. /**
  47117. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47118. */
  47119. protected _useAlphaFromAlbedoTexture: boolean;
  47120. /**
  47121. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47122. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47123. */
  47124. protected _useSpecularOverAlpha: boolean;
  47125. /**
  47126. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47127. */
  47128. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47129. /**
  47130. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47131. */
  47132. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47133. /**
  47134. * Specifies if the metallic texture contains the roughness information in its green channel.
  47135. */
  47136. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47137. /**
  47138. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47139. */
  47140. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47141. /**
  47142. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47143. */
  47144. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47145. /**
  47146. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47147. */
  47148. protected _useAmbientInGrayScale: boolean;
  47149. /**
  47150. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47151. * The material will try to infer what glossiness each pixel should be.
  47152. */
  47153. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47154. /**
  47155. * Defines the falloff type used in this material.
  47156. * It by default is Physical.
  47157. */
  47158. protected _lightFalloff: number;
  47159. /**
  47160. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47161. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47162. */
  47163. protected _useRadianceOverAlpha: boolean;
  47164. /**
  47165. * Allows using an object space normal map (instead of tangent space).
  47166. */
  47167. protected _useObjectSpaceNormalMap: boolean;
  47168. /**
  47169. * Allows using the bump map in parallax mode.
  47170. */
  47171. protected _useParallax: boolean;
  47172. /**
  47173. * Allows using the bump map in parallax occlusion mode.
  47174. */
  47175. protected _useParallaxOcclusion: boolean;
  47176. /**
  47177. * Controls the scale bias of the parallax mode.
  47178. */
  47179. protected _parallaxScaleBias: number;
  47180. /**
  47181. * If sets to true, disables all the lights affecting the material.
  47182. */
  47183. protected _disableLighting: boolean;
  47184. /**
  47185. * Number of Simultaneous lights allowed on the material.
  47186. */
  47187. protected _maxSimultaneousLights: number;
  47188. /**
  47189. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47190. */
  47191. protected _invertNormalMapX: boolean;
  47192. /**
  47193. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47194. */
  47195. protected _invertNormalMapY: boolean;
  47196. /**
  47197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47198. */
  47199. protected _twoSidedLighting: boolean;
  47200. /**
  47201. * Defines the alpha limits in alpha test mode.
  47202. */
  47203. protected _alphaCutOff: number;
  47204. /**
  47205. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47206. */
  47207. protected _forceAlphaTest: boolean;
  47208. /**
  47209. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47210. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47211. */
  47212. protected _useAlphaFresnel: boolean;
  47213. /**
  47214. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47215. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47216. */
  47217. protected _useLinearAlphaFresnel: boolean;
  47218. /**
  47219. * The transparency mode of the material.
  47220. */
  47221. protected _transparencyMode: Nullable<number>;
  47222. /**
  47223. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47224. * from cos thetav and roughness:
  47225. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47226. */
  47227. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47228. /**
  47229. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47230. */
  47231. protected _forceIrradianceInFragment: boolean;
  47232. /**
  47233. * Force normal to face away from face.
  47234. */
  47235. protected _forceNormalForward: boolean;
  47236. /**
  47237. * Enables specular anti aliasing in the PBR shader.
  47238. * It will both interacts on the Geometry for analytical and IBL lighting.
  47239. * It also prefilter the roughness map based on the bump values.
  47240. */
  47241. protected _enableSpecularAntiAliasing: boolean;
  47242. /**
  47243. * Default configuration related to image processing available in the PBR Material.
  47244. */
  47245. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47246. /**
  47247. * Keep track of the image processing observer to allow dispose and replace.
  47248. */
  47249. private _imageProcessingObserver;
  47250. /**
  47251. * Attaches a new image processing configuration to the PBR Material.
  47252. * @param configuration
  47253. */
  47254. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47255. /**
  47256. * Stores the available render targets.
  47257. */
  47258. private _renderTargets;
  47259. /**
  47260. * Sets the global ambient color for the material used in lighting calculations.
  47261. */
  47262. private _globalAmbientColor;
  47263. /**
  47264. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47265. */
  47266. private _useLogarithmicDepth;
  47267. /**
  47268. * If set to true, no lighting calculations will be applied.
  47269. */
  47270. private _unlit;
  47271. private _debugMode;
  47272. /**
  47273. * @hidden
  47274. * This is reserved for the inspector.
  47275. * Defines the material debug mode.
  47276. * It helps seeing only some components of the material while troubleshooting.
  47277. */
  47278. debugMode: number;
  47279. /**
  47280. * @hidden
  47281. * This is reserved for the inspector.
  47282. * Specify from where on screen the debug mode should start.
  47283. * The value goes from -1 (full screen) to 1 (not visible)
  47284. * It helps with side by side comparison against the final render
  47285. * This defaults to -1
  47286. */
  47287. private debugLimit;
  47288. /**
  47289. * @hidden
  47290. * This is reserved for the inspector.
  47291. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47292. * You can use the factor to better multiply the final value.
  47293. */
  47294. private debugFactor;
  47295. /**
  47296. * Defines the clear coat layer parameters for the material.
  47297. */
  47298. readonly clearCoat: PBRClearCoatConfiguration;
  47299. /**
  47300. * Defines the anisotropic parameters for the material.
  47301. */
  47302. readonly anisotropy: PBRAnisotropicConfiguration;
  47303. /**
  47304. * Defines the BRDF parameters for the material.
  47305. */
  47306. readonly brdf: PBRBRDFConfiguration;
  47307. /**
  47308. * Defines the Sheen parameters for the material.
  47309. */
  47310. readonly sheen: PBRSheenConfiguration;
  47311. /**
  47312. * Defines the SubSurface parameters for the material.
  47313. */
  47314. readonly subSurface: PBRSubSurfaceConfiguration;
  47315. /**
  47316. * Custom callback helping to override the default shader used in the material.
  47317. */
  47318. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47319. /**
  47320. * Instantiates a new PBRMaterial instance.
  47321. *
  47322. * @param name The material name
  47323. * @param scene The scene the material will be use in.
  47324. */
  47325. constructor(name: string, scene: Scene);
  47326. /**
  47327. * Gets a boolean indicating that current material needs to register RTT
  47328. */
  47329. readonly hasRenderTargetTextures: boolean;
  47330. /**
  47331. * Gets the name of the material class.
  47332. */
  47333. getClassName(): string;
  47334. /**
  47335. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47336. */
  47337. /**
  47338. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47339. */
  47340. useLogarithmicDepth: boolean;
  47341. /**
  47342. * Gets the current transparency mode.
  47343. */
  47344. /**
  47345. * Sets the transparency mode of the material.
  47346. *
  47347. * | Value | Type | Description |
  47348. * | ----- | ----------------------------------- | ----------- |
  47349. * | 0 | OPAQUE | |
  47350. * | 1 | ALPHATEST | |
  47351. * | 2 | ALPHABLEND | |
  47352. * | 3 | ALPHATESTANDBLEND | |
  47353. *
  47354. */
  47355. transparencyMode: Nullable<number>;
  47356. /**
  47357. * Returns true if alpha blending should be disabled.
  47358. */
  47359. private readonly _disableAlphaBlending;
  47360. /**
  47361. * Specifies whether or not this material should be rendered in alpha blend mode.
  47362. */
  47363. needAlphaBlending(): boolean;
  47364. /**
  47365. * Specifies if the mesh will require alpha blending.
  47366. * @param mesh - BJS mesh.
  47367. */
  47368. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47369. /**
  47370. * Specifies whether or not this material should be rendered in alpha test mode.
  47371. */
  47372. needAlphaTesting(): boolean;
  47373. /**
  47374. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47375. */
  47376. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47377. /**
  47378. * Gets the texture used for the alpha test.
  47379. */
  47380. getAlphaTestTexture(): Nullable<BaseTexture>;
  47381. /**
  47382. * Specifies that the submesh is ready to be used.
  47383. * @param mesh - BJS mesh.
  47384. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47385. * @param useInstances - Specifies that instances should be used.
  47386. * @returns - boolean indicating that the submesh is ready or not.
  47387. */
  47388. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47389. /**
  47390. * Specifies if the material uses metallic roughness workflow.
  47391. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47392. */
  47393. isMetallicWorkflow(): boolean;
  47394. private _prepareEffect;
  47395. private _prepareDefines;
  47396. /**
  47397. * Force shader compilation
  47398. */
  47399. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47400. clipPlane: boolean;
  47401. }>): void;
  47402. /**
  47403. * Initializes the uniform buffer layout for the shader.
  47404. */
  47405. buildUniformLayout(): void;
  47406. /**
  47407. * Unbinds the material from the mesh
  47408. */
  47409. unbind(): void;
  47410. /**
  47411. * Binds the submesh data.
  47412. * @param world - The world matrix.
  47413. * @param mesh - The BJS mesh.
  47414. * @param subMesh - A submesh of the BJS mesh.
  47415. */
  47416. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47417. /**
  47418. * Returns the animatable textures.
  47419. * @returns - Array of animatable textures.
  47420. */
  47421. getAnimatables(): IAnimatable[];
  47422. /**
  47423. * Returns the texture used for reflections.
  47424. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47425. */
  47426. private _getReflectionTexture;
  47427. /**
  47428. * Returns an array of the actively used textures.
  47429. * @returns - Array of BaseTextures
  47430. */
  47431. getActiveTextures(): BaseTexture[];
  47432. /**
  47433. * Checks to see if a texture is used in the material.
  47434. * @param texture - Base texture to use.
  47435. * @returns - Boolean specifying if a texture is used in the material.
  47436. */
  47437. hasTexture(texture: BaseTexture): boolean;
  47438. /**
  47439. * Disposes the resources of the material.
  47440. * @param forceDisposeEffect - Forces the disposal of effects.
  47441. * @param forceDisposeTextures - Forces the disposal of all textures.
  47442. */
  47443. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47444. }
  47445. }
  47446. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47447. import { Nullable } from "babylonjs/types";
  47448. import { Scene } from "babylonjs/scene";
  47449. import { Color3 } from "babylonjs/Maths/math";
  47450. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47451. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47453. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47454. /**
  47455. * The Physically based material of BJS.
  47456. *
  47457. * This offers the main features of a standard PBR material.
  47458. * For more information, please refer to the documentation :
  47459. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47460. */
  47461. export class PBRMaterial extends PBRBaseMaterial {
  47462. /**
  47463. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47464. */
  47465. static readonly PBRMATERIAL_OPAQUE: number;
  47466. /**
  47467. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47468. */
  47469. static readonly PBRMATERIAL_ALPHATEST: number;
  47470. /**
  47471. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47472. */
  47473. static readonly PBRMATERIAL_ALPHABLEND: number;
  47474. /**
  47475. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47476. * They are also discarded below the alpha cutoff threshold to improve performances.
  47477. */
  47478. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47479. /**
  47480. * Defines the default value of how much AO map is occluding the analytical lights
  47481. * (point spot...).
  47482. */
  47483. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47484. /**
  47485. * Intensity of the direct lights e.g. the four lights available in your scene.
  47486. * This impacts both the direct diffuse and specular highlights.
  47487. */
  47488. directIntensity: number;
  47489. /**
  47490. * Intensity of the emissive part of the material.
  47491. * This helps controlling the emissive effect without modifying the emissive color.
  47492. */
  47493. emissiveIntensity: number;
  47494. /**
  47495. * Intensity of the environment e.g. how much the environment will light the object
  47496. * either through harmonics for rough material or through the refelction for shiny ones.
  47497. */
  47498. environmentIntensity: number;
  47499. /**
  47500. * This is a special control allowing the reduction of the specular highlights coming from the
  47501. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47502. */
  47503. specularIntensity: number;
  47504. /**
  47505. * Debug Control allowing disabling the bump map on this material.
  47506. */
  47507. disableBumpMap: boolean;
  47508. /**
  47509. * AKA Diffuse Texture in standard nomenclature.
  47510. */
  47511. albedoTexture: BaseTexture;
  47512. /**
  47513. * AKA Occlusion Texture in other nomenclature.
  47514. */
  47515. ambientTexture: BaseTexture;
  47516. /**
  47517. * AKA Occlusion Texture Intensity in other nomenclature.
  47518. */
  47519. ambientTextureStrength: number;
  47520. /**
  47521. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47522. * 1 means it completely occludes it
  47523. * 0 mean it has no impact
  47524. */
  47525. ambientTextureImpactOnAnalyticalLights: number;
  47526. /**
  47527. * Stores the alpha values in a texture.
  47528. */
  47529. opacityTexture: BaseTexture;
  47530. /**
  47531. * Stores the reflection values in a texture.
  47532. */
  47533. reflectionTexture: Nullable<BaseTexture>;
  47534. /**
  47535. * Stores the emissive values in a texture.
  47536. */
  47537. emissiveTexture: BaseTexture;
  47538. /**
  47539. * AKA Specular texture in other nomenclature.
  47540. */
  47541. reflectivityTexture: BaseTexture;
  47542. /**
  47543. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47544. */
  47545. metallicTexture: BaseTexture;
  47546. /**
  47547. * Specifies the metallic scalar of the metallic/roughness workflow.
  47548. * Can also be used to scale the metalness values of the metallic texture.
  47549. */
  47550. metallic: Nullable<number>;
  47551. /**
  47552. * Specifies the roughness scalar of the metallic/roughness workflow.
  47553. * Can also be used to scale the roughness values of the metallic texture.
  47554. */
  47555. roughness: Nullable<number>;
  47556. /**
  47557. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47558. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47559. */
  47560. microSurfaceTexture: BaseTexture;
  47561. /**
  47562. * Stores surface normal data used to displace a mesh in a texture.
  47563. */
  47564. bumpTexture: BaseTexture;
  47565. /**
  47566. * Stores the pre-calculated light information of a mesh in a texture.
  47567. */
  47568. lightmapTexture: BaseTexture;
  47569. /**
  47570. * Stores the refracted light information in a texture.
  47571. */
  47572. refractionTexture: Nullable<BaseTexture>;
  47573. /**
  47574. * The color of a material in ambient lighting.
  47575. */
  47576. ambientColor: Color3;
  47577. /**
  47578. * AKA Diffuse Color in other nomenclature.
  47579. */
  47580. albedoColor: Color3;
  47581. /**
  47582. * AKA Specular Color in other nomenclature.
  47583. */
  47584. reflectivityColor: Color3;
  47585. /**
  47586. * The color reflected from the material.
  47587. */
  47588. reflectionColor: Color3;
  47589. /**
  47590. * The color emitted from the material.
  47591. */
  47592. emissiveColor: Color3;
  47593. /**
  47594. * AKA Glossiness in other nomenclature.
  47595. */
  47596. microSurface: number;
  47597. /**
  47598. * source material index of refraction (IOR)' / 'destination material IOR.
  47599. */
  47600. indexOfRefraction: number;
  47601. /**
  47602. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47603. */
  47604. invertRefractionY: boolean;
  47605. /**
  47606. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47607. * Materials half opaque for instance using refraction could benefit from this control.
  47608. */
  47609. linkRefractionWithTransparency: boolean;
  47610. /**
  47611. * If true, the light map contains occlusion information instead of lighting info.
  47612. */
  47613. useLightmapAsShadowmap: boolean;
  47614. /**
  47615. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47616. */
  47617. useAlphaFromAlbedoTexture: boolean;
  47618. /**
  47619. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47620. */
  47621. forceAlphaTest: boolean;
  47622. /**
  47623. * Defines the alpha limits in alpha test mode.
  47624. */
  47625. alphaCutOff: number;
  47626. /**
  47627. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47628. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47629. */
  47630. useSpecularOverAlpha: boolean;
  47631. /**
  47632. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47633. */
  47634. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47635. /**
  47636. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47637. */
  47638. useRoughnessFromMetallicTextureAlpha: boolean;
  47639. /**
  47640. * Specifies if the metallic texture contains the roughness information in its green channel.
  47641. */
  47642. useRoughnessFromMetallicTextureGreen: boolean;
  47643. /**
  47644. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47645. */
  47646. useMetallnessFromMetallicTextureBlue: boolean;
  47647. /**
  47648. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47649. */
  47650. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47651. /**
  47652. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47653. */
  47654. useAmbientInGrayScale: boolean;
  47655. /**
  47656. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47657. * The material will try to infer what glossiness each pixel should be.
  47658. */
  47659. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47660. /**
  47661. * BJS is using an harcoded light falloff based on a manually sets up range.
  47662. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47663. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47664. */
  47665. /**
  47666. * BJS is using an harcoded light falloff based on a manually sets up range.
  47667. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47668. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47669. */
  47670. usePhysicalLightFalloff: boolean;
  47671. /**
  47672. * In order to support the falloff compatibility with gltf, a special mode has been added
  47673. * to reproduce the gltf light falloff.
  47674. */
  47675. /**
  47676. * In order to support the falloff compatibility with gltf, a special mode has been added
  47677. * to reproduce the gltf light falloff.
  47678. */
  47679. useGLTFLightFalloff: boolean;
  47680. /**
  47681. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47682. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47683. */
  47684. useRadianceOverAlpha: boolean;
  47685. /**
  47686. * Allows using an object space normal map (instead of tangent space).
  47687. */
  47688. useObjectSpaceNormalMap: boolean;
  47689. /**
  47690. * Allows using the bump map in parallax mode.
  47691. */
  47692. useParallax: boolean;
  47693. /**
  47694. * Allows using the bump map in parallax occlusion mode.
  47695. */
  47696. useParallaxOcclusion: boolean;
  47697. /**
  47698. * Controls the scale bias of the parallax mode.
  47699. */
  47700. parallaxScaleBias: number;
  47701. /**
  47702. * If sets to true, disables all the lights affecting the material.
  47703. */
  47704. disableLighting: boolean;
  47705. /**
  47706. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47707. */
  47708. forceIrradianceInFragment: boolean;
  47709. /**
  47710. * Number of Simultaneous lights allowed on the material.
  47711. */
  47712. maxSimultaneousLights: number;
  47713. /**
  47714. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47715. */
  47716. invertNormalMapX: boolean;
  47717. /**
  47718. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47719. */
  47720. invertNormalMapY: boolean;
  47721. /**
  47722. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47723. */
  47724. twoSidedLighting: boolean;
  47725. /**
  47726. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47727. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47728. */
  47729. useAlphaFresnel: boolean;
  47730. /**
  47731. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47732. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47733. */
  47734. useLinearAlphaFresnel: boolean;
  47735. /**
  47736. * Let user defines the brdf lookup texture used for IBL.
  47737. * A default 8bit version is embedded but you could point at :
  47738. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47739. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47740. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47741. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47742. */
  47743. environmentBRDFTexture: Nullable<BaseTexture>;
  47744. /**
  47745. * Force normal to face away from face.
  47746. */
  47747. forceNormalForward: boolean;
  47748. /**
  47749. * Enables specular anti aliasing in the PBR shader.
  47750. * It will both interacts on the Geometry for analytical and IBL lighting.
  47751. * It also prefilter the roughness map based on the bump values.
  47752. */
  47753. enableSpecularAntiAliasing: boolean;
  47754. /**
  47755. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47756. * makes the reflect vector face the model (under horizon).
  47757. */
  47758. useHorizonOcclusion: boolean;
  47759. /**
  47760. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47761. * too much the area relying on ambient texture to define their ambient occlusion.
  47762. */
  47763. useRadianceOcclusion: boolean;
  47764. /**
  47765. * If set to true, no lighting calculations will be applied.
  47766. */
  47767. unlit: boolean;
  47768. /**
  47769. * Gets the image processing configuration used either in this material.
  47770. */
  47771. /**
  47772. * Sets the Default image processing configuration used either in the this material.
  47773. *
  47774. * If sets to null, the scene one is in use.
  47775. */
  47776. imageProcessingConfiguration: ImageProcessingConfiguration;
  47777. /**
  47778. * Gets wether the color curves effect is enabled.
  47779. */
  47780. /**
  47781. * Sets wether the color curves effect is enabled.
  47782. */
  47783. cameraColorCurvesEnabled: boolean;
  47784. /**
  47785. * Gets wether the color grading effect is enabled.
  47786. */
  47787. /**
  47788. * Gets wether the color grading effect is enabled.
  47789. */
  47790. cameraColorGradingEnabled: boolean;
  47791. /**
  47792. * Gets wether tonemapping is enabled or not.
  47793. */
  47794. /**
  47795. * Sets wether tonemapping is enabled or not
  47796. */
  47797. cameraToneMappingEnabled: boolean;
  47798. /**
  47799. * The camera exposure used on this material.
  47800. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47801. * This corresponds to a photographic exposure.
  47802. */
  47803. /**
  47804. * The camera exposure used on this material.
  47805. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47806. * This corresponds to a photographic exposure.
  47807. */
  47808. cameraExposure: number;
  47809. /**
  47810. * Gets The camera contrast used on this material.
  47811. */
  47812. /**
  47813. * Sets The camera contrast used on this material.
  47814. */
  47815. cameraContrast: number;
  47816. /**
  47817. * Gets the Color Grading 2D Lookup Texture.
  47818. */
  47819. /**
  47820. * Sets the Color Grading 2D Lookup Texture.
  47821. */
  47822. cameraColorGradingTexture: Nullable<BaseTexture>;
  47823. /**
  47824. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47825. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47826. * 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;
  47827. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47828. */
  47829. /**
  47830. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47831. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47832. * 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;
  47833. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47834. */
  47835. cameraColorCurves: Nullable<ColorCurves>;
  47836. /**
  47837. * Instantiates a new PBRMaterial instance.
  47838. *
  47839. * @param name The material name
  47840. * @param scene The scene the material will be use in.
  47841. */
  47842. constructor(name: string, scene: Scene);
  47843. /**
  47844. * Returns the name of this material class.
  47845. */
  47846. getClassName(): string;
  47847. /**
  47848. * Makes a duplicate of the current material.
  47849. * @param name - name to use for the new material.
  47850. */
  47851. clone(name: string): PBRMaterial;
  47852. /**
  47853. * Serializes this PBR Material.
  47854. * @returns - An object with the serialized material.
  47855. */
  47856. serialize(): any;
  47857. /**
  47858. * Parses a PBR Material from a serialized object.
  47859. * @param source - Serialized object.
  47860. * @param scene - BJS scene instance.
  47861. * @param rootUrl - url for the scene object
  47862. * @returns - PBRMaterial
  47863. */
  47864. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47865. }
  47866. }
  47867. declare module "babylonjs/Misc/dds" {
  47868. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47869. import { Engine } from "babylonjs/Engines/engine";
  47870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47871. import { Nullable } from "babylonjs/types";
  47872. import { Scene } from "babylonjs/scene";
  47873. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47874. /**
  47875. * Direct draw surface info
  47876. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47877. */
  47878. export interface DDSInfo {
  47879. /**
  47880. * Width of the texture
  47881. */
  47882. width: number;
  47883. /**
  47884. * Width of the texture
  47885. */
  47886. height: number;
  47887. /**
  47888. * Number of Mipmaps for the texture
  47889. * @see https://en.wikipedia.org/wiki/Mipmap
  47890. */
  47891. mipmapCount: number;
  47892. /**
  47893. * If the textures format is a known fourCC format
  47894. * @see https://www.fourcc.org/
  47895. */
  47896. isFourCC: boolean;
  47897. /**
  47898. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47899. */
  47900. isRGB: boolean;
  47901. /**
  47902. * If the texture is a lumincance format
  47903. */
  47904. isLuminance: boolean;
  47905. /**
  47906. * If this is a cube texture
  47907. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47908. */
  47909. isCube: boolean;
  47910. /**
  47911. * If the texture is a compressed format eg. FOURCC_DXT1
  47912. */
  47913. isCompressed: boolean;
  47914. /**
  47915. * The dxgiFormat of the texture
  47916. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47917. */
  47918. dxgiFormat: number;
  47919. /**
  47920. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47921. */
  47922. textureType: number;
  47923. /**
  47924. * Sphericle polynomial created for the dds texture
  47925. */
  47926. sphericalPolynomial?: SphericalPolynomial;
  47927. }
  47928. /**
  47929. * Class used to provide DDS decompression tools
  47930. */
  47931. export class DDSTools {
  47932. /**
  47933. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47934. */
  47935. static StoreLODInAlphaChannel: boolean;
  47936. /**
  47937. * Gets DDS information from an array buffer
  47938. * @param arrayBuffer defines the array buffer to read data from
  47939. * @returns the DDS information
  47940. */
  47941. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47942. private static _FloatView;
  47943. private static _Int32View;
  47944. private static _ToHalfFloat;
  47945. private static _FromHalfFloat;
  47946. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47947. private static _GetHalfFloatRGBAArrayBuffer;
  47948. private static _GetFloatRGBAArrayBuffer;
  47949. private static _GetFloatAsUIntRGBAArrayBuffer;
  47950. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47951. private static _GetRGBAArrayBuffer;
  47952. private static _ExtractLongWordOrder;
  47953. private static _GetRGBArrayBuffer;
  47954. private static _GetLuminanceArrayBuffer;
  47955. /**
  47956. * Uploads DDS Levels to a Babylon Texture
  47957. * @hidden
  47958. */
  47959. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47960. }
  47961. module "babylonjs/Engines/engine" {
  47962. interface Engine {
  47963. /**
  47964. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47965. * @param rootUrl defines the url where the file to load is located
  47966. * @param scene defines the current scene
  47967. * @param lodScale defines scale to apply to the mip map selection
  47968. * @param lodOffset defines offset to apply to the mip map selection
  47969. * @param onLoad defines an optional callback raised when the texture is loaded
  47970. * @param onError defines an optional callback raised if there is an issue to load the texture
  47971. * @param format defines the format of the data
  47972. * @param forcedExtension defines the extension to use to pick the right loader
  47973. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47974. * @returns the cube texture as an InternalTexture
  47975. */
  47976. 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;
  47977. }
  47978. }
  47979. }
  47980. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47981. import { Nullable } from "babylonjs/types";
  47982. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47983. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47984. /**
  47985. * Implementation of the DDS Texture Loader.
  47986. * @hidden
  47987. */
  47988. export class _DDSTextureLoader implements IInternalTextureLoader {
  47989. /**
  47990. * Defines wether the loader supports cascade loading the different faces.
  47991. */
  47992. readonly supportCascades: boolean;
  47993. /**
  47994. * This returns if the loader support the current file information.
  47995. * @param extension defines the file extension of the file being loaded
  47996. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47997. * @param fallback defines the fallback internal texture if any
  47998. * @param isBase64 defines whether the texture is encoded as a base64
  47999. * @param isBuffer defines whether the texture data are stored as a buffer
  48000. * @returns true if the loader can load the specified file
  48001. */
  48002. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48003. /**
  48004. * Transform the url before loading if required.
  48005. * @param rootUrl the url of the texture
  48006. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48007. * @returns the transformed texture
  48008. */
  48009. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48010. /**
  48011. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48012. * @param rootUrl the url of the texture
  48013. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48014. * @returns the fallback texture
  48015. */
  48016. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48017. /**
  48018. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48019. * @param data contains the texture data
  48020. * @param texture defines the BabylonJS internal texture
  48021. * @param createPolynomials will be true if polynomials have been requested
  48022. * @param onLoad defines the callback to trigger once the texture is ready
  48023. * @param onError defines the callback to trigger in case of error
  48024. */
  48025. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48026. /**
  48027. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48028. * @param data contains the texture data
  48029. * @param texture defines the BabylonJS internal texture
  48030. * @param callback defines the method to call once ready to upload
  48031. */
  48032. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48033. }
  48034. }
  48035. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48036. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48037. /** @hidden */
  48038. export var rgbdEncodePixelShader: {
  48039. name: string;
  48040. shader: string;
  48041. };
  48042. }
  48043. declare module "babylonjs/Misc/environmentTextureTools" {
  48044. import { Nullable } from "babylonjs/types";
  48045. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48046. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48047. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48048. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48049. import "babylonjs/Shaders/rgbdEncode.fragment";
  48050. import "babylonjs/Shaders/rgbdDecode.fragment";
  48051. /**
  48052. * Raw texture data and descriptor sufficient for WebGL texture upload
  48053. */
  48054. export interface EnvironmentTextureInfo {
  48055. /**
  48056. * Version of the environment map
  48057. */
  48058. version: number;
  48059. /**
  48060. * Width of image
  48061. */
  48062. width: number;
  48063. /**
  48064. * Irradiance information stored in the file.
  48065. */
  48066. irradiance: any;
  48067. /**
  48068. * Specular information stored in the file.
  48069. */
  48070. specular: any;
  48071. }
  48072. /**
  48073. * Sets of helpers addressing the serialization and deserialization of environment texture
  48074. * stored in a BabylonJS env file.
  48075. * Those files are usually stored as .env files.
  48076. */
  48077. export class EnvironmentTextureTools {
  48078. /**
  48079. * Magic number identifying the env file.
  48080. */
  48081. private static _MagicBytes;
  48082. /**
  48083. * Gets the environment info from an env file.
  48084. * @param data The array buffer containing the .env bytes.
  48085. * @returns the environment file info (the json header) if successfully parsed.
  48086. */
  48087. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48088. /**
  48089. * Creates an environment texture from a loaded cube texture.
  48090. * @param texture defines the cube texture to convert in env file
  48091. * @return a promise containing the environment data if succesfull.
  48092. */
  48093. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48094. /**
  48095. * Creates a JSON representation of the spherical data.
  48096. * @param texture defines the texture containing the polynomials
  48097. * @return the JSON representation of the spherical info
  48098. */
  48099. private static _CreateEnvTextureIrradiance;
  48100. /**
  48101. * Uploads the texture info contained in the env file to the GPU.
  48102. * @param texture defines the internal texture to upload to
  48103. * @param arrayBuffer defines the buffer cotaining the data to load
  48104. * @param info defines the texture info retrieved through the GetEnvInfo method
  48105. * @returns a promise
  48106. */
  48107. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48108. /**
  48109. * Uploads the levels of image data to the GPU.
  48110. * @param texture defines the internal texture to upload to
  48111. * @param imageData defines the array buffer views of image data [mipmap][face]
  48112. * @returns a promise
  48113. */
  48114. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48115. /**
  48116. * Uploads spherical polynomials information to the texture.
  48117. * @param texture defines the texture we are trying to upload the information to
  48118. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48119. */
  48120. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48121. /** @hidden */
  48122. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48123. }
  48124. }
  48125. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48126. import { Nullable } from "babylonjs/types";
  48127. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48128. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48129. /**
  48130. * Implementation of the ENV Texture Loader.
  48131. * @hidden
  48132. */
  48133. export class _ENVTextureLoader implements IInternalTextureLoader {
  48134. /**
  48135. * Defines wether the loader supports cascade loading the different faces.
  48136. */
  48137. readonly supportCascades: boolean;
  48138. /**
  48139. * This returns if the loader support the current file information.
  48140. * @param extension defines the file extension of the file being loaded
  48141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48142. * @param fallback defines the fallback internal texture if any
  48143. * @param isBase64 defines whether the texture is encoded as a base64
  48144. * @param isBuffer defines whether the texture data are stored as a buffer
  48145. * @returns true if the loader can load the specified file
  48146. */
  48147. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48148. /**
  48149. * Transform the url before loading if required.
  48150. * @param rootUrl the url of the texture
  48151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48152. * @returns the transformed texture
  48153. */
  48154. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48155. /**
  48156. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48157. * @param rootUrl the url of the texture
  48158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48159. * @returns the fallback texture
  48160. */
  48161. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48162. /**
  48163. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48164. * @param data contains the texture data
  48165. * @param texture defines the BabylonJS internal texture
  48166. * @param createPolynomials will be true if polynomials have been requested
  48167. * @param onLoad defines the callback to trigger once the texture is ready
  48168. * @param onError defines the callback to trigger in case of error
  48169. */
  48170. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48171. /**
  48172. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48173. * @param data contains the texture data
  48174. * @param texture defines the BabylonJS internal texture
  48175. * @param callback defines the method to call once ready to upload
  48176. */
  48177. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48178. }
  48179. }
  48180. declare module "babylonjs/Misc/khronosTextureContainer" {
  48181. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48182. /**
  48183. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48184. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48185. */
  48186. export class KhronosTextureContainer {
  48187. /** contents of the KTX container file */
  48188. arrayBuffer: any;
  48189. private static HEADER_LEN;
  48190. private static COMPRESSED_2D;
  48191. private static COMPRESSED_3D;
  48192. private static TEX_2D;
  48193. private static TEX_3D;
  48194. /**
  48195. * Gets the openGL type
  48196. */
  48197. glType: number;
  48198. /**
  48199. * Gets the openGL type size
  48200. */
  48201. glTypeSize: number;
  48202. /**
  48203. * Gets the openGL format
  48204. */
  48205. glFormat: number;
  48206. /**
  48207. * Gets the openGL internal format
  48208. */
  48209. glInternalFormat: number;
  48210. /**
  48211. * Gets the base internal format
  48212. */
  48213. glBaseInternalFormat: number;
  48214. /**
  48215. * Gets image width in pixel
  48216. */
  48217. pixelWidth: number;
  48218. /**
  48219. * Gets image height in pixel
  48220. */
  48221. pixelHeight: number;
  48222. /**
  48223. * Gets image depth in pixels
  48224. */
  48225. pixelDepth: number;
  48226. /**
  48227. * Gets the number of array elements
  48228. */
  48229. numberOfArrayElements: number;
  48230. /**
  48231. * Gets the number of faces
  48232. */
  48233. numberOfFaces: number;
  48234. /**
  48235. * Gets the number of mipmap levels
  48236. */
  48237. numberOfMipmapLevels: number;
  48238. /**
  48239. * Gets the bytes of key value data
  48240. */
  48241. bytesOfKeyValueData: number;
  48242. /**
  48243. * Gets the load type
  48244. */
  48245. loadType: number;
  48246. /**
  48247. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48248. */
  48249. isInvalid: boolean;
  48250. /**
  48251. * Creates a new KhronosTextureContainer
  48252. * @param arrayBuffer contents of the KTX container file
  48253. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48254. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48255. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48256. */
  48257. constructor(
  48258. /** contents of the KTX container file */
  48259. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48260. /**
  48261. * Uploads KTX content to a Babylon Texture.
  48262. * It is assumed that the texture has already been created & is currently bound
  48263. * @hidden
  48264. */
  48265. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48266. private _upload2DCompressedLevels;
  48267. }
  48268. }
  48269. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48270. import { Nullable } from "babylonjs/types";
  48271. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48272. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48273. /**
  48274. * Implementation of the KTX Texture Loader.
  48275. * @hidden
  48276. */
  48277. export class _KTXTextureLoader implements IInternalTextureLoader {
  48278. /**
  48279. * Defines wether the loader supports cascade loading the different faces.
  48280. */
  48281. readonly supportCascades: boolean;
  48282. /**
  48283. * This returns if the loader support the current file information.
  48284. * @param extension defines the file extension of the file being loaded
  48285. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48286. * @param fallback defines the fallback internal texture if any
  48287. * @param isBase64 defines whether the texture is encoded as a base64
  48288. * @param isBuffer defines whether the texture data are stored as a buffer
  48289. * @returns true if the loader can load the specified file
  48290. */
  48291. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48292. /**
  48293. * Transform the url before loading if required.
  48294. * @param rootUrl the url of the texture
  48295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48296. * @returns the transformed texture
  48297. */
  48298. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48299. /**
  48300. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48301. * @param rootUrl the url of the texture
  48302. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48303. * @returns the fallback texture
  48304. */
  48305. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48306. /**
  48307. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48308. * @param data contains the texture data
  48309. * @param texture defines the BabylonJS internal texture
  48310. * @param createPolynomials will be true if polynomials have been requested
  48311. * @param onLoad defines the callback to trigger once the texture is ready
  48312. * @param onError defines the callback to trigger in case of error
  48313. */
  48314. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48315. /**
  48316. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48317. * @param data contains the texture data
  48318. * @param texture defines the BabylonJS internal texture
  48319. * @param callback defines the method to call once ready to upload
  48320. */
  48321. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48322. }
  48323. }
  48324. declare module "babylonjs/Helpers/sceneHelpers" {
  48325. import { Nullable } from "babylonjs/types";
  48326. import { Mesh } from "babylonjs/Meshes/mesh";
  48327. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48328. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48329. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48330. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48331. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48332. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48333. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48334. import "babylonjs/Meshes/Builders/boxBuilder";
  48335. /** @hidden */
  48336. export var _forceSceneHelpersToBundle: boolean;
  48337. module "babylonjs/scene" {
  48338. interface Scene {
  48339. /**
  48340. * Creates a default light for the scene.
  48341. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48342. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48343. */
  48344. createDefaultLight(replace?: boolean): void;
  48345. /**
  48346. * Creates a default camera for the scene.
  48347. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48348. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48349. * @param replace has default false, when true replaces the active camera in the scene
  48350. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48351. */
  48352. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48353. /**
  48354. * Creates a default camera and a default light.
  48355. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48356. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48357. * @param replace has the default false, when true replaces the active camera/light in the scene
  48358. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48359. */
  48360. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48361. /**
  48362. * Creates a new sky box
  48363. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48364. * @param environmentTexture defines the texture to use as environment texture
  48365. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48366. * @param scale defines the overall scale of the skybox
  48367. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48368. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48369. * @returns a new mesh holding the sky box
  48370. */
  48371. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48372. /**
  48373. * Creates a new environment
  48374. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48375. * @param options defines the options you can use to configure the environment
  48376. * @returns the new EnvironmentHelper
  48377. */
  48378. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48379. /**
  48380. * Creates a new VREXperienceHelper
  48381. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48382. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48383. * @returns a new VREXperienceHelper
  48384. */
  48385. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48386. /**
  48387. * Creates a new XREXperienceHelper
  48388. * @see http://doc.babylonjs.com/how_to/webxr
  48389. * @returns a promise for a new XREXperienceHelper
  48390. */
  48391. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48392. }
  48393. }
  48394. }
  48395. declare module "babylonjs/Helpers/videoDome" {
  48396. import { Scene } from "babylonjs/scene";
  48397. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48398. import { Mesh } from "babylonjs/Meshes/mesh";
  48399. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48400. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48401. import "babylonjs/Meshes/Builders/sphereBuilder";
  48402. /**
  48403. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48404. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48405. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48406. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48407. */
  48408. export class VideoDome extends TransformNode {
  48409. /**
  48410. * Define the video source as a Monoscopic panoramic 360 video.
  48411. */
  48412. static readonly MODE_MONOSCOPIC: number;
  48413. /**
  48414. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48415. */
  48416. static readonly MODE_TOPBOTTOM: number;
  48417. /**
  48418. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48419. */
  48420. static readonly MODE_SIDEBYSIDE: number;
  48421. private _useDirectMapping;
  48422. /**
  48423. * The video texture being displayed on the sphere
  48424. */
  48425. protected _videoTexture: VideoTexture;
  48426. /**
  48427. * Gets the video texture being displayed on the sphere
  48428. */
  48429. readonly videoTexture: VideoTexture;
  48430. /**
  48431. * The skybox material
  48432. */
  48433. protected _material: BackgroundMaterial;
  48434. /**
  48435. * The surface used for the skybox
  48436. */
  48437. protected _mesh: Mesh;
  48438. /**
  48439. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48440. * Also see the options.resolution property.
  48441. */
  48442. fovMultiplier: number;
  48443. private _videoMode;
  48444. /**
  48445. * Gets or set the current video mode for the video. It can be:
  48446. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48447. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48448. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48449. */
  48450. videoMode: number;
  48451. /**
  48452. * Oberserver used in Stereoscopic VR Mode.
  48453. */
  48454. private _onBeforeCameraRenderObserver;
  48455. /**
  48456. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48457. * @param name Element's name, child elements will append suffixes for their own names.
  48458. * @param urlsOrVideo defines the url(s) or the video element to use
  48459. * @param options An object containing optional or exposed sub element properties
  48460. */
  48461. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48462. resolution?: number;
  48463. clickToPlay?: boolean;
  48464. autoPlay?: boolean;
  48465. loop?: boolean;
  48466. size?: number;
  48467. poster?: string;
  48468. faceForward?: boolean;
  48469. useDirectMapping?: boolean;
  48470. }, scene: Scene);
  48471. private _changeVideoMode;
  48472. /**
  48473. * Releases resources associated with this node.
  48474. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48475. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48476. */
  48477. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48478. }
  48479. }
  48480. declare module "babylonjs/Helpers/index" {
  48481. export * from "babylonjs/Helpers/environmentHelper";
  48482. export * from "babylonjs/Helpers/photoDome";
  48483. export * from "babylonjs/Helpers/sceneHelpers";
  48484. export * from "babylonjs/Helpers/videoDome";
  48485. }
  48486. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48487. import { PerfCounter } from "babylonjs/Misc/tools";
  48488. import { IDisposable } from "babylonjs/scene";
  48489. import { Engine } from "babylonjs/Engines/engine";
  48490. /**
  48491. * This class can be used to get instrumentation data from a Babylon engine
  48492. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48493. */
  48494. export class EngineInstrumentation implements IDisposable {
  48495. /**
  48496. * Define the instrumented engine.
  48497. */
  48498. engine: Engine;
  48499. private _captureGPUFrameTime;
  48500. private _gpuFrameTimeToken;
  48501. private _gpuFrameTime;
  48502. private _captureShaderCompilationTime;
  48503. private _shaderCompilationTime;
  48504. private _onBeginFrameObserver;
  48505. private _onEndFrameObserver;
  48506. private _onBeforeShaderCompilationObserver;
  48507. private _onAfterShaderCompilationObserver;
  48508. /**
  48509. * Gets the perf counter used for GPU frame time
  48510. */
  48511. readonly gpuFrameTimeCounter: PerfCounter;
  48512. /**
  48513. * Gets the GPU frame time capture status
  48514. */
  48515. /**
  48516. * Enable or disable the GPU frame time capture
  48517. */
  48518. captureGPUFrameTime: boolean;
  48519. /**
  48520. * Gets the perf counter used for shader compilation time
  48521. */
  48522. readonly shaderCompilationTimeCounter: PerfCounter;
  48523. /**
  48524. * Gets the shader compilation time capture status
  48525. */
  48526. /**
  48527. * Enable or disable the shader compilation time capture
  48528. */
  48529. captureShaderCompilationTime: boolean;
  48530. /**
  48531. * Instantiates a new engine instrumentation.
  48532. * This class can be used to get instrumentation data from a Babylon engine
  48533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48534. * @param engine Defines the engine to instrument
  48535. */
  48536. constructor(
  48537. /**
  48538. * Define the instrumented engine.
  48539. */
  48540. engine: Engine);
  48541. /**
  48542. * Dispose and release associated resources.
  48543. */
  48544. dispose(): void;
  48545. }
  48546. }
  48547. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48548. import { PerfCounter } from "babylonjs/Misc/tools";
  48549. import { Scene, IDisposable } from "babylonjs/scene";
  48550. /**
  48551. * This class can be used to get instrumentation data from a Babylon engine
  48552. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48553. */
  48554. export class SceneInstrumentation implements IDisposable {
  48555. /**
  48556. * Defines the scene to instrument
  48557. */
  48558. scene: Scene;
  48559. private _captureActiveMeshesEvaluationTime;
  48560. private _activeMeshesEvaluationTime;
  48561. private _captureRenderTargetsRenderTime;
  48562. private _renderTargetsRenderTime;
  48563. private _captureFrameTime;
  48564. private _frameTime;
  48565. private _captureRenderTime;
  48566. private _renderTime;
  48567. private _captureInterFrameTime;
  48568. private _interFrameTime;
  48569. private _captureParticlesRenderTime;
  48570. private _particlesRenderTime;
  48571. private _captureSpritesRenderTime;
  48572. private _spritesRenderTime;
  48573. private _capturePhysicsTime;
  48574. private _physicsTime;
  48575. private _captureAnimationsTime;
  48576. private _animationsTime;
  48577. private _captureCameraRenderTime;
  48578. private _cameraRenderTime;
  48579. private _onBeforeActiveMeshesEvaluationObserver;
  48580. private _onAfterActiveMeshesEvaluationObserver;
  48581. private _onBeforeRenderTargetsRenderObserver;
  48582. private _onAfterRenderTargetsRenderObserver;
  48583. private _onAfterRenderObserver;
  48584. private _onBeforeDrawPhaseObserver;
  48585. private _onAfterDrawPhaseObserver;
  48586. private _onBeforeAnimationsObserver;
  48587. private _onBeforeParticlesRenderingObserver;
  48588. private _onAfterParticlesRenderingObserver;
  48589. private _onBeforeSpritesRenderingObserver;
  48590. private _onAfterSpritesRenderingObserver;
  48591. private _onBeforePhysicsObserver;
  48592. private _onAfterPhysicsObserver;
  48593. private _onAfterAnimationsObserver;
  48594. private _onBeforeCameraRenderObserver;
  48595. private _onAfterCameraRenderObserver;
  48596. /**
  48597. * Gets the perf counter used for active meshes evaluation time
  48598. */
  48599. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48600. /**
  48601. * Gets the active meshes evaluation time capture status
  48602. */
  48603. /**
  48604. * Enable or disable the active meshes evaluation time capture
  48605. */
  48606. captureActiveMeshesEvaluationTime: boolean;
  48607. /**
  48608. * Gets the perf counter used for render targets render time
  48609. */
  48610. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48611. /**
  48612. * Gets the render targets render time capture status
  48613. */
  48614. /**
  48615. * Enable or disable the render targets render time capture
  48616. */
  48617. captureRenderTargetsRenderTime: boolean;
  48618. /**
  48619. * Gets the perf counter used for particles render time
  48620. */
  48621. readonly particlesRenderTimeCounter: PerfCounter;
  48622. /**
  48623. * Gets the particles render time capture status
  48624. */
  48625. /**
  48626. * Enable or disable the particles render time capture
  48627. */
  48628. captureParticlesRenderTime: boolean;
  48629. /**
  48630. * Gets the perf counter used for sprites render time
  48631. */
  48632. readonly spritesRenderTimeCounter: PerfCounter;
  48633. /**
  48634. * Gets the sprites render time capture status
  48635. */
  48636. /**
  48637. * Enable or disable the sprites render time capture
  48638. */
  48639. captureSpritesRenderTime: boolean;
  48640. /**
  48641. * Gets the perf counter used for physics time
  48642. */
  48643. readonly physicsTimeCounter: PerfCounter;
  48644. /**
  48645. * Gets the physics time capture status
  48646. */
  48647. /**
  48648. * Enable or disable the physics time capture
  48649. */
  48650. capturePhysicsTime: boolean;
  48651. /**
  48652. * Gets the perf counter used for animations time
  48653. */
  48654. readonly animationsTimeCounter: PerfCounter;
  48655. /**
  48656. * Gets the animations time capture status
  48657. */
  48658. /**
  48659. * Enable or disable the animations time capture
  48660. */
  48661. captureAnimationsTime: boolean;
  48662. /**
  48663. * Gets the perf counter used for frame time capture
  48664. */
  48665. readonly frameTimeCounter: PerfCounter;
  48666. /**
  48667. * Gets the frame time capture status
  48668. */
  48669. /**
  48670. * Enable or disable the frame time capture
  48671. */
  48672. captureFrameTime: boolean;
  48673. /**
  48674. * Gets the perf counter used for inter-frames time capture
  48675. */
  48676. readonly interFrameTimeCounter: PerfCounter;
  48677. /**
  48678. * Gets the inter-frames time capture status
  48679. */
  48680. /**
  48681. * Enable or disable the inter-frames time capture
  48682. */
  48683. captureInterFrameTime: boolean;
  48684. /**
  48685. * Gets the perf counter used for render time capture
  48686. */
  48687. readonly renderTimeCounter: PerfCounter;
  48688. /**
  48689. * Gets the render time capture status
  48690. */
  48691. /**
  48692. * Enable or disable the render time capture
  48693. */
  48694. captureRenderTime: boolean;
  48695. /**
  48696. * Gets the perf counter used for camera render time capture
  48697. */
  48698. readonly cameraRenderTimeCounter: PerfCounter;
  48699. /**
  48700. * Gets the camera render time capture status
  48701. */
  48702. /**
  48703. * Enable or disable the camera render time capture
  48704. */
  48705. captureCameraRenderTime: boolean;
  48706. /**
  48707. * Gets the perf counter used for draw calls
  48708. */
  48709. readonly drawCallsCounter: PerfCounter;
  48710. /**
  48711. * Instantiates a new scene instrumentation.
  48712. * This class can be used to get instrumentation data from a Babylon engine
  48713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48714. * @param scene Defines the scene to instrument
  48715. */
  48716. constructor(
  48717. /**
  48718. * Defines the scene to instrument
  48719. */
  48720. scene: Scene);
  48721. /**
  48722. * Dispose and release associated resources.
  48723. */
  48724. dispose(): void;
  48725. }
  48726. }
  48727. declare module "babylonjs/Instrumentation/index" {
  48728. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48729. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48730. export * from "babylonjs/Instrumentation/timeToken";
  48731. }
  48732. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48733. /** @hidden */
  48734. export var glowMapGenerationPixelShader: {
  48735. name: string;
  48736. shader: string;
  48737. };
  48738. }
  48739. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48740. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48741. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48742. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48743. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48744. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48745. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48746. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48747. /** @hidden */
  48748. export var glowMapGenerationVertexShader: {
  48749. name: string;
  48750. shader: string;
  48751. };
  48752. }
  48753. declare module "babylonjs/Layers/effectLayer" {
  48754. import { Observable } from "babylonjs/Misc/observable";
  48755. import { Nullable } from "babylonjs/types";
  48756. import { Camera } from "babylonjs/Cameras/camera";
  48757. import { Scene } from "babylonjs/scene";
  48758. import { Color4, ISize } from "babylonjs/Maths/math";
  48759. import { Engine } from "babylonjs/Engines/engine";
  48760. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48762. import { Mesh } from "babylonjs/Meshes/mesh";
  48763. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48765. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48766. import { Effect } from "babylonjs/Materials/effect";
  48767. import { Material } from "babylonjs/Materials/material";
  48768. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48769. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48770. /**
  48771. * Effect layer options. This helps customizing the behaviour
  48772. * of the effect layer.
  48773. */
  48774. export interface IEffectLayerOptions {
  48775. /**
  48776. * Multiplication factor apply to the canvas size to compute the render target size
  48777. * used to generated the objects (the smaller the faster).
  48778. */
  48779. mainTextureRatio: number;
  48780. /**
  48781. * Enforces a fixed size texture to ensure effect stability across devices.
  48782. */
  48783. mainTextureFixedSize?: number;
  48784. /**
  48785. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48786. */
  48787. alphaBlendingMode: number;
  48788. /**
  48789. * The camera attached to the layer.
  48790. */
  48791. camera: Nullable<Camera>;
  48792. /**
  48793. * The rendering group to draw the layer in.
  48794. */
  48795. renderingGroupId: number;
  48796. }
  48797. /**
  48798. * The effect layer Helps adding post process effect blended with the main pass.
  48799. *
  48800. * This can be for instance use to generate glow or higlight effects on the scene.
  48801. *
  48802. * The effect layer class can not be used directly and is intented to inherited from to be
  48803. * customized per effects.
  48804. */
  48805. export abstract class EffectLayer {
  48806. private _vertexBuffers;
  48807. private _indexBuffer;
  48808. private _cachedDefines;
  48809. private _effectLayerMapGenerationEffect;
  48810. private _effectLayerOptions;
  48811. private _mergeEffect;
  48812. protected _scene: Scene;
  48813. protected _engine: Engine;
  48814. protected _maxSize: number;
  48815. protected _mainTextureDesiredSize: ISize;
  48816. protected _mainTexture: RenderTargetTexture;
  48817. protected _shouldRender: boolean;
  48818. protected _postProcesses: PostProcess[];
  48819. protected _textures: BaseTexture[];
  48820. protected _emissiveTextureAndColor: {
  48821. texture: Nullable<BaseTexture>;
  48822. color: Color4;
  48823. };
  48824. /**
  48825. * The name of the layer
  48826. */
  48827. name: string;
  48828. /**
  48829. * The clear color of the texture used to generate the glow map.
  48830. */
  48831. neutralColor: Color4;
  48832. /**
  48833. * Specifies wether the highlight layer is enabled or not.
  48834. */
  48835. isEnabled: boolean;
  48836. /**
  48837. * Gets the camera attached to the layer.
  48838. */
  48839. readonly camera: Nullable<Camera>;
  48840. /**
  48841. * Gets the rendering group id the layer should render in.
  48842. */
  48843. readonly renderingGroupId: number;
  48844. /**
  48845. * An event triggered when the effect layer has been disposed.
  48846. */
  48847. onDisposeObservable: Observable<EffectLayer>;
  48848. /**
  48849. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48850. */
  48851. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48852. /**
  48853. * An event triggered when the generated texture is being merged in the scene.
  48854. */
  48855. onBeforeComposeObservable: Observable<EffectLayer>;
  48856. /**
  48857. * An event triggered when the generated texture has been merged in the scene.
  48858. */
  48859. onAfterComposeObservable: Observable<EffectLayer>;
  48860. /**
  48861. * An event triggered when the efffect layer changes its size.
  48862. */
  48863. onSizeChangedObservable: Observable<EffectLayer>;
  48864. /** @hidden */
  48865. static _SceneComponentInitialization: (scene: Scene) => void;
  48866. /**
  48867. * Instantiates a new effect Layer and references it in the scene.
  48868. * @param name The name of the layer
  48869. * @param scene The scene to use the layer in
  48870. */
  48871. constructor(
  48872. /** The Friendly of the effect in the scene */
  48873. name: string, scene: Scene);
  48874. /**
  48875. * Get the effect name of the layer.
  48876. * @return The effect name
  48877. */
  48878. abstract getEffectName(): string;
  48879. /**
  48880. * Checks for the readiness of the element composing the layer.
  48881. * @param subMesh the mesh to check for
  48882. * @param useInstances specify wether or not to use instances to render the mesh
  48883. * @return true if ready otherwise, false
  48884. */
  48885. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48886. /**
  48887. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48888. * @returns true if the effect requires stencil during the main canvas render pass.
  48889. */
  48890. abstract needStencil(): boolean;
  48891. /**
  48892. * Create the merge effect. This is the shader use to blit the information back
  48893. * to the main canvas at the end of the scene rendering.
  48894. * @returns The effect containing the shader used to merge the effect on the main canvas
  48895. */
  48896. protected abstract _createMergeEffect(): Effect;
  48897. /**
  48898. * Creates the render target textures and post processes used in the effect layer.
  48899. */
  48900. protected abstract _createTextureAndPostProcesses(): void;
  48901. /**
  48902. * Implementation specific of rendering the generating effect on the main canvas.
  48903. * @param effect The effect used to render through
  48904. */
  48905. protected abstract _internalRender(effect: Effect): void;
  48906. /**
  48907. * Sets the required values for both the emissive texture and and the main color.
  48908. */
  48909. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48910. /**
  48911. * Free any resources and references associated to a mesh.
  48912. * Internal use
  48913. * @param mesh The mesh to free.
  48914. */
  48915. abstract _disposeMesh(mesh: Mesh): void;
  48916. /**
  48917. * Serializes this layer (Glow or Highlight for example)
  48918. * @returns a serialized layer object
  48919. */
  48920. abstract serialize?(): any;
  48921. /**
  48922. * Initializes the effect layer with the required options.
  48923. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48924. */
  48925. protected _init(options: Partial<IEffectLayerOptions>): void;
  48926. /**
  48927. * Generates the index buffer of the full screen quad blending to the main canvas.
  48928. */
  48929. private _generateIndexBuffer;
  48930. /**
  48931. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48932. */
  48933. private _generateVertexBuffer;
  48934. /**
  48935. * Sets the main texture desired size which is the closest power of two
  48936. * of the engine canvas size.
  48937. */
  48938. private _setMainTextureSize;
  48939. /**
  48940. * Creates the main texture for the effect layer.
  48941. */
  48942. protected _createMainTexture(): void;
  48943. /**
  48944. * Adds specific effects defines.
  48945. * @param defines The defines to add specifics to.
  48946. */
  48947. protected _addCustomEffectDefines(defines: string[]): void;
  48948. /**
  48949. * Checks for the readiness of the element composing the layer.
  48950. * @param subMesh the mesh to check for
  48951. * @param useInstances specify wether or not to use instances to render the mesh
  48952. * @param emissiveTexture the associated emissive texture used to generate the glow
  48953. * @return true if ready otherwise, false
  48954. */
  48955. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48956. /**
  48957. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48958. */
  48959. render(): void;
  48960. /**
  48961. * Determine if a given mesh will be used in the current effect.
  48962. * @param mesh mesh to test
  48963. * @returns true if the mesh will be used
  48964. */
  48965. hasMesh(mesh: AbstractMesh): boolean;
  48966. /**
  48967. * Returns true if the layer contains information to display, otherwise false.
  48968. * @returns true if the glow layer should be rendered
  48969. */
  48970. shouldRender(): boolean;
  48971. /**
  48972. * Returns true if the mesh should render, otherwise false.
  48973. * @param mesh The mesh to render
  48974. * @returns true if it should render otherwise false
  48975. */
  48976. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48977. /**
  48978. * Returns true if the mesh can be rendered, otherwise false.
  48979. * @param mesh The mesh to render
  48980. * @param material The material used on the mesh
  48981. * @returns true if it can be rendered otherwise false
  48982. */
  48983. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48984. /**
  48985. * Returns true if the mesh should render, otherwise false.
  48986. * @param mesh The mesh to render
  48987. * @returns true if it should render otherwise false
  48988. */
  48989. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48990. /**
  48991. * Renders the submesh passed in parameter to the generation map.
  48992. */
  48993. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48994. /**
  48995. * Rebuild the required buffers.
  48996. * @hidden Internal use only.
  48997. */
  48998. _rebuild(): void;
  48999. /**
  49000. * Dispose only the render target textures and post process.
  49001. */
  49002. private _disposeTextureAndPostProcesses;
  49003. /**
  49004. * Dispose the highlight layer and free resources.
  49005. */
  49006. dispose(): void;
  49007. /**
  49008. * Gets the class name of the effect layer
  49009. * @returns the string with the class name of the effect layer
  49010. */
  49011. getClassName(): string;
  49012. /**
  49013. * Creates an effect layer from parsed effect layer data
  49014. * @param parsedEffectLayer defines effect layer data
  49015. * @param scene defines the current scene
  49016. * @param rootUrl defines the root URL containing the effect layer information
  49017. * @returns a parsed effect Layer
  49018. */
  49019. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49020. }
  49021. }
  49022. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49023. import { Scene } from "babylonjs/scene";
  49024. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49025. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49026. import { AbstractScene } from "babylonjs/abstractScene";
  49027. module "babylonjs/abstractScene" {
  49028. interface AbstractScene {
  49029. /**
  49030. * The list of effect layers (highlights/glow) added to the scene
  49031. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49032. * @see http://doc.babylonjs.com/how_to/glow_layer
  49033. */
  49034. effectLayers: Array<EffectLayer>;
  49035. /**
  49036. * Removes the given effect layer from this scene.
  49037. * @param toRemove defines the effect layer to remove
  49038. * @returns the index of the removed effect layer
  49039. */
  49040. removeEffectLayer(toRemove: EffectLayer): number;
  49041. /**
  49042. * Adds the given effect layer to this scene
  49043. * @param newEffectLayer defines the effect layer to add
  49044. */
  49045. addEffectLayer(newEffectLayer: EffectLayer): void;
  49046. }
  49047. }
  49048. /**
  49049. * Defines the layer scene component responsible to manage any effect layers
  49050. * in a given scene.
  49051. */
  49052. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49053. /**
  49054. * The component name helpfull to identify the component in the list of scene components.
  49055. */
  49056. readonly name: string;
  49057. /**
  49058. * The scene the component belongs to.
  49059. */
  49060. scene: Scene;
  49061. private _engine;
  49062. private _renderEffects;
  49063. private _needStencil;
  49064. private _previousStencilState;
  49065. /**
  49066. * Creates a new instance of the component for the given scene
  49067. * @param scene Defines the scene to register the component in
  49068. */
  49069. constructor(scene: Scene);
  49070. /**
  49071. * Registers the component in a given scene
  49072. */
  49073. register(): void;
  49074. /**
  49075. * Rebuilds the elements related to this component in case of
  49076. * context lost for instance.
  49077. */
  49078. rebuild(): void;
  49079. /**
  49080. * Serializes the component data to the specified json object
  49081. * @param serializationObject The object to serialize to
  49082. */
  49083. serialize(serializationObject: any): void;
  49084. /**
  49085. * Adds all the element from the container to the scene
  49086. * @param container the container holding the elements
  49087. */
  49088. addFromContainer(container: AbstractScene): void;
  49089. /**
  49090. * Removes all the elements in the container from the scene
  49091. * @param container contains the elements to remove
  49092. * @param dispose if the removed element should be disposed (default: false)
  49093. */
  49094. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49095. /**
  49096. * Disposes the component and the associated ressources.
  49097. */
  49098. dispose(): void;
  49099. private _isReadyForMesh;
  49100. private _renderMainTexture;
  49101. private _setStencil;
  49102. private _setStencilBack;
  49103. private _draw;
  49104. private _drawCamera;
  49105. private _drawRenderingGroup;
  49106. }
  49107. }
  49108. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49109. /** @hidden */
  49110. export var glowMapMergePixelShader: {
  49111. name: string;
  49112. shader: string;
  49113. };
  49114. }
  49115. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49116. /** @hidden */
  49117. export var glowMapMergeVertexShader: {
  49118. name: string;
  49119. shader: string;
  49120. };
  49121. }
  49122. declare module "babylonjs/Layers/glowLayer" {
  49123. import { Nullable } from "babylonjs/types";
  49124. import { Camera } from "babylonjs/Cameras/camera";
  49125. import { Scene } from "babylonjs/scene";
  49126. import { Color4 } from "babylonjs/Maths/math";
  49127. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49129. import { Mesh } from "babylonjs/Meshes/mesh";
  49130. import { Texture } from "babylonjs/Materials/Textures/texture";
  49131. import { Effect } from "babylonjs/Materials/effect";
  49132. import { Material } from "babylonjs/Materials/material";
  49133. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49134. import "babylonjs/Shaders/glowMapMerge.fragment";
  49135. import "babylonjs/Shaders/glowMapMerge.vertex";
  49136. import "babylonjs/Layers/effectLayerSceneComponent";
  49137. module "babylonjs/abstractScene" {
  49138. interface AbstractScene {
  49139. /**
  49140. * Return a the first highlight layer of the scene with a given name.
  49141. * @param name The name of the highlight layer to look for.
  49142. * @return The highlight layer if found otherwise null.
  49143. */
  49144. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49145. }
  49146. }
  49147. /**
  49148. * Glow layer options. This helps customizing the behaviour
  49149. * of the glow layer.
  49150. */
  49151. export interface IGlowLayerOptions {
  49152. /**
  49153. * Multiplication factor apply to the canvas size to compute the render target size
  49154. * used to generated the glowing objects (the smaller the faster).
  49155. */
  49156. mainTextureRatio: number;
  49157. /**
  49158. * Enforces a fixed size texture to ensure resize independant blur.
  49159. */
  49160. mainTextureFixedSize?: number;
  49161. /**
  49162. * How big is the kernel of the blur texture.
  49163. */
  49164. blurKernelSize: number;
  49165. /**
  49166. * The camera attached to the layer.
  49167. */
  49168. camera: Nullable<Camera>;
  49169. /**
  49170. * Enable MSAA by chosing the number of samples.
  49171. */
  49172. mainTextureSamples?: number;
  49173. /**
  49174. * The rendering group to draw the layer in.
  49175. */
  49176. renderingGroupId: number;
  49177. }
  49178. /**
  49179. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49180. *
  49181. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49182. * glowy meshes to your scene.
  49183. *
  49184. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49185. */
  49186. export class GlowLayer extends EffectLayer {
  49187. /**
  49188. * Effect Name of the layer.
  49189. */
  49190. static readonly EffectName: string;
  49191. /**
  49192. * The default blur kernel size used for the glow.
  49193. */
  49194. static DefaultBlurKernelSize: number;
  49195. /**
  49196. * The default texture size ratio used for the glow.
  49197. */
  49198. static DefaultTextureRatio: number;
  49199. /**
  49200. * Sets the kernel size of the blur.
  49201. */
  49202. /**
  49203. * Gets the kernel size of the blur.
  49204. */
  49205. blurKernelSize: number;
  49206. /**
  49207. * Sets the glow intensity.
  49208. */
  49209. /**
  49210. * Gets the glow intensity.
  49211. */
  49212. intensity: number;
  49213. private _options;
  49214. private _intensity;
  49215. private _horizontalBlurPostprocess1;
  49216. private _verticalBlurPostprocess1;
  49217. private _horizontalBlurPostprocess2;
  49218. private _verticalBlurPostprocess2;
  49219. private _blurTexture1;
  49220. private _blurTexture2;
  49221. private _postProcesses1;
  49222. private _postProcesses2;
  49223. private _includedOnlyMeshes;
  49224. private _excludedMeshes;
  49225. /**
  49226. * Callback used to let the user override the color selection on a per mesh basis
  49227. */
  49228. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49229. /**
  49230. * Callback used to let the user override the texture selection on a per mesh basis
  49231. */
  49232. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49233. /**
  49234. * Instantiates a new glow Layer and references it to the scene.
  49235. * @param name The name of the layer
  49236. * @param scene The scene to use the layer in
  49237. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49238. */
  49239. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49240. /**
  49241. * Get the effect name of the layer.
  49242. * @return The effect name
  49243. */
  49244. getEffectName(): string;
  49245. /**
  49246. * Create the merge effect. This is the shader use to blit the information back
  49247. * to the main canvas at the end of the scene rendering.
  49248. */
  49249. protected _createMergeEffect(): Effect;
  49250. /**
  49251. * Creates the render target textures and post processes used in the glow layer.
  49252. */
  49253. protected _createTextureAndPostProcesses(): void;
  49254. /**
  49255. * Checks for the readiness of the element composing the layer.
  49256. * @param subMesh the mesh to check for
  49257. * @param useInstances specify wether or not to use instances to render the mesh
  49258. * @param emissiveTexture the associated emissive texture used to generate the glow
  49259. * @return true if ready otherwise, false
  49260. */
  49261. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49262. /**
  49263. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49264. */
  49265. needStencil(): boolean;
  49266. /**
  49267. * Returns true if the mesh can be rendered, otherwise false.
  49268. * @param mesh The mesh to render
  49269. * @param material The material used on the mesh
  49270. * @returns true if it can be rendered otherwise false
  49271. */
  49272. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49273. /**
  49274. * Implementation specific of rendering the generating effect on the main canvas.
  49275. * @param effect The effect used to render through
  49276. */
  49277. protected _internalRender(effect: Effect): void;
  49278. /**
  49279. * Sets the required values for both the emissive texture and and the main color.
  49280. */
  49281. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49282. /**
  49283. * Returns true if the mesh should render, otherwise false.
  49284. * @param mesh The mesh to render
  49285. * @returns true if it should render otherwise false
  49286. */
  49287. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49288. /**
  49289. * Adds specific effects defines.
  49290. * @param defines The defines to add specifics to.
  49291. */
  49292. protected _addCustomEffectDefines(defines: string[]): void;
  49293. /**
  49294. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49295. * @param mesh The mesh to exclude from the glow layer
  49296. */
  49297. addExcludedMesh(mesh: Mesh): void;
  49298. /**
  49299. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49300. * @param mesh The mesh to remove
  49301. */
  49302. removeExcludedMesh(mesh: Mesh): void;
  49303. /**
  49304. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49305. * @param mesh The mesh to include in the glow layer
  49306. */
  49307. addIncludedOnlyMesh(mesh: Mesh): void;
  49308. /**
  49309. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49310. * @param mesh The mesh to remove
  49311. */
  49312. removeIncludedOnlyMesh(mesh: Mesh): void;
  49313. /**
  49314. * Determine if a given mesh will be used in the glow layer
  49315. * @param mesh The mesh to test
  49316. * @returns true if the mesh will be highlighted by the current glow layer
  49317. */
  49318. hasMesh(mesh: AbstractMesh): boolean;
  49319. /**
  49320. * Free any resources and references associated to a mesh.
  49321. * Internal use
  49322. * @param mesh The mesh to free.
  49323. * @hidden
  49324. */
  49325. _disposeMesh(mesh: Mesh): void;
  49326. /**
  49327. * Gets the class name of the effect layer
  49328. * @returns the string with the class name of the effect layer
  49329. */
  49330. getClassName(): string;
  49331. /**
  49332. * Serializes this glow layer
  49333. * @returns a serialized glow layer object
  49334. */
  49335. serialize(): any;
  49336. /**
  49337. * Creates a Glow Layer from parsed glow layer data
  49338. * @param parsedGlowLayer defines glow layer data
  49339. * @param scene defines the current scene
  49340. * @param rootUrl defines the root URL containing the glow layer information
  49341. * @returns a parsed Glow Layer
  49342. */
  49343. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49344. }
  49345. }
  49346. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49347. /** @hidden */
  49348. export var glowBlurPostProcessPixelShader: {
  49349. name: string;
  49350. shader: string;
  49351. };
  49352. }
  49353. declare module "babylonjs/Layers/highlightLayer" {
  49354. import { Observable } from "babylonjs/Misc/observable";
  49355. import { Nullable } from "babylonjs/types";
  49356. import { Camera } from "babylonjs/Cameras/camera";
  49357. import { Scene } from "babylonjs/scene";
  49358. import { Color3, Color4 } from "babylonjs/Maths/math";
  49359. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49361. import { Mesh } from "babylonjs/Meshes/mesh";
  49362. import { Effect } from "babylonjs/Materials/effect";
  49363. import { Material } from "babylonjs/Materials/material";
  49364. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49365. import "babylonjs/Shaders/glowMapMerge.fragment";
  49366. import "babylonjs/Shaders/glowMapMerge.vertex";
  49367. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49368. module "babylonjs/abstractScene" {
  49369. interface AbstractScene {
  49370. /**
  49371. * Return a the first highlight layer of the scene with a given name.
  49372. * @param name The name of the highlight layer to look for.
  49373. * @return The highlight layer if found otherwise null.
  49374. */
  49375. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49376. }
  49377. }
  49378. /**
  49379. * Highlight layer options. This helps customizing the behaviour
  49380. * of the highlight layer.
  49381. */
  49382. export interface IHighlightLayerOptions {
  49383. /**
  49384. * Multiplication factor apply to the canvas size to compute the render target size
  49385. * used to generated the glowing objects (the smaller the faster).
  49386. */
  49387. mainTextureRatio: number;
  49388. /**
  49389. * Enforces a fixed size texture to ensure resize independant blur.
  49390. */
  49391. mainTextureFixedSize?: number;
  49392. /**
  49393. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49394. * of the picture to blur (the smaller the faster).
  49395. */
  49396. blurTextureSizeRatio: number;
  49397. /**
  49398. * How big in texel of the blur texture is the vertical blur.
  49399. */
  49400. blurVerticalSize: number;
  49401. /**
  49402. * How big in texel of the blur texture is the horizontal blur.
  49403. */
  49404. blurHorizontalSize: number;
  49405. /**
  49406. * Alpha blending mode used to apply the blur. Default is combine.
  49407. */
  49408. alphaBlendingMode: number;
  49409. /**
  49410. * The camera attached to the layer.
  49411. */
  49412. camera: Nullable<Camera>;
  49413. /**
  49414. * Should we display highlight as a solid stroke?
  49415. */
  49416. isStroke?: boolean;
  49417. /**
  49418. * The rendering group to draw the layer in.
  49419. */
  49420. renderingGroupId: number;
  49421. }
  49422. /**
  49423. * The highlight layer Helps adding a glow effect around a mesh.
  49424. *
  49425. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49426. * glowy meshes to your scene.
  49427. *
  49428. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49429. */
  49430. export class HighlightLayer extends EffectLayer {
  49431. name: string;
  49432. /**
  49433. * Effect Name of the highlight layer.
  49434. */
  49435. static readonly EffectName: string;
  49436. /**
  49437. * The neutral color used during the preparation of the glow effect.
  49438. * This is black by default as the blend operation is a blend operation.
  49439. */
  49440. static NeutralColor: Color4;
  49441. /**
  49442. * Stencil value used for glowing meshes.
  49443. */
  49444. static GlowingMeshStencilReference: number;
  49445. /**
  49446. * Stencil value used for the other meshes in the scene.
  49447. */
  49448. static NormalMeshStencilReference: number;
  49449. /**
  49450. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49451. */
  49452. innerGlow: boolean;
  49453. /**
  49454. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49455. */
  49456. outerGlow: boolean;
  49457. /**
  49458. * Specifies the horizontal size of the blur.
  49459. */
  49460. /**
  49461. * Gets the horizontal size of the blur.
  49462. */
  49463. blurHorizontalSize: number;
  49464. /**
  49465. * Specifies the vertical size of the blur.
  49466. */
  49467. /**
  49468. * Gets the vertical size of the blur.
  49469. */
  49470. blurVerticalSize: number;
  49471. /**
  49472. * An event triggered when the highlight layer is being blurred.
  49473. */
  49474. onBeforeBlurObservable: Observable<HighlightLayer>;
  49475. /**
  49476. * An event triggered when the highlight layer has been blurred.
  49477. */
  49478. onAfterBlurObservable: Observable<HighlightLayer>;
  49479. private _instanceGlowingMeshStencilReference;
  49480. private _options;
  49481. private _downSamplePostprocess;
  49482. private _horizontalBlurPostprocess;
  49483. private _verticalBlurPostprocess;
  49484. private _blurTexture;
  49485. private _meshes;
  49486. private _excludedMeshes;
  49487. /**
  49488. * Instantiates a new highlight Layer and references it to the scene..
  49489. * @param name The name of the layer
  49490. * @param scene The scene to use the layer in
  49491. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49492. */
  49493. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49494. /**
  49495. * Get the effect name of the layer.
  49496. * @return The effect name
  49497. */
  49498. getEffectName(): string;
  49499. /**
  49500. * Create the merge effect. This is the shader use to blit the information back
  49501. * to the main canvas at the end of the scene rendering.
  49502. */
  49503. protected _createMergeEffect(): Effect;
  49504. /**
  49505. * Creates the render target textures and post processes used in the highlight layer.
  49506. */
  49507. protected _createTextureAndPostProcesses(): void;
  49508. /**
  49509. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49510. */
  49511. needStencil(): boolean;
  49512. /**
  49513. * Checks for the readiness of the element composing the layer.
  49514. * @param subMesh the mesh to check for
  49515. * @param useInstances specify wether or not to use instances to render the mesh
  49516. * @param emissiveTexture the associated emissive texture used to generate the glow
  49517. * @return true if ready otherwise, false
  49518. */
  49519. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49520. /**
  49521. * Implementation specific of rendering the generating effect on the main canvas.
  49522. * @param effect The effect used to render through
  49523. */
  49524. protected _internalRender(effect: Effect): void;
  49525. /**
  49526. * Returns true if the layer contains information to display, otherwise false.
  49527. */
  49528. shouldRender(): boolean;
  49529. /**
  49530. * Returns true if the mesh should render, otherwise false.
  49531. * @param mesh The mesh to render
  49532. * @returns true if it should render otherwise false
  49533. */
  49534. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49535. /**
  49536. * Sets the required values for both the emissive texture and and the main color.
  49537. */
  49538. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49539. /**
  49540. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49541. * @param mesh The mesh to exclude from the highlight layer
  49542. */
  49543. addExcludedMesh(mesh: Mesh): void;
  49544. /**
  49545. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49546. * @param mesh The mesh to highlight
  49547. */
  49548. removeExcludedMesh(mesh: Mesh): void;
  49549. /**
  49550. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49551. * @param mesh mesh to test
  49552. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49553. */
  49554. hasMesh(mesh: AbstractMesh): boolean;
  49555. /**
  49556. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49557. * @param mesh The mesh to highlight
  49558. * @param color The color of the highlight
  49559. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49560. */
  49561. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49562. /**
  49563. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49564. * @param mesh The mesh to highlight
  49565. */
  49566. removeMesh(mesh: Mesh): void;
  49567. /**
  49568. * Force the stencil to the normal expected value for none glowing parts
  49569. */
  49570. private _defaultStencilReference;
  49571. /**
  49572. * Free any resources and references associated to a mesh.
  49573. * Internal use
  49574. * @param mesh The mesh to free.
  49575. * @hidden
  49576. */
  49577. _disposeMesh(mesh: Mesh): void;
  49578. /**
  49579. * Dispose the highlight layer and free resources.
  49580. */
  49581. dispose(): void;
  49582. /**
  49583. * Gets the class name of the effect layer
  49584. * @returns the string with the class name of the effect layer
  49585. */
  49586. getClassName(): string;
  49587. /**
  49588. * Serializes this Highlight layer
  49589. * @returns a serialized Highlight layer object
  49590. */
  49591. serialize(): any;
  49592. /**
  49593. * Creates a Highlight layer from parsed Highlight layer data
  49594. * @param parsedHightlightLayer defines the Highlight layer data
  49595. * @param scene defines the current scene
  49596. * @param rootUrl defines the root URL containing the Highlight layer information
  49597. * @returns a parsed Highlight layer
  49598. */
  49599. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49600. }
  49601. }
  49602. declare module "babylonjs/Layers/index" {
  49603. export * from "babylonjs/Layers/effectLayer";
  49604. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49605. export * from "babylonjs/Layers/glowLayer";
  49606. export * from "babylonjs/Layers/highlightLayer";
  49607. export * from "babylonjs/Layers/layer";
  49608. export * from "babylonjs/Layers/layerSceneComponent";
  49609. }
  49610. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49611. /** @hidden */
  49612. export var lensFlarePixelShader: {
  49613. name: string;
  49614. shader: string;
  49615. };
  49616. }
  49617. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49618. /** @hidden */
  49619. export var lensFlareVertexShader: {
  49620. name: string;
  49621. shader: string;
  49622. };
  49623. }
  49624. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49625. import { Scene } from "babylonjs/scene";
  49626. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49628. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49629. import "babylonjs/Shaders/lensFlare.fragment";
  49630. import "babylonjs/Shaders/lensFlare.vertex";
  49631. /**
  49632. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49633. * It is usually composed of several `lensFlare`.
  49634. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49635. */
  49636. export class LensFlareSystem {
  49637. /**
  49638. * Define the name of the lens flare system
  49639. */
  49640. name: string;
  49641. /**
  49642. * List of lens flares used in this system.
  49643. */
  49644. lensFlares: LensFlare[];
  49645. /**
  49646. * Define a limit from the border the lens flare can be visible.
  49647. */
  49648. borderLimit: number;
  49649. /**
  49650. * Define a viewport border we do not want to see the lens flare in.
  49651. */
  49652. viewportBorder: number;
  49653. /**
  49654. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49655. */
  49656. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49657. /**
  49658. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49659. */
  49660. layerMask: number;
  49661. /**
  49662. * Define the id of the lens flare system in the scene.
  49663. * (equal to name by default)
  49664. */
  49665. id: string;
  49666. private _scene;
  49667. private _emitter;
  49668. private _vertexBuffers;
  49669. private _indexBuffer;
  49670. private _effect;
  49671. private _positionX;
  49672. private _positionY;
  49673. private _isEnabled;
  49674. /** @hidden */
  49675. static _SceneComponentInitialization: (scene: Scene) => void;
  49676. /**
  49677. * Instantiates a lens flare system.
  49678. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49679. * It is usually composed of several `lensFlare`.
  49680. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49681. * @param name Define the name of the lens flare system in the scene
  49682. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49683. * @param scene Define the scene the lens flare system belongs to
  49684. */
  49685. constructor(
  49686. /**
  49687. * Define the name of the lens flare system
  49688. */
  49689. name: string, emitter: any, scene: Scene);
  49690. /**
  49691. * Define if the lens flare system is enabled.
  49692. */
  49693. isEnabled: boolean;
  49694. /**
  49695. * Get the scene the effects belongs to.
  49696. * @returns the scene holding the lens flare system
  49697. */
  49698. getScene(): Scene;
  49699. /**
  49700. * Get the emitter of the lens flare system.
  49701. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49702. * @returns the emitter of the lens flare system
  49703. */
  49704. getEmitter(): any;
  49705. /**
  49706. * Set the emitter of the lens flare system.
  49707. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49708. * @param newEmitter Define the new emitter of the system
  49709. */
  49710. setEmitter(newEmitter: any): void;
  49711. /**
  49712. * Get the lens flare system emitter position.
  49713. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49714. * @returns the position
  49715. */
  49716. getEmitterPosition(): Vector3;
  49717. /**
  49718. * @hidden
  49719. */
  49720. computeEffectivePosition(globalViewport: Viewport): boolean;
  49721. /** @hidden */
  49722. _isVisible(): boolean;
  49723. /**
  49724. * @hidden
  49725. */
  49726. render(): boolean;
  49727. /**
  49728. * Dispose and release the lens flare with its associated resources.
  49729. */
  49730. dispose(): void;
  49731. /**
  49732. * Parse a lens flare system from a JSON repressentation
  49733. * @param parsedLensFlareSystem Define the JSON to parse
  49734. * @param scene Define the scene the parsed system should be instantiated in
  49735. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49736. * @returns the parsed system
  49737. */
  49738. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49739. /**
  49740. * Serialize the current Lens Flare System into a JSON representation.
  49741. * @returns the serialized JSON
  49742. */
  49743. serialize(): any;
  49744. }
  49745. }
  49746. declare module "babylonjs/LensFlares/lensFlare" {
  49747. import { Nullable } from "babylonjs/types";
  49748. import { Color3 } from "babylonjs/Maths/math";
  49749. import { Texture } from "babylonjs/Materials/Textures/texture";
  49750. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49751. /**
  49752. * This represents one of the lens effect in a `lensFlareSystem`.
  49753. * It controls one of the indiviual texture used in the effect.
  49754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49755. */
  49756. export class LensFlare {
  49757. /**
  49758. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49759. */
  49760. size: number;
  49761. /**
  49762. * 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.
  49763. */
  49764. position: number;
  49765. /**
  49766. * Define the lens color.
  49767. */
  49768. color: Color3;
  49769. /**
  49770. * Define the lens texture.
  49771. */
  49772. texture: Nullable<Texture>;
  49773. /**
  49774. * Define the alpha mode to render this particular lens.
  49775. */
  49776. alphaMode: number;
  49777. private _system;
  49778. /**
  49779. * Creates a new Lens Flare.
  49780. * This represents one of the lens effect in a `lensFlareSystem`.
  49781. * It controls one of the indiviual texture used in the effect.
  49782. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49783. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49784. * @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.
  49785. * @param color Define the lens color
  49786. * @param imgUrl Define the lens texture url
  49787. * @param system Define the `lensFlareSystem` this flare is part of
  49788. * @returns The newly created Lens Flare
  49789. */
  49790. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49791. /**
  49792. * Instantiates a new Lens Flare.
  49793. * This represents one of the lens effect in a `lensFlareSystem`.
  49794. * It controls one of the indiviual texture used in the effect.
  49795. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49796. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49797. * @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.
  49798. * @param color Define the lens color
  49799. * @param imgUrl Define the lens texture url
  49800. * @param system Define the `lensFlareSystem` this flare is part of
  49801. */
  49802. constructor(
  49803. /**
  49804. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49805. */
  49806. size: number,
  49807. /**
  49808. * 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.
  49809. */
  49810. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49811. /**
  49812. * Dispose and release the lens flare with its associated resources.
  49813. */
  49814. dispose(): void;
  49815. }
  49816. }
  49817. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49818. import { Nullable } from "babylonjs/types";
  49819. import { Scene } from "babylonjs/scene";
  49820. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49821. import { AbstractScene } from "babylonjs/abstractScene";
  49822. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49823. module "babylonjs/abstractScene" {
  49824. interface AbstractScene {
  49825. /**
  49826. * The list of lens flare system added to the scene
  49827. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49828. */
  49829. lensFlareSystems: Array<LensFlareSystem>;
  49830. /**
  49831. * Removes the given lens flare system from this scene.
  49832. * @param toRemove The lens flare system to remove
  49833. * @returns The index of the removed lens flare system
  49834. */
  49835. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49836. /**
  49837. * Adds the given lens flare system to this scene
  49838. * @param newLensFlareSystem The lens flare system to add
  49839. */
  49840. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49841. /**
  49842. * Gets a lens flare system using its name
  49843. * @param name defines the name to look for
  49844. * @returns the lens flare system or null if not found
  49845. */
  49846. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49847. /**
  49848. * Gets a lens flare system using its id
  49849. * @param id defines the id to look for
  49850. * @returns the lens flare system or null if not found
  49851. */
  49852. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49853. }
  49854. }
  49855. /**
  49856. * Defines the lens flare scene component responsible to manage any lens flares
  49857. * in a given scene.
  49858. */
  49859. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49860. /**
  49861. * The component name helpfull to identify the component in the list of scene components.
  49862. */
  49863. readonly name: string;
  49864. /**
  49865. * The scene the component belongs to.
  49866. */
  49867. scene: Scene;
  49868. /**
  49869. * Creates a new instance of the component for the given scene
  49870. * @param scene Defines the scene to register the component in
  49871. */
  49872. constructor(scene: Scene);
  49873. /**
  49874. * Registers the component in a given scene
  49875. */
  49876. register(): void;
  49877. /**
  49878. * Rebuilds the elements related to this component in case of
  49879. * context lost for instance.
  49880. */
  49881. rebuild(): void;
  49882. /**
  49883. * Adds all the element from the container to the scene
  49884. * @param container the container holding the elements
  49885. */
  49886. addFromContainer(container: AbstractScene): void;
  49887. /**
  49888. * Removes all the elements in the container from the scene
  49889. * @param container contains the elements to remove
  49890. * @param dispose if the removed element should be disposed (default: false)
  49891. */
  49892. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49893. /**
  49894. * Serializes the component data to the specified json object
  49895. * @param serializationObject The object to serialize to
  49896. */
  49897. serialize(serializationObject: any): void;
  49898. /**
  49899. * Disposes the component and the associated ressources.
  49900. */
  49901. dispose(): void;
  49902. private _draw;
  49903. }
  49904. }
  49905. declare module "babylonjs/LensFlares/index" {
  49906. export * from "babylonjs/LensFlares/lensFlare";
  49907. export * from "babylonjs/LensFlares/lensFlareSystem";
  49908. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49909. }
  49910. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49911. import { Scene } from "babylonjs/scene";
  49912. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49913. import { AbstractScene } from "babylonjs/abstractScene";
  49914. /**
  49915. * Defines the shadow generator component responsible to manage any shadow generators
  49916. * in a given scene.
  49917. */
  49918. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49919. /**
  49920. * The component name helpfull to identify the component in the list of scene components.
  49921. */
  49922. readonly name: string;
  49923. /**
  49924. * The scene the component belongs to.
  49925. */
  49926. scene: Scene;
  49927. /**
  49928. * Creates a new instance of the component for the given scene
  49929. * @param scene Defines the scene to register the component in
  49930. */
  49931. constructor(scene: Scene);
  49932. /**
  49933. * Registers the component in a given scene
  49934. */
  49935. register(): void;
  49936. /**
  49937. * Rebuilds the elements related to this component in case of
  49938. * context lost for instance.
  49939. */
  49940. rebuild(): void;
  49941. /**
  49942. * Serializes the component data to the specified json object
  49943. * @param serializationObject The object to serialize to
  49944. */
  49945. serialize(serializationObject: any): void;
  49946. /**
  49947. * Adds all the element from the container to the scene
  49948. * @param container the container holding the elements
  49949. */
  49950. addFromContainer(container: AbstractScene): void;
  49951. /**
  49952. * Removes all the elements in the container from the scene
  49953. * @param container contains the elements to remove
  49954. * @param dispose if the removed element should be disposed (default: false)
  49955. */
  49956. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49957. /**
  49958. * Rebuilds the elements related to this component in case of
  49959. * context lost for instance.
  49960. */
  49961. dispose(): void;
  49962. private _gatherRenderTargets;
  49963. }
  49964. }
  49965. declare module "babylonjs/Lights/Shadows/index" {
  49966. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49967. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49968. }
  49969. declare module "babylonjs/Lights/pointLight" {
  49970. import { Scene } from "babylonjs/scene";
  49971. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49973. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49974. import { Effect } from "babylonjs/Materials/effect";
  49975. /**
  49976. * A point light is a light defined by an unique point in world space.
  49977. * The light is emitted in every direction from this point.
  49978. * A good example of a point light is a standard light bulb.
  49979. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49980. */
  49981. export class PointLight extends ShadowLight {
  49982. private _shadowAngle;
  49983. /**
  49984. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49985. * This specifies what angle the shadow will use to be created.
  49986. *
  49987. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49988. */
  49989. /**
  49990. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49991. * This specifies what angle the shadow will use to be created.
  49992. *
  49993. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49994. */
  49995. shadowAngle: number;
  49996. /**
  49997. * Gets the direction if it has been set.
  49998. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49999. */
  50000. /**
  50001. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50002. */
  50003. direction: Vector3;
  50004. /**
  50005. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50006. * A PointLight emits the light in every direction.
  50007. * It can cast shadows.
  50008. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50009. * ```javascript
  50010. * var pointLight = new PointLight("pl", camera.position, scene);
  50011. * ```
  50012. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50013. * @param name The light friendly name
  50014. * @param position The position of the point light in the scene
  50015. * @param scene The scene the lights belongs to
  50016. */
  50017. constructor(name: string, position: Vector3, scene: Scene);
  50018. /**
  50019. * Returns the string "PointLight"
  50020. * @returns the class name
  50021. */
  50022. getClassName(): string;
  50023. /**
  50024. * Returns the integer 0.
  50025. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50026. */
  50027. getTypeID(): number;
  50028. /**
  50029. * Specifies wether or not the shadowmap should be a cube texture.
  50030. * @returns true if the shadowmap needs to be a cube texture.
  50031. */
  50032. needCube(): boolean;
  50033. /**
  50034. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50035. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50036. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50037. */
  50038. getShadowDirection(faceIndex?: number): Vector3;
  50039. /**
  50040. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50041. * - fov = PI / 2
  50042. * - aspect ratio : 1.0
  50043. * - z-near and far equal to the active camera minZ and maxZ.
  50044. * Returns the PointLight.
  50045. */
  50046. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50047. protected _buildUniformLayout(): void;
  50048. /**
  50049. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50050. * @param effect The effect to update
  50051. * @param lightIndex The index of the light in the effect to update
  50052. * @returns The point light
  50053. */
  50054. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50055. /**
  50056. * Prepares the list of defines specific to the light type.
  50057. * @param defines the list of defines
  50058. * @param lightIndex defines the index of the light for the effect
  50059. */
  50060. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50061. }
  50062. }
  50063. declare module "babylonjs/Lights/index" {
  50064. export * from "babylonjs/Lights/light";
  50065. export * from "babylonjs/Lights/shadowLight";
  50066. export * from "babylonjs/Lights/Shadows/index";
  50067. export * from "babylonjs/Lights/directionalLight";
  50068. export * from "babylonjs/Lights/hemisphericLight";
  50069. export * from "babylonjs/Lights/pointLight";
  50070. export * from "babylonjs/Lights/spotLight";
  50071. }
  50072. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50073. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50074. /**
  50075. * Header information of HDR texture files.
  50076. */
  50077. export interface HDRInfo {
  50078. /**
  50079. * The height of the texture in pixels.
  50080. */
  50081. height: number;
  50082. /**
  50083. * The width of the texture in pixels.
  50084. */
  50085. width: number;
  50086. /**
  50087. * The index of the beginning of the data in the binary file.
  50088. */
  50089. dataPosition: number;
  50090. }
  50091. /**
  50092. * This groups tools to convert HDR texture to native colors array.
  50093. */
  50094. export class HDRTools {
  50095. private static Ldexp;
  50096. private static Rgbe2float;
  50097. private static readStringLine;
  50098. /**
  50099. * Reads header information from an RGBE texture stored in a native array.
  50100. * More information on this format are available here:
  50101. * https://en.wikipedia.org/wiki/RGBE_image_format
  50102. *
  50103. * @param uint8array The binary file stored in native array.
  50104. * @return The header information.
  50105. */
  50106. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50107. /**
  50108. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50109. * This RGBE texture needs to store the information as a panorama.
  50110. *
  50111. * More information on this format are available here:
  50112. * https://en.wikipedia.org/wiki/RGBE_image_format
  50113. *
  50114. * @param buffer The binary file stored in an array buffer.
  50115. * @param size The expected size of the extracted cubemap.
  50116. * @return The Cube Map information.
  50117. */
  50118. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50119. /**
  50120. * Returns the pixels data extracted from an RGBE texture.
  50121. * This pixels will be stored left to right up to down in the R G B order in one array.
  50122. *
  50123. * More information on this format are available here:
  50124. * https://en.wikipedia.org/wiki/RGBE_image_format
  50125. *
  50126. * @param uint8array The binary file stored in an array buffer.
  50127. * @param hdrInfo The header information of the file.
  50128. * @return The pixels data in RGB right to left up to down order.
  50129. */
  50130. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50131. private static RGBE_ReadPixels_RLE;
  50132. }
  50133. }
  50134. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50135. import { Nullable } from "babylonjs/types";
  50136. import { Scene } from "babylonjs/scene";
  50137. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50139. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50140. /**
  50141. * This represents a texture coming from an HDR input.
  50142. *
  50143. * The only supported format is currently panorama picture stored in RGBE format.
  50144. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50145. */
  50146. export class HDRCubeTexture extends BaseTexture {
  50147. private static _facesMapping;
  50148. private _generateHarmonics;
  50149. private _noMipmap;
  50150. private _textureMatrix;
  50151. private _size;
  50152. private _onLoad;
  50153. private _onError;
  50154. /**
  50155. * The texture URL.
  50156. */
  50157. url: string;
  50158. /**
  50159. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50160. */
  50161. coordinatesMode: number;
  50162. protected _isBlocking: boolean;
  50163. /**
  50164. * Sets wether or not the texture is blocking during loading.
  50165. */
  50166. /**
  50167. * Gets wether or not the texture is blocking during loading.
  50168. */
  50169. isBlocking: boolean;
  50170. protected _rotationY: number;
  50171. /**
  50172. * Sets texture matrix rotation angle around Y axis in radians.
  50173. */
  50174. /**
  50175. * Gets texture matrix rotation angle around Y axis radians.
  50176. */
  50177. rotationY: number;
  50178. /**
  50179. * Gets or sets the center of the bounding box associated with the cube texture
  50180. * It must define where the camera used to render the texture was set
  50181. */
  50182. boundingBoxPosition: Vector3;
  50183. private _boundingBoxSize;
  50184. /**
  50185. * Gets or sets the size of the bounding box associated with the cube texture
  50186. * When defined, the cubemap will switch to local mode
  50187. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50188. * @example https://www.babylonjs-playground.com/#RNASML
  50189. */
  50190. boundingBoxSize: Vector3;
  50191. /**
  50192. * Instantiates an HDRTexture from the following parameters.
  50193. *
  50194. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50195. * @param scene The scene the texture will be used in
  50196. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50197. * @param noMipmap Forces to not generate the mipmap if true
  50198. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50199. * @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)
  50200. * @param reserved Reserved flag for internal use.
  50201. */
  50202. 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>);
  50203. /**
  50204. * Get the current class name of the texture useful for serialization or dynamic coding.
  50205. * @returns "HDRCubeTexture"
  50206. */
  50207. getClassName(): string;
  50208. /**
  50209. * Occurs when the file is raw .hdr file.
  50210. */
  50211. private loadTexture;
  50212. clone(): HDRCubeTexture;
  50213. delayLoad(): void;
  50214. /**
  50215. * Get the texture reflection matrix used to rotate/transform the reflection.
  50216. * @returns the reflection matrix
  50217. */
  50218. getReflectionTextureMatrix(): Matrix;
  50219. /**
  50220. * Set the texture reflection matrix used to rotate/transform the reflection.
  50221. * @param value Define the reflection matrix to set
  50222. */
  50223. setReflectionTextureMatrix(value: Matrix): void;
  50224. /**
  50225. * Parses a JSON representation of an HDR Texture in order to create the texture
  50226. * @param parsedTexture Define the JSON representation
  50227. * @param scene Define the scene the texture should be created in
  50228. * @param rootUrl Define the root url in case we need to load relative dependencies
  50229. * @returns the newly created texture after parsing
  50230. */
  50231. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50232. serialize(): any;
  50233. }
  50234. }
  50235. declare module "babylonjs/Physics/physicsEngine" {
  50236. import { Nullable } from "babylonjs/types";
  50237. import { Vector3 } from "babylonjs/Maths/math";
  50238. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50239. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50240. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50241. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50242. /**
  50243. * Class used to control physics engine
  50244. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50245. */
  50246. export class PhysicsEngine implements IPhysicsEngine {
  50247. private _physicsPlugin;
  50248. /**
  50249. * Global value used to control the smallest number supported by the simulation
  50250. */
  50251. static Epsilon: number;
  50252. private _impostors;
  50253. private _joints;
  50254. /**
  50255. * Gets the gravity vector used by the simulation
  50256. */
  50257. gravity: Vector3;
  50258. /**
  50259. * Factory used to create the default physics plugin.
  50260. * @returns The default physics plugin
  50261. */
  50262. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50263. /**
  50264. * Creates a new Physics Engine
  50265. * @param gravity defines the gravity vector used by the simulation
  50266. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50267. */
  50268. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50269. /**
  50270. * Sets the gravity vector used by the simulation
  50271. * @param gravity defines the gravity vector to use
  50272. */
  50273. setGravity(gravity: Vector3): void;
  50274. /**
  50275. * Set the time step of the physics engine.
  50276. * Default is 1/60.
  50277. * To slow it down, enter 1/600 for example.
  50278. * To speed it up, 1/30
  50279. * @param newTimeStep defines the new timestep to apply to this world.
  50280. */
  50281. setTimeStep(newTimeStep?: number): void;
  50282. /**
  50283. * Get the time step of the physics engine.
  50284. * @returns the current time step
  50285. */
  50286. getTimeStep(): number;
  50287. /**
  50288. * Release all resources
  50289. */
  50290. dispose(): void;
  50291. /**
  50292. * Gets the name of the current physics plugin
  50293. * @returns the name of the plugin
  50294. */
  50295. getPhysicsPluginName(): string;
  50296. /**
  50297. * Adding a new impostor for the impostor tracking.
  50298. * This will be done by the impostor itself.
  50299. * @param impostor the impostor to add
  50300. */
  50301. addImpostor(impostor: PhysicsImpostor): void;
  50302. /**
  50303. * Remove an impostor from the engine.
  50304. * This impostor and its mesh will not longer be updated by the physics engine.
  50305. * @param impostor the impostor to remove
  50306. */
  50307. removeImpostor(impostor: PhysicsImpostor): void;
  50308. /**
  50309. * Add a joint to the physics engine
  50310. * @param mainImpostor defines the main impostor to which the joint is added.
  50311. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50312. * @param joint defines the joint that will connect both impostors.
  50313. */
  50314. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50315. /**
  50316. * Removes a joint from the simulation
  50317. * @param mainImpostor defines the impostor used with the joint
  50318. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50319. * @param joint defines the joint to remove
  50320. */
  50321. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50322. /**
  50323. * Called by the scene. No need to call it.
  50324. * @param delta defines the timespam between frames
  50325. */
  50326. _step(delta: number): void;
  50327. /**
  50328. * Gets the current plugin used to run the simulation
  50329. * @returns current plugin
  50330. */
  50331. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50332. /**
  50333. * Gets the list of physic impostors
  50334. * @returns an array of PhysicsImpostor
  50335. */
  50336. getImpostors(): Array<PhysicsImpostor>;
  50337. /**
  50338. * Gets the impostor for a physics enabled object
  50339. * @param object defines the object impersonated by the impostor
  50340. * @returns the PhysicsImpostor or null if not found
  50341. */
  50342. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50343. /**
  50344. * Gets the impostor for a physics body object
  50345. * @param body defines physics body used by the impostor
  50346. * @returns the PhysicsImpostor or null if not found
  50347. */
  50348. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50349. /**
  50350. * Does a raycast in the physics world
  50351. * @param from when should the ray start?
  50352. * @param to when should the ray end?
  50353. * @returns PhysicsRaycastResult
  50354. */
  50355. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50356. }
  50357. }
  50358. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50359. import { Nullable } from "babylonjs/types";
  50360. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50362. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50363. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50364. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50365. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50366. /** @hidden */
  50367. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50368. private _useDeltaForWorldStep;
  50369. world: any;
  50370. name: string;
  50371. private _physicsMaterials;
  50372. private _fixedTimeStep;
  50373. private _cannonRaycastResult;
  50374. private _raycastResult;
  50375. private _removeAfterStep;
  50376. BJSCANNON: any;
  50377. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50378. setGravity(gravity: Vector3): void;
  50379. setTimeStep(timeStep: number): void;
  50380. getTimeStep(): number;
  50381. executeStep(delta: number): void;
  50382. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50383. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50384. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50385. private _processChildMeshes;
  50386. removePhysicsBody(impostor: PhysicsImpostor): void;
  50387. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50388. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50389. private _addMaterial;
  50390. private _checkWithEpsilon;
  50391. private _createShape;
  50392. private _createHeightmap;
  50393. private _minus90X;
  50394. private _plus90X;
  50395. private _tmpPosition;
  50396. private _tmpDeltaPosition;
  50397. private _tmpUnityRotation;
  50398. private _updatePhysicsBodyTransformation;
  50399. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50400. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50401. isSupported(): boolean;
  50402. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50403. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50404. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50405. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50406. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50407. getBodyMass(impostor: PhysicsImpostor): number;
  50408. getBodyFriction(impostor: PhysicsImpostor): number;
  50409. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50410. getBodyRestitution(impostor: PhysicsImpostor): number;
  50411. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50412. sleepBody(impostor: PhysicsImpostor): void;
  50413. wakeUpBody(impostor: PhysicsImpostor): void;
  50414. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50415. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50416. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50417. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50418. getRadius(impostor: PhysicsImpostor): number;
  50419. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50420. dispose(): void;
  50421. private _extendNamespace;
  50422. /**
  50423. * Does a raycast in the physics world
  50424. * @param from when should the ray start?
  50425. * @param to when should the ray end?
  50426. * @returns PhysicsRaycastResult
  50427. */
  50428. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50429. }
  50430. }
  50431. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50432. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50433. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50434. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50436. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50437. import { Nullable } from "babylonjs/types";
  50438. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50439. /** @hidden */
  50440. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50441. world: any;
  50442. name: string;
  50443. BJSOIMO: any;
  50444. private _raycastResult;
  50445. constructor(iterations?: number, oimoInjection?: any);
  50446. setGravity(gravity: Vector3): void;
  50447. setTimeStep(timeStep: number): void;
  50448. getTimeStep(): number;
  50449. private _tmpImpostorsArray;
  50450. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50451. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50452. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50453. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50454. private _tmpPositionVector;
  50455. removePhysicsBody(impostor: PhysicsImpostor): void;
  50456. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50457. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50458. isSupported(): boolean;
  50459. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50460. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50461. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50462. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50463. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50464. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50465. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50466. getBodyMass(impostor: PhysicsImpostor): number;
  50467. getBodyFriction(impostor: PhysicsImpostor): number;
  50468. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50469. getBodyRestitution(impostor: PhysicsImpostor): number;
  50470. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50471. sleepBody(impostor: PhysicsImpostor): void;
  50472. wakeUpBody(impostor: PhysicsImpostor): void;
  50473. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50474. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50475. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50476. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50477. getRadius(impostor: PhysicsImpostor): number;
  50478. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50479. dispose(): void;
  50480. /**
  50481. * Does a raycast in the physics world
  50482. * @param from when should the ray start?
  50483. * @param to when should the ray end?
  50484. * @returns PhysicsRaycastResult
  50485. */
  50486. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50487. }
  50488. }
  50489. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50490. import { Nullable } from "babylonjs/types";
  50491. import { Scene } from "babylonjs/scene";
  50492. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50493. import { Mesh } from "babylonjs/Meshes/mesh";
  50494. /**
  50495. * Class containing static functions to help procedurally build meshes
  50496. */
  50497. export class RibbonBuilder {
  50498. /**
  50499. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50500. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50501. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50502. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50503. * * 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
  50504. * * 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
  50505. * * 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
  50506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50508. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50509. * * 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
  50510. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50511. * * 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
  50512. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50514. * @param name defines the name of the mesh
  50515. * @param options defines the options used to create the mesh
  50516. * @param scene defines the hosting scene
  50517. * @returns the ribbon mesh
  50518. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50520. */
  50521. static CreateRibbon(name: string, options: {
  50522. pathArray: Vector3[][];
  50523. closeArray?: boolean;
  50524. closePath?: boolean;
  50525. offset?: number;
  50526. updatable?: boolean;
  50527. sideOrientation?: number;
  50528. frontUVs?: Vector4;
  50529. backUVs?: Vector4;
  50530. instance?: Mesh;
  50531. invertUV?: boolean;
  50532. uvs?: Vector2[];
  50533. colors?: Color4[];
  50534. }, scene?: Nullable<Scene>): Mesh;
  50535. }
  50536. }
  50537. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50538. import { Nullable } from "babylonjs/types";
  50539. import { Scene } from "babylonjs/scene";
  50540. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50541. import { Mesh } from "babylonjs/Meshes/mesh";
  50542. /**
  50543. * Class containing static functions to help procedurally build meshes
  50544. */
  50545. export class ShapeBuilder {
  50546. /**
  50547. * 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.
  50548. * * 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.
  50549. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50550. * * 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.
  50551. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50552. * * 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
  50553. * * 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
  50554. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50557. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50559. * @param name defines the name of the mesh
  50560. * @param options defines the options used to create the mesh
  50561. * @param scene defines the hosting scene
  50562. * @returns the extruded shape mesh
  50563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50565. */
  50566. static ExtrudeShape(name: string, options: {
  50567. shape: Vector3[];
  50568. path: Vector3[];
  50569. scale?: number;
  50570. rotation?: number;
  50571. cap?: number;
  50572. updatable?: boolean;
  50573. sideOrientation?: number;
  50574. frontUVs?: Vector4;
  50575. backUVs?: Vector4;
  50576. instance?: Mesh;
  50577. invertUV?: boolean;
  50578. }, scene?: Nullable<Scene>): Mesh;
  50579. /**
  50580. * Creates an custom extruded shape mesh.
  50581. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50582. * * 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.
  50583. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50584. * * 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
  50585. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50586. * * 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
  50587. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50588. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50589. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50590. * * 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
  50591. * * 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
  50592. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50595. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50597. * @param name defines the name of the mesh
  50598. * @param options defines the options used to create the mesh
  50599. * @param scene defines the hosting scene
  50600. * @returns the custom extruded shape mesh
  50601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50602. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50604. */
  50605. static ExtrudeShapeCustom(name: string, options: {
  50606. shape: Vector3[];
  50607. path: Vector3[];
  50608. scaleFunction?: any;
  50609. rotationFunction?: any;
  50610. ribbonCloseArray?: boolean;
  50611. ribbonClosePath?: boolean;
  50612. cap?: number;
  50613. updatable?: boolean;
  50614. sideOrientation?: number;
  50615. frontUVs?: Vector4;
  50616. backUVs?: Vector4;
  50617. instance?: Mesh;
  50618. invertUV?: boolean;
  50619. }, scene?: Nullable<Scene>): Mesh;
  50620. private static _ExtrudeShapeGeneric;
  50621. }
  50622. }
  50623. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50624. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50625. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50626. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50627. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50628. import { Nullable } from "babylonjs/types";
  50629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50630. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50631. /**
  50632. * AmmoJS Physics plugin
  50633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50634. * @see https://github.com/kripken/ammo.js/
  50635. */
  50636. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50637. private _useDeltaForWorldStep;
  50638. /**
  50639. * Reference to the Ammo library
  50640. */
  50641. bjsAMMO: any;
  50642. /**
  50643. * Created ammoJS world which physics bodies are added to
  50644. */
  50645. world: any;
  50646. /**
  50647. * Name of the plugin
  50648. */
  50649. name: string;
  50650. private _timeStep;
  50651. private _fixedTimeStep;
  50652. private _maxSteps;
  50653. private _tmpQuaternion;
  50654. private _tmpAmmoTransform;
  50655. private _tmpAmmoQuaternion;
  50656. private _tmpAmmoConcreteContactResultCallback;
  50657. private _collisionConfiguration;
  50658. private _dispatcher;
  50659. private _overlappingPairCache;
  50660. private _solver;
  50661. private _softBodySolver;
  50662. private _tmpAmmoVectorA;
  50663. private _tmpAmmoVectorB;
  50664. private _tmpAmmoVectorC;
  50665. private _tmpAmmoVectorD;
  50666. private _tmpContactCallbackResult;
  50667. private _tmpAmmoVectorRCA;
  50668. private _tmpAmmoVectorRCB;
  50669. private _raycastResult;
  50670. private static readonly DISABLE_COLLISION_FLAG;
  50671. private static readonly KINEMATIC_FLAG;
  50672. private static readonly DISABLE_DEACTIVATION_FLAG;
  50673. /**
  50674. * Initializes the ammoJS plugin
  50675. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50676. * @param ammoInjection can be used to inject your own ammo reference
  50677. */
  50678. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50679. /**
  50680. * Sets the gravity of the physics world (m/(s^2))
  50681. * @param gravity Gravity to set
  50682. */
  50683. setGravity(gravity: Vector3): void;
  50684. /**
  50685. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50686. * @param timeStep timestep to use in seconds
  50687. */
  50688. setTimeStep(timeStep: number): void;
  50689. /**
  50690. * 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)
  50691. * @param fixedTimeStep fixedTimeStep to use in seconds
  50692. */
  50693. setFixedTimeStep(fixedTimeStep: number): void;
  50694. /**
  50695. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50696. * @param maxSteps the maximum number of steps by the physics engine per frame
  50697. */
  50698. setMaxSteps(maxSteps: number): void;
  50699. /**
  50700. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50701. * @returns the current timestep in seconds
  50702. */
  50703. getTimeStep(): number;
  50704. private _isImpostorInContact;
  50705. private _isImpostorPairInContact;
  50706. private _stepSimulation;
  50707. /**
  50708. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50709. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50710. * After the step the babylon meshes are set to the position of the physics imposters
  50711. * @param delta amount of time to step forward
  50712. * @param impostors array of imposters to update before/after the step
  50713. */
  50714. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50715. /**
  50716. * Update babylon mesh to match physics world object
  50717. * @param impostor imposter to match
  50718. */
  50719. private _afterSoftStep;
  50720. /**
  50721. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50722. * @param impostor imposter to match
  50723. */
  50724. private _ropeStep;
  50725. /**
  50726. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50727. * @param impostor imposter to match
  50728. */
  50729. private _softbodyOrClothStep;
  50730. private _tmpVector;
  50731. private _tmpMatrix;
  50732. /**
  50733. * Applies an impulse on the imposter
  50734. * @param impostor imposter to apply impulse to
  50735. * @param force amount of force to be applied to the imposter
  50736. * @param contactPoint the location to apply the impulse on the imposter
  50737. */
  50738. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50739. /**
  50740. * Applies a force on the imposter
  50741. * @param impostor imposter to apply force
  50742. * @param force amount of force to be applied to the imposter
  50743. * @param contactPoint the location to apply the force on the imposter
  50744. */
  50745. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50746. /**
  50747. * Creates a physics body using the plugin
  50748. * @param impostor the imposter to create the physics body on
  50749. */
  50750. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50751. /**
  50752. * Removes the physics body from the imposter and disposes of the body's memory
  50753. * @param impostor imposter to remove the physics body from
  50754. */
  50755. removePhysicsBody(impostor: PhysicsImpostor): void;
  50756. /**
  50757. * Generates a joint
  50758. * @param impostorJoint the imposter joint to create the joint with
  50759. */
  50760. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50761. /**
  50762. * Removes a joint
  50763. * @param impostorJoint the imposter joint to remove the joint from
  50764. */
  50765. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50766. private _addMeshVerts;
  50767. /**
  50768. * Initialise the soft body vertices to match its object's (mesh) vertices
  50769. * Softbody vertices (nodes) are in world space and to match this
  50770. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50771. * @param impostor to create the softbody for
  50772. */
  50773. private _softVertexData;
  50774. /**
  50775. * Create an impostor's soft body
  50776. * @param impostor to create the softbody for
  50777. */
  50778. private _createSoftbody;
  50779. /**
  50780. * Create cloth for an impostor
  50781. * @param impostor to create the softbody for
  50782. */
  50783. private _createCloth;
  50784. /**
  50785. * Create rope for an impostor
  50786. * @param impostor to create the softbody for
  50787. */
  50788. private _createRope;
  50789. private _addHullVerts;
  50790. private _createShape;
  50791. /**
  50792. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50793. * @param impostor imposter containing the physics body and babylon object
  50794. */
  50795. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50796. /**
  50797. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50798. * @param impostor imposter containing the physics body and babylon object
  50799. * @param newPosition new position
  50800. * @param newRotation new rotation
  50801. */
  50802. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50803. /**
  50804. * If this plugin is supported
  50805. * @returns true if its supported
  50806. */
  50807. isSupported(): boolean;
  50808. /**
  50809. * Sets the linear velocity of the physics body
  50810. * @param impostor imposter to set the velocity on
  50811. * @param velocity velocity to set
  50812. */
  50813. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50814. /**
  50815. * Sets the angular velocity of the physics body
  50816. * @param impostor imposter to set the velocity on
  50817. * @param velocity velocity to set
  50818. */
  50819. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50820. /**
  50821. * gets the linear velocity
  50822. * @param impostor imposter to get linear velocity from
  50823. * @returns linear velocity
  50824. */
  50825. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50826. /**
  50827. * gets the angular velocity
  50828. * @param impostor imposter to get angular velocity from
  50829. * @returns angular velocity
  50830. */
  50831. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50832. /**
  50833. * Sets the mass of physics body
  50834. * @param impostor imposter to set the mass on
  50835. * @param mass mass to set
  50836. */
  50837. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50838. /**
  50839. * Gets the mass of the physics body
  50840. * @param impostor imposter to get the mass from
  50841. * @returns mass
  50842. */
  50843. getBodyMass(impostor: PhysicsImpostor): number;
  50844. /**
  50845. * Gets friction of the impostor
  50846. * @param impostor impostor to get friction from
  50847. * @returns friction value
  50848. */
  50849. getBodyFriction(impostor: PhysicsImpostor): number;
  50850. /**
  50851. * Sets friction of the impostor
  50852. * @param impostor impostor to set friction on
  50853. * @param friction friction value
  50854. */
  50855. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50856. /**
  50857. * Gets restitution of the impostor
  50858. * @param impostor impostor to get restitution from
  50859. * @returns restitution value
  50860. */
  50861. getBodyRestitution(impostor: PhysicsImpostor): number;
  50862. /**
  50863. * Sets resitution of the impostor
  50864. * @param impostor impostor to set resitution on
  50865. * @param restitution resitution value
  50866. */
  50867. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50868. /**
  50869. * Gets pressure inside the impostor
  50870. * @param impostor impostor to get pressure from
  50871. * @returns pressure value
  50872. */
  50873. getBodyPressure(impostor: PhysicsImpostor): number;
  50874. /**
  50875. * Sets pressure inside a soft body impostor
  50876. * Cloth and rope must remain 0 pressure
  50877. * @param impostor impostor to set pressure on
  50878. * @param pressure pressure value
  50879. */
  50880. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50881. /**
  50882. * Gets stiffness of the impostor
  50883. * @param impostor impostor to get stiffness from
  50884. * @returns pressure value
  50885. */
  50886. getBodyStiffness(impostor: PhysicsImpostor): number;
  50887. /**
  50888. * Sets stiffness of the impostor
  50889. * @param impostor impostor to set stiffness on
  50890. * @param stiffness stiffness value from 0 to 1
  50891. */
  50892. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50893. /**
  50894. * Gets velocityIterations of the impostor
  50895. * @param impostor impostor to get velocity iterations from
  50896. * @returns velocityIterations value
  50897. */
  50898. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50899. /**
  50900. * Sets velocityIterations of the impostor
  50901. * @param impostor impostor to set velocity iterations on
  50902. * @param velocityIterations velocityIterations value
  50903. */
  50904. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50905. /**
  50906. * Gets positionIterations of the impostor
  50907. * @param impostor impostor to get position iterations from
  50908. * @returns positionIterations value
  50909. */
  50910. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50911. /**
  50912. * Sets positionIterations of the impostor
  50913. * @param impostor impostor to set position on
  50914. * @param positionIterations positionIterations value
  50915. */
  50916. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50917. /**
  50918. * Append an anchor to a cloth object
  50919. * @param impostor is the cloth impostor to add anchor to
  50920. * @param otherImpostor is the rigid impostor to anchor to
  50921. * @param width ratio across width from 0 to 1
  50922. * @param height ratio up height from 0 to 1
  50923. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50924. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50925. */
  50926. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50927. /**
  50928. * Append an hook to a rope object
  50929. * @param impostor is the rope impostor to add hook to
  50930. * @param otherImpostor is the rigid impostor to hook to
  50931. * @param length ratio along the rope from 0 to 1
  50932. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50933. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50934. */
  50935. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50936. /**
  50937. * Sleeps the physics body and stops it from being active
  50938. * @param impostor impostor to sleep
  50939. */
  50940. sleepBody(impostor: PhysicsImpostor): void;
  50941. /**
  50942. * Activates the physics body
  50943. * @param impostor impostor to activate
  50944. */
  50945. wakeUpBody(impostor: PhysicsImpostor): void;
  50946. /**
  50947. * Updates the distance parameters of the joint
  50948. * @param joint joint to update
  50949. * @param maxDistance maximum distance of the joint
  50950. * @param minDistance minimum distance of the joint
  50951. */
  50952. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50953. /**
  50954. * Sets a motor on the joint
  50955. * @param joint joint to set motor on
  50956. * @param speed speed of the motor
  50957. * @param maxForce maximum force of the motor
  50958. * @param motorIndex index of the motor
  50959. */
  50960. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50961. /**
  50962. * Sets the motors limit
  50963. * @param joint joint to set limit on
  50964. * @param upperLimit upper limit
  50965. * @param lowerLimit lower limit
  50966. */
  50967. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50968. /**
  50969. * Syncs the position and rotation of a mesh with the impostor
  50970. * @param mesh mesh to sync
  50971. * @param impostor impostor to update the mesh with
  50972. */
  50973. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50974. /**
  50975. * Gets the radius of the impostor
  50976. * @param impostor impostor to get radius from
  50977. * @returns the radius
  50978. */
  50979. getRadius(impostor: PhysicsImpostor): number;
  50980. /**
  50981. * Gets the box size of the impostor
  50982. * @param impostor impostor to get box size from
  50983. * @param result the resulting box size
  50984. */
  50985. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50986. /**
  50987. * Disposes of the impostor
  50988. */
  50989. dispose(): void;
  50990. /**
  50991. * Does a raycast in the physics world
  50992. * @param from when should the ray start?
  50993. * @param to when should the ray end?
  50994. * @returns PhysicsRaycastResult
  50995. */
  50996. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50997. }
  50998. }
  50999. declare module "babylonjs/Probes/reflectionProbe" {
  51000. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51001. import { Vector3 } from "babylonjs/Maths/math";
  51002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51003. import { Nullable } from "babylonjs/types";
  51004. import { Scene } from "babylonjs/scene";
  51005. module "babylonjs/abstractScene" {
  51006. interface AbstractScene {
  51007. /**
  51008. * The list of reflection probes added to the scene
  51009. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51010. */
  51011. reflectionProbes: Array<ReflectionProbe>;
  51012. /**
  51013. * Removes the given reflection probe from this scene.
  51014. * @param toRemove The reflection probe to remove
  51015. * @returns The index of the removed reflection probe
  51016. */
  51017. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51018. /**
  51019. * Adds the given reflection probe to this scene.
  51020. * @param newReflectionProbe The reflection probe to add
  51021. */
  51022. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51023. }
  51024. }
  51025. /**
  51026. * Class used to generate realtime reflection / refraction cube textures
  51027. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51028. */
  51029. export class ReflectionProbe {
  51030. /** defines the name of the probe */
  51031. name: string;
  51032. private _scene;
  51033. private _renderTargetTexture;
  51034. private _projectionMatrix;
  51035. private _viewMatrix;
  51036. private _target;
  51037. private _add;
  51038. private _attachedMesh;
  51039. private _invertYAxis;
  51040. /** Gets or sets probe position (center of the cube map) */
  51041. position: Vector3;
  51042. /**
  51043. * Creates a new reflection probe
  51044. * @param name defines the name of the probe
  51045. * @param size defines the texture resolution (for each face)
  51046. * @param scene defines the hosting scene
  51047. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51048. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51049. */
  51050. constructor(
  51051. /** defines the name of the probe */
  51052. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51053. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51054. samples: number;
  51055. /** Gets or sets the refresh rate to use (on every frame by default) */
  51056. refreshRate: number;
  51057. /**
  51058. * Gets the hosting scene
  51059. * @returns a Scene
  51060. */
  51061. getScene(): Scene;
  51062. /** Gets the internal CubeTexture used to render to */
  51063. readonly cubeTexture: RenderTargetTexture;
  51064. /** Gets the list of meshes to render */
  51065. readonly renderList: Nullable<AbstractMesh[]>;
  51066. /**
  51067. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51068. * @param mesh defines the mesh to attach to
  51069. */
  51070. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51071. /**
  51072. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51073. * @param renderingGroupId The rendering group id corresponding to its index
  51074. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51075. */
  51076. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51077. /**
  51078. * Clean all associated resources
  51079. */
  51080. dispose(): void;
  51081. /**
  51082. * Converts the reflection probe information to a readable string for debug purpose.
  51083. * @param fullDetails Supports for multiple levels of logging within scene loading
  51084. * @returns the human readable reflection probe info
  51085. */
  51086. toString(fullDetails?: boolean): string;
  51087. /**
  51088. * Get the class name of the relfection probe.
  51089. * @returns "ReflectionProbe"
  51090. */
  51091. getClassName(): string;
  51092. /**
  51093. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51094. * @returns The JSON representation of the texture
  51095. */
  51096. serialize(): any;
  51097. /**
  51098. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51099. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51100. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51101. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51102. * @returns The parsed reflection probe if successful
  51103. */
  51104. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51105. }
  51106. }
  51107. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51108. /** @hidden */
  51109. export var _BabylonLoaderRegistered: boolean;
  51110. }
  51111. declare module "babylonjs/Loading/Plugins/index" {
  51112. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51113. }
  51114. declare module "babylonjs/Loading/index" {
  51115. export * from "babylonjs/Loading/loadingScreen";
  51116. export * from "babylonjs/Loading/Plugins/index";
  51117. export * from "babylonjs/Loading/sceneLoader";
  51118. export * from "babylonjs/Loading/sceneLoaderFlags";
  51119. }
  51120. declare module "babylonjs/Materials/Background/index" {
  51121. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51122. }
  51123. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51124. import { Scene } from "babylonjs/scene";
  51125. import { Color3 } from "babylonjs/Maths/math";
  51126. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51128. /**
  51129. * The Physically based simple base material of BJS.
  51130. *
  51131. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51132. * It is used as the base class for both the specGloss and metalRough conventions.
  51133. */
  51134. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51135. /**
  51136. * Number of Simultaneous lights allowed on the material.
  51137. */
  51138. maxSimultaneousLights: number;
  51139. /**
  51140. * If sets to true, disables all the lights affecting the material.
  51141. */
  51142. disableLighting: boolean;
  51143. /**
  51144. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51145. */
  51146. environmentTexture: BaseTexture;
  51147. /**
  51148. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51149. */
  51150. invertNormalMapX: boolean;
  51151. /**
  51152. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51153. */
  51154. invertNormalMapY: boolean;
  51155. /**
  51156. * Normal map used in the model.
  51157. */
  51158. normalTexture: BaseTexture;
  51159. /**
  51160. * Emissivie color used to self-illuminate the model.
  51161. */
  51162. emissiveColor: Color3;
  51163. /**
  51164. * Emissivie texture used to self-illuminate the model.
  51165. */
  51166. emissiveTexture: BaseTexture;
  51167. /**
  51168. * Occlusion Channel Strenght.
  51169. */
  51170. occlusionStrength: number;
  51171. /**
  51172. * Occlusion Texture of the material (adding extra occlusion effects).
  51173. */
  51174. occlusionTexture: BaseTexture;
  51175. /**
  51176. * Defines the alpha limits in alpha test mode.
  51177. */
  51178. alphaCutOff: number;
  51179. /**
  51180. * Gets the current double sided mode.
  51181. */
  51182. /**
  51183. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51184. */
  51185. doubleSided: boolean;
  51186. /**
  51187. * Stores the pre-calculated light information of a mesh in a texture.
  51188. */
  51189. lightmapTexture: BaseTexture;
  51190. /**
  51191. * If true, the light map contains occlusion information instead of lighting info.
  51192. */
  51193. useLightmapAsShadowmap: boolean;
  51194. /**
  51195. * Instantiates a new PBRMaterial instance.
  51196. *
  51197. * @param name The material name
  51198. * @param scene The scene the material will be use in.
  51199. */
  51200. constructor(name: string, scene: Scene);
  51201. getClassName(): string;
  51202. }
  51203. }
  51204. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51205. import { Scene } from "babylonjs/scene";
  51206. import { Color3 } from "babylonjs/Maths/math";
  51207. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51208. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51209. /**
  51210. * The PBR material of BJS following the metal roughness convention.
  51211. *
  51212. * This fits to the PBR convention in the GLTF definition:
  51213. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51214. */
  51215. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51216. /**
  51217. * The base color has two different interpretations depending on the value of metalness.
  51218. * When the material is a metal, the base color is the specific measured reflectance value
  51219. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51220. * of the material.
  51221. */
  51222. baseColor: Color3;
  51223. /**
  51224. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51225. * well as opacity information in the alpha channel.
  51226. */
  51227. baseTexture: BaseTexture;
  51228. /**
  51229. * Specifies the metallic scalar value of the material.
  51230. * Can also be used to scale the metalness values of the metallic texture.
  51231. */
  51232. metallic: number;
  51233. /**
  51234. * Specifies the roughness scalar value of the material.
  51235. * Can also be used to scale the roughness values of the metallic texture.
  51236. */
  51237. roughness: number;
  51238. /**
  51239. * Texture containing both the metallic value in the B channel and the
  51240. * roughness value in the G channel to keep better precision.
  51241. */
  51242. metallicRoughnessTexture: BaseTexture;
  51243. /**
  51244. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51245. *
  51246. * @param name The material name
  51247. * @param scene The scene the material will be use in.
  51248. */
  51249. constructor(name: string, scene: Scene);
  51250. /**
  51251. * Return the currrent class name of the material.
  51252. */
  51253. getClassName(): string;
  51254. /**
  51255. * Makes a duplicate of the current material.
  51256. * @param name - name to use for the new material.
  51257. */
  51258. clone(name: string): PBRMetallicRoughnessMaterial;
  51259. /**
  51260. * Serialize the material to a parsable JSON object.
  51261. */
  51262. serialize(): any;
  51263. /**
  51264. * Parses a JSON object correponding to the serialize function.
  51265. */
  51266. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51267. }
  51268. }
  51269. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51270. import { Scene } from "babylonjs/scene";
  51271. import { Color3 } from "babylonjs/Maths/math";
  51272. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51273. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51274. /**
  51275. * The PBR material of BJS following the specular glossiness convention.
  51276. *
  51277. * This fits to the PBR convention in the GLTF definition:
  51278. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51279. */
  51280. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51281. /**
  51282. * Specifies the diffuse color of the material.
  51283. */
  51284. diffuseColor: Color3;
  51285. /**
  51286. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51287. * channel.
  51288. */
  51289. diffuseTexture: BaseTexture;
  51290. /**
  51291. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51292. */
  51293. specularColor: Color3;
  51294. /**
  51295. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51296. */
  51297. glossiness: number;
  51298. /**
  51299. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51300. */
  51301. specularGlossinessTexture: BaseTexture;
  51302. /**
  51303. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51304. *
  51305. * @param name The material name
  51306. * @param scene The scene the material will be use in.
  51307. */
  51308. constructor(name: string, scene: Scene);
  51309. /**
  51310. * Return the currrent class name of the material.
  51311. */
  51312. getClassName(): string;
  51313. /**
  51314. * Makes a duplicate of the current material.
  51315. * @param name - name to use for the new material.
  51316. */
  51317. clone(name: string): PBRSpecularGlossinessMaterial;
  51318. /**
  51319. * Serialize the material to a parsable JSON object.
  51320. */
  51321. serialize(): any;
  51322. /**
  51323. * Parses a JSON object correponding to the serialize function.
  51324. */
  51325. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51326. }
  51327. }
  51328. declare module "babylonjs/Materials/PBR/index" {
  51329. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51330. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51331. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51332. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51333. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51334. }
  51335. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51336. import { Nullable } from "babylonjs/types";
  51337. import { Scene } from "babylonjs/scene";
  51338. import { Matrix } from "babylonjs/Maths/math";
  51339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51340. /**
  51341. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51342. * It can help converting any input color in a desired output one. This can then be used to create effects
  51343. * from sepia, black and white to sixties or futuristic rendering...
  51344. *
  51345. * The only supported format is currently 3dl.
  51346. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51347. */
  51348. export class ColorGradingTexture extends BaseTexture {
  51349. /**
  51350. * The current texture matrix. (will always be identity in color grading texture)
  51351. */
  51352. private _textureMatrix;
  51353. /**
  51354. * The texture URL.
  51355. */
  51356. url: string;
  51357. /**
  51358. * Empty line regex stored for GC.
  51359. */
  51360. private static _noneEmptyLineRegex;
  51361. private _engine;
  51362. /**
  51363. * Instantiates a ColorGradingTexture from the following parameters.
  51364. *
  51365. * @param url The location of the color gradind data (currently only supporting 3dl)
  51366. * @param scene The scene the texture will be used in
  51367. */
  51368. constructor(url: string, scene: Scene);
  51369. /**
  51370. * Returns the texture matrix used in most of the material.
  51371. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51372. */
  51373. getTextureMatrix(): Matrix;
  51374. /**
  51375. * Occurs when the file being loaded is a .3dl LUT file.
  51376. */
  51377. private load3dlTexture;
  51378. /**
  51379. * Starts the loading process of the texture.
  51380. */
  51381. private loadTexture;
  51382. /**
  51383. * Clones the color gradind texture.
  51384. */
  51385. clone(): ColorGradingTexture;
  51386. /**
  51387. * Called during delayed load for textures.
  51388. */
  51389. delayLoad(): void;
  51390. /**
  51391. * Parses a color grading texture serialized by Babylon.
  51392. * @param parsedTexture The texture information being parsedTexture
  51393. * @param scene The scene to load the texture in
  51394. * @param rootUrl The root url of the data assets to load
  51395. * @return A color gradind texture
  51396. */
  51397. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51398. /**
  51399. * Serializes the LUT texture to json format.
  51400. */
  51401. serialize(): any;
  51402. }
  51403. }
  51404. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51405. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51406. import { Scene } from "babylonjs/scene";
  51407. import { Nullable } from "babylonjs/types";
  51408. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51409. /**
  51410. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51411. */
  51412. export class EquiRectangularCubeTexture extends BaseTexture {
  51413. /** The six faces of the cube. */
  51414. private static _FacesMapping;
  51415. private _noMipmap;
  51416. private _onLoad;
  51417. private _onError;
  51418. /** The size of the cubemap. */
  51419. private _size;
  51420. /** The buffer of the image. */
  51421. private _buffer;
  51422. /** The width of the input image. */
  51423. private _width;
  51424. /** The height of the input image. */
  51425. private _height;
  51426. /** The URL to the image. */
  51427. url: string;
  51428. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51429. coordinatesMode: number;
  51430. /**
  51431. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51432. * @param url The location of the image
  51433. * @param scene The scene the texture will be used in
  51434. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51435. * @param noMipmap Forces to not generate the mipmap if true
  51436. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51437. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51438. * @param onLoad — defines a callback called when texture is loaded
  51439. * @param onError — defines a callback called if there is an error
  51440. */
  51441. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51442. /**
  51443. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51444. */
  51445. private loadImage;
  51446. /**
  51447. * Convert the image buffer into a cubemap and create a CubeTexture.
  51448. */
  51449. private loadTexture;
  51450. /**
  51451. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51452. * @param buffer The ArrayBuffer that should be converted.
  51453. * @returns The buffer as Float32Array.
  51454. */
  51455. private getFloat32ArrayFromArrayBuffer;
  51456. /**
  51457. * Get the current class name of the texture useful for serialization or dynamic coding.
  51458. * @returns "EquiRectangularCubeTexture"
  51459. */
  51460. getClassName(): string;
  51461. /**
  51462. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51463. * @returns A clone of the current EquiRectangularCubeTexture.
  51464. */
  51465. clone(): EquiRectangularCubeTexture;
  51466. }
  51467. }
  51468. declare module "babylonjs/Misc/tga" {
  51469. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51470. /**
  51471. * Based on jsTGALoader - Javascript loader for TGA file
  51472. * By Vincent Thibault
  51473. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51474. */
  51475. export class TGATools {
  51476. private static _TYPE_INDEXED;
  51477. private static _TYPE_RGB;
  51478. private static _TYPE_GREY;
  51479. private static _TYPE_RLE_INDEXED;
  51480. private static _TYPE_RLE_RGB;
  51481. private static _TYPE_RLE_GREY;
  51482. private static _ORIGIN_MASK;
  51483. private static _ORIGIN_SHIFT;
  51484. private static _ORIGIN_BL;
  51485. private static _ORIGIN_BR;
  51486. private static _ORIGIN_UL;
  51487. private static _ORIGIN_UR;
  51488. /**
  51489. * Gets the header of a TGA file
  51490. * @param data defines the TGA data
  51491. * @returns the header
  51492. */
  51493. static GetTGAHeader(data: Uint8Array): any;
  51494. /**
  51495. * Uploads TGA content to a Babylon Texture
  51496. * @hidden
  51497. */
  51498. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51499. /** @hidden */
  51500. 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;
  51501. /** @hidden */
  51502. 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;
  51503. /** @hidden */
  51504. 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;
  51505. /** @hidden */
  51506. 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;
  51507. /** @hidden */
  51508. 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;
  51509. /** @hidden */
  51510. 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;
  51511. }
  51512. }
  51513. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51514. import { Nullable } from "babylonjs/types";
  51515. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51516. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51517. /**
  51518. * Implementation of the TGA Texture Loader.
  51519. * @hidden
  51520. */
  51521. export class _TGATextureLoader implements IInternalTextureLoader {
  51522. /**
  51523. * Defines wether the loader supports cascade loading the different faces.
  51524. */
  51525. readonly supportCascades: boolean;
  51526. /**
  51527. * This returns if the loader support the current file information.
  51528. * @param extension defines the file extension of the file being loaded
  51529. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51530. * @param fallback defines the fallback internal texture if any
  51531. * @param isBase64 defines whether the texture is encoded as a base64
  51532. * @param isBuffer defines whether the texture data are stored as a buffer
  51533. * @returns true if the loader can load the specified file
  51534. */
  51535. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51536. /**
  51537. * Transform the url before loading if required.
  51538. * @param rootUrl the url of the texture
  51539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51540. * @returns the transformed texture
  51541. */
  51542. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51543. /**
  51544. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51545. * @param rootUrl the url of the texture
  51546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51547. * @returns the fallback texture
  51548. */
  51549. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51550. /**
  51551. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51552. * @param data contains the texture data
  51553. * @param texture defines the BabylonJS internal texture
  51554. * @param createPolynomials will be true if polynomials have been requested
  51555. * @param onLoad defines the callback to trigger once the texture is ready
  51556. * @param onError defines the callback to trigger in case of error
  51557. */
  51558. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51559. /**
  51560. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51561. * @param data contains the texture data
  51562. * @param texture defines the BabylonJS internal texture
  51563. * @param callback defines the method to call once ready to upload
  51564. */
  51565. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51566. }
  51567. }
  51568. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51569. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51570. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51571. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51572. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51573. }
  51574. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51575. import { Scene } from "babylonjs/scene";
  51576. import { Texture } from "babylonjs/Materials/Textures/texture";
  51577. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51578. /**
  51579. * 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.
  51580. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51581. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51582. */
  51583. export class CustomProceduralTexture extends ProceduralTexture {
  51584. private _animate;
  51585. private _time;
  51586. private _config;
  51587. private _texturePath;
  51588. /**
  51589. * Instantiates a new Custom Procedural Texture.
  51590. * 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.
  51591. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51592. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51593. * @param name Define the name of the texture
  51594. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51595. * @param size Define the size of the texture to create
  51596. * @param scene Define the scene the texture belongs to
  51597. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51598. * @param generateMipMaps Define if the texture should creates mip maps or not
  51599. */
  51600. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51601. private _loadJson;
  51602. /**
  51603. * Is the texture ready to be used ? (rendered at least once)
  51604. * @returns true if ready, otherwise, false.
  51605. */
  51606. isReady(): boolean;
  51607. /**
  51608. * Render the texture to its associated render target.
  51609. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51610. */
  51611. render(useCameraPostProcess?: boolean): void;
  51612. /**
  51613. * Update the list of dependant textures samplers in the shader.
  51614. */
  51615. updateTextures(): void;
  51616. /**
  51617. * Update the uniform values of the procedural texture in the shader.
  51618. */
  51619. updateShaderUniforms(): void;
  51620. /**
  51621. * Define if the texture animates or not.
  51622. */
  51623. animate: boolean;
  51624. }
  51625. }
  51626. declare module "babylonjs/Shaders/noise.fragment" {
  51627. /** @hidden */
  51628. export var noisePixelShader: {
  51629. name: string;
  51630. shader: string;
  51631. };
  51632. }
  51633. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51634. import { Nullable } from "babylonjs/types";
  51635. import { Scene } from "babylonjs/scene";
  51636. import { Texture } from "babylonjs/Materials/Textures/texture";
  51637. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51638. import "babylonjs/Shaders/noise.fragment";
  51639. /**
  51640. * Class used to generate noise procedural textures
  51641. */
  51642. export class NoiseProceduralTexture extends ProceduralTexture {
  51643. private _time;
  51644. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51645. brightness: number;
  51646. /** Defines the number of octaves to process */
  51647. octaves: number;
  51648. /** Defines the level of persistence (0.8 by default) */
  51649. persistence: number;
  51650. /** Gets or sets animation speed factor (default is 1) */
  51651. animationSpeedFactor: number;
  51652. /**
  51653. * Creates a new NoiseProceduralTexture
  51654. * @param name defines the name fo the texture
  51655. * @param size defines the size of the texture (default is 256)
  51656. * @param scene defines the hosting scene
  51657. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51658. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51659. */
  51660. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51661. private _updateShaderUniforms;
  51662. protected _getDefines(): string;
  51663. /** Generate the current state of the procedural texture */
  51664. render(useCameraPostProcess?: boolean): void;
  51665. /**
  51666. * Serializes this noise procedural texture
  51667. * @returns a serialized noise procedural texture object
  51668. */
  51669. serialize(): any;
  51670. /**
  51671. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51672. * @param parsedTexture defines parsed texture data
  51673. * @param scene defines the current scene
  51674. * @param rootUrl defines the root URL containing noise procedural texture information
  51675. * @returns a parsed NoiseProceduralTexture
  51676. */
  51677. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51678. }
  51679. }
  51680. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51681. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51682. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51683. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51684. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51685. }
  51686. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51687. import { Nullable } from "babylonjs/types";
  51688. import { Scene } from "babylonjs/scene";
  51689. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51691. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51692. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51693. /**
  51694. * Raw cube texture where the raw buffers are passed in
  51695. */
  51696. export class RawCubeTexture extends CubeTexture {
  51697. /**
  51698. * Creates a cube texture where the raw buffers are passed in.
  51699. * @param scene defines the scene the texture is attached to
  51700. * @param data defines the array of data to use to create each face
  51701. * @param size defines the size of the textures
  51702. * @param format defines the format of the data
  51703. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51704. * @param generateMipMaps defines if the engine should generate the mip levels
  51705. * @param invertY defines if data must be stored with Y axis inverted
  51706. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51707. * @param compression defines the compression used (null by default)
  51708. */
  51709. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51710. /**
  51711. * Updates the raw cube texture.
  51712. * @param data defines the data to store
  51713. * @param format defines the data format
  51714. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51715. * @param invertY defines if data must be stored with Y axis inverted
  51716. * @param compression defines the compression used (null by default)
  51717. * @param level defines which level of the texture to update
  51718. */
  51719. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51720. /**
  51721. * Updates a raw cube texture with RGBD encoded data.
  51722. * @param data defines the array of data [mipmap][face] to use to create each face
  51723. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51724. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51725. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51726. * @returns a promsie that resolves when the operation is complete
  51727. */
  51728. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51729. /**
  51730. * Clones the raw cube texture.
  51731. * @return a new cube texture
  51732. */
  51733. clone(): CubeTexture;
  51734. /** @hidden */
  51735. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51736. }
  51737. }
  51738. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51739. import { Scene } from "babylonjs/scene";
  51740. import { Texture } from "babylonjs/Materials/Textures/texture";
  51741. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51742. /**
  51743. * Class used to store 3D textures containing user data
  51744. */
  51745. export class RawTexture3D extends Texture {
  51746. /** Gets or sets the texture format to use */
  51747. format: number;
  51748. private _engine;
  51749. /**
  51750. * Create a new RawTexture3D
  51751. * @param data defines the data of the texture
  51752. * @param width defines the width of the texture
  51753. * @param height defines the height of the texture
  51754. * @param depth defines the depth of the texture
  51755. * @param format defines the texture format to use
  51756. * @param scene defines the hosting scene
  51757. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51758. * @param invertY defines if texture must be stored with Y axis inverted
  51759. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51760. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51761. */
  51762. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51763. /** Gets or sets the texture format to use */
  51764. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51765. /**
  51766. * Update the texture with new data
  51767. * @param data defines the data to store in the texture
  51768. */
  51769. update(data: ArrayBufferView): void;
  51770. }
  51771. }
  51772. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51773. import { Scene } from "babylonjs/scene";
  51774. import { Plane } from "babylonjs/Maths/math";
  51775. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51776. /**
  51777. * Creates a refraction texture used by refraction channel of the standard material.
  51778. * It is like a mirror but to see through a material.
  51779. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51780. */
  51781. export class RefractionTexture extends RenderTargetTexture {
  51782. /**
  51783. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51784. * 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.
  51785. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51786. */
  51787. refractionPlane: Plane;
  51788. /**
  51789. * Define how deep under the surface we should see.
  51790. */
  51791. depth: number;
  51792. /**
  51793. * Creates a refraction texture used by refraction channel of the standard material.
  51794. * It is like a mirror but to see through a material.
  51795. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51796. * @param name Define the texture name
  51797. * @param size Define the size of the underlying texture
  51798. * @param scene Define the scene the refraction belongs to
  51799. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51800. */
  51801. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51802. /**
  51803. * Clone the refraction texture.
  51804. * @returns the cloned texture
  51805. */
  51806. clone(): RefractionTexture;
  51807. /**
  51808. * Serialize the texture to a JSON representation you could use in Parse later on
  51809. * @returns the serialized JSON representation
  51810. */
  51811. serialize(): any;
  51812. }
  51813. }
  51814. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51815. import { Nullable } from "babylonjs/types";
  51816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51817. import { Matrix } from "babylonjs/Maths/math";
  51818. import { Engine } from "babylonjs/Engines/engine";
  51819. import { Scene } from "babylonjs/scene";
  51820. /**
  51821. * Defines the options related to the creation of an HtmlElementTexture
  51822. */
  51823. export interface IHtmlElementTextureOptions {
  51824. /**
  51825. * Defines wether mip maps should be created or not.
  51826. */
  51827. generateMipMaps?: boolean;
  51828. /**
  51829. * Defines the sampling mode of the texture.
  51830. */
  51831. samplingMode?: number;
  51832. /**
  51833. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51834. */
  51835. engine: Nullable<Engine>;
  51836. /**
  51837. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51838. */
  51839. scene: Nullable<Scene>;
  51840. }
  51841. /**
  51842. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51843. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51844. * is automatically managed.
  51845. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51846. * in your application.
  51847. *
  51848. * As the update is not automatic, you need to call them manually.
  51849. */
  51850. export class HtmlElementTexture extends BaseTexture {
  51851. /**
  51852. * The texture URL.
  51853. */
  51854. element: HTMLVideoElement | HTMLCanvasElement;
  51855. private static readonly DefaultOptions;
  51856. private _textureMatrix;
  51857. private _engine;
  51858. private _isVideo;
  51859. private _generateMipMaps;
  51860. private _samplingMode;
  51861. /**
  51862. * Instantiates a HtmlElementTexture from the following parameters.
  51863. *
  51864. * @param name Defines the name of the texture
  51865. * @param element Defines the video or canvas the texture is filled with
  51866. * @param options Defines the other none mandatory texture creation options
  51867. */
  51868. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51869. private _createInternalTexture;
  51870. /**
  51871. * Returns the texture matrix used in most of the material.
  51872. */
  51873. getTextureMatrix(): Matrix;
  51874. /**
  51875. * Updates the content of the texture.
  51876. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51877. */
  51878. update(invertY?: Nullable<boolean>): void;
  51879. }
  51880. }
  51881. declare module "babylonjs/Materials/Textures/index" {
  51882. export * from "babylonjs/Materials/Textures/baseTexture";
  51883. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51884. export * from "babylonjs/Materials/Textures/cubeTexture";
  51885. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51886. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51887. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51888. export * from "babylonjs/Materials/Textures/internalTexture";
  51889. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51890. export * from "babylonjs/Materials/Textures/Loaders/index";
  51891. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51892. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51893. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51894. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51895. export * from "babylonjs/Materials/Textures/rawTexture";
  51896. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51897. export * from "babylonjs/Materials/Textures/refractionTexture";
  51898. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51899. export * from "babylonjs/Materials/Textures/texture";
  51900. export * from "babylonjs/Materials/Textures/videoTexture";
  51901. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51902. }
  51903. declare module "babylonjs/Materials/index" {
  51904. export * from "babylonjs/Materials/Background/index";
  51905. export * from "babylonjs/Materials/colorCurves";
  51906. export * from "babylonjs/Materials/effect";
  51907. export * from "babylonjs/Materials/fresnelParameters";
  51908. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51909. export * from "babylonjs/Materials/material";
  51910. export * from "babylonjs/Materials/materialDefines";
  51911. export * from "babylonjs/Materials/materialHelper";
  51912. export * from "babylonjs/Materials/multiMaterial";
  51913. export * from "babylonjs/Materials/PBR/index";
  51914. export * from "babylonjs/Materials/pushMaterial";
  51915. export * from "babylonjs/Materials/shaderMaterial";
  51916. export * from "babylonjs/Materials/standardMaterial";
  51917. export * from "babylonjs/Materials/Textures/index";
  51918. export * from "babylonjs/Materials/uniformBuffer";
  51919. export * from "babylonjs/Materials/materialFlags";
  51920. }
  51921. declare module "babylonjs/Maths/index" {
  51922. export * from "babylonjs/Maths/math.scalar";
  51923. export * from "babylonjs/Maths/math";
  51924. export * from "babylonjs/Maths/sphericalPolynomial";
  51925. }
  51926. declare module "babylonjs/Misc/workerPool" {
  51927. import { IDisposable } from "babylonjs/scene";
  51928. /**
  51929. * Helper class to push actions to a pool of workers.
  51930. */
  51931. export class WorkerPool implements IDisposable {
  51932. private _workerInfos;
  51933. private _pendingActions;
  51934. /**
  51935. * Constructor
  51936. * @param workers Array of workers to use for actions
  51937. */
  51938. constructor(workers: Array<Worker>);
  51939. /**
  51940. * Terminates all workers and clears any pending actions.
  51941. */
  51942. dispose(): void;
  51943. /**
  51944. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51945. * pended until a worker has completed its action.
  51946. * @param action The action to perform. Call onComplete when the action is complete.
  51947. */
  51948. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51949. private _execute;
  51950. }
  51951. }
  51952. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51953. import { IDisposable } from "babylonjs/scene";
  51954. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51955. /**
  51956. * Configuration for Draco compression
  51957. */
  51958. export interface IDracoCompressionConfiguration {
  51959. /**
  51960. * Configuration for the decoder.
  51961. */
  51962. decoder: {
  51963. /**
  51964. * The url to the WebAssembly module.
  51965. */
  51966. wasmUrl?: string;
  51967. /**
  51968. * The url to the WebAssembly binary.
  51969. */
  51970. wasmBinaryUrl?: string;
  51971. /**
  51972. * The url to the fallback JavaScript module.
  51973. */
  51974. fallbackUrl?: string;
  51975. };
  51976. }
  51977. /**
  51978. * Draco compression (https://google.github.io/draco/)
  51979. *
  51980. * This class wraps the Draco module.
  51981. *
  51982. * **Encoder**
  51983. *
  51984. * The encoder is not currently implemented.
  51985. *
  51986. * **Decoder**
  51987. *
  51988. * 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.
  51989. *
  51990. * To update the configuration, use the following code:
  51991. * ```javascript
  51992. * DracoCompression.Configuration = {
  51993. * decoder: {
  51994. * wasmUrl: "<url to the WebAssembly library>",
  51995. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51996. * fallbackUrl: "<url to the fallback JavaScript library>",
  51997. * }
  51998. * };
  51999. * ```
  52000. *
  52001. * 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.
  52002. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52003. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52004. *
  52005. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52006. * ```javascript
  52007. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52008. * ```
  52009. *
  52010. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52011. */
  52012. export class DracoCompression implements IDisposable {
  52013. private _workerPoolPromise?;
  52014. private _decoderModulePromise?;
  52015. /**
  52016. * The configuration. Defaults to the following urls:
  52017. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52018. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52019. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52020. */
  52021. static Configuration: IDracoCompressionConfiguration;
  52022. /**
  52023. * Returns true if the decoder configuration is available.
  52024. */
  52025. static readonly DecoderAvailable: boolean;
  52026. /**
  52027. * Default number of workers to create when creating the draco compression object.
  52028. */
  52029. static DefaultNumWorkers: number;
  52030. private static GetDefaultNumWorkers;
  52031. private static _Default;
  52032. /**
  52033. * Default instance for the draco compression object.
  52034. */
  52035. static readonly Default: DracoCompression;
  52036. /**
  52037. * Constructor
  52038. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52039. */
  52040. constructor(numWorkers?: number);
  52041. /**
  52042. * Stop all async operations and release resources.
  52043. */
  52044. dispose(): void;
  52045. /**
  52046. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52047. * @returns a promise that resolves when ready
  52048. */
  52049. whenReadyAsync(): Promise<void>;
  52050. /**
  52051. * Decode Draco compressed mesh data to vertex data.
  52052. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52053. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52054. * @returns A promise that resolves with the decoded vertex data
  52055. */
  52056. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52057. [kind: string]: number;
  52058. }): Promise<VertexData>;
  52059. }
  52060. }
  52061. declare module "babylonjs/Meshes/Compression/index" {
  52062. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52063. }
  52064. declare module "babylonjs/Meshes/csg" {
  52065. import { Nullable } from "babylonjs/types";
  52066. import { Scene } from "babylonjs/scene";
  52067. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52068. import { Mesh } from "babylonjs/Meshes/mesh";
  52069. import { Material } from "babylonjs/Materials/material";
  52070. /**
  52071. * Class for building Constructive Solid Geometry
  52072. */
  52073. export class CSG {
  52074. private polygons;
  52075. /**
  52076. * The world matrix
  52077. */
  52078. matrix: Matrix;
  52079. /**
  52080. * Stores the position
  52081. */
  52082. position: Vector3;
  52083. /**
  52084. * Stores the rotation
  52085. */
  52086. rotation: Vector3;
  52087. /**
  52088. * Stores the rotation quaternion
  52089. */
  52090. rotationQuaternion: Nullable<Quaternion>;
  52091. /**
  52092. * Stores the scaling vector
  52093. */
  52094. scaling: Vector3;
  52095. /**
  52096. * Convert the Mesh to CSG
  52097. * @param mesh The Mesh to convert to CSG
  52098. * @returns A new CSG from the Mesh
  52099. */
  52100. static FromMesh(mesh: Mesh): CSG;
  52101. /**
  52102. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52103. * @param polygons Polygons used to construct a CSG solid
  52104. */
  52105. private static FromPolygons;
  52106. /**
  52107. * Clones, or makes a deep copy, of the CSG
  52108. * @returns A new CSG
  52109. */
  52110. clone(): CSG;
  52111. /**
  52112. * Unions this CSG with another CSG
  52113. * @param csg The CSG to union against this CSG
  52114. * @returns The unioned CSG
  52115. */
  52116. union(csg: CSG): CSG;
  52117. /**
  52118. * Unions this CSG with another CSG in place
  52119. * @param csg The CSG to union against this CSG
  52120. */
  52121. unionInPlace(csg: CSG): void;
  52122. /**
  52123. * Subtracts this CSG with another CSG
  52124. * @param csg The CSG to subtract against this CSG
  52125. * @returns A new CSG
  52126. */
  52127. subtract(csg: CSG): CSG;
  52128. /**
  52129. * Subtracts this CSG with another CSG in place
  52130. * @param csg The CSG to subtact against this CSG
  52131. */
  52132. subtractInPlace(csg: CSG): void;
  52133. /**
  52134. * Intersect this CSG with another CSG
  52135. * @param csg The CSG to intersect against this CSG
  52136. * @returns A new CSG
  52137. */
  52138. intersect(csg: CSG): CSG;
  52139. /**
  52140. * Intersects this CSG with another CSG in place
  52141. * @param csg The CSG to intersect against this CSG
  52142. */
  52143. intersectInPlace(csg: CSG): void;
  52144. /**
  52145. * Return a new CSG solid with solid and empty space switched. This solid is
  52146. * not modified.
  52147. * @returns A new CSG solid with solid and empty space switched
  52148. */
  52149. inverse(): CSG;
  52150. /**
  52151. * Inverses the CSG in place
  52152. */
  52153. inverseInPlace(): void;
  52154. /**
  52155. * This is used to keep meshes transformations so they can be restored
  52156. * when we build back a Babylon Mesh
  52157. * NB : All CSG operations are performed in world coordinates
  52158. * @param csg The CSG to copy the transform attributes from
  52159. * @returns This CSG
  52160. */
  52161. copyTransformAttributes(csg: CSG): CSG;
  52162. /**
  52163. * Build Raw mesh from CSG
  52164. * Coordinates here are in world space
  52165. * @param name The name of the mesh geometry
  52166. * @param scene The Scene
  52167. * @param keepSubMeshes Specifies if the submeshes should be kept
  52168. * @returns A new Mesh
  52169. */
  52170. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52171. /**
  52172. * Build Mesh from CSG taking material and transforms into account
  52173. * @param name The name of the Mesh
  52174. * @param material The material of the Mesh
  52175. * @param scene The Scene
  52176. * @param keepSubMeshes Specifies if submeshes should be kept
  52177. * @returns The new Mesh
  52178. */
  52179. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52180. }
  52181. }
  52182. declare module "babylonjs/Meshes/trailMesh" {
  52183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52184. import { Mesh } from "babylonjs/Meshes/mesh";
  52185. import { Scene } from "babylonjs/scene";
  52186. /**
  52187. * Class used to create a trail following a mesh
  52188. */
  52189. export class TrailMesh extends Mesh {
  52190. private _generator;
  52191. private _autoStart;
  52192. private _running;
  52193. private _diameter;
  52194. private _length;
  52195. private _sectionPolygonPointsCount;
  52196. private _sectionVectors;
  52197. private _sectionNormalVectors;
  52198. private _beforeRenderObserver;
  52199. /**
  52200. * @constructor
  52201. * @param name The value used by scene.getMeshByName() to do a lookup.
  52202. * @param generator The mesh to generate a trail.
  52203. * @param scene The scene to add this mesh to.
  52204. * @param diameter Diameter of trailing mesh. Default is 1.
  52205. * @param length Length of trailing mesh. Default is 60.
  52206. * @param autoStart Automatically start trailing mesh. Default true.
  52207. */
  52208. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52209. /**
  52210. * "TrailMesh"
  52211. * @returns "TrailMesh"
  52212. */
  52213. getClassName(): string;
  52214. private _createMesh;
  52215. /**
  52216. * Start trailing mesh.
  52217. */
  52218. start(): void;
  52219. /**
  52220. * Stop trailing mesh.
  52221. */
  52222. stop(): void;
  52223. /**
  52224. * Update trailing mesh geometry.
  52225. */
  52226. update(): void;
  52227. /**
  52228. * Returns a new TrailMesh object.
  52229. * @param name is a string, the name given to the new mesh
  52230. * @param newGenerator use new generator object for cloned trail mesh
  52231. * @returns a new mesh
  52232. */
  52233. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52234. /**
  52235. * Serializes this trail mesh
  52236. * @param serializationObject object to write serialization to
  52237. */
  52238. serialize(serializationObject: any): void;
  52239. /**
  52240. * Parses a serialized trail mesh
  52241. * @param parsedMesh the serialized mesh
  52242. * @param scene the scene to create the trail mesh in
  52243. * @returns the created trail mesh
  52244. */
  52245. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52246. }
  52247. }
  52248. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52249. import { Vector4 } from "babylonjs/Maths/math";
  52250. import { Mesh } from "babylonjs/Meshes/mesh";
  52251. /**
  52252. * Class containing static functions to help procedurally build meshes
  52253. */
  52254. export class TorusKnotBuilder {
  52255. /**
  52256. * Creates a torus knot mesh
  52257. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52258. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52259. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52260. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52264. * @param name defines the name of the mesh
  52265. * @param options defines the options used to create the mesh
  52266. * @param scene defines the hosting scene
  52267. * @returns the torus knot mesh
  52268. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52269. */
  52270. static CreateTorusKnot(name: string, options: {
  52271. radius?: number;
  52272. tube?: number;
  52273. radialSegments?: number;
  52274. tubularSegments?: number;
  52275. p?: number;
  52276. q?: number;
  52277. updatable?: boolean;
  52278. sideOrientation?: number;
  52279. frontUVs?: Vector4;
  52280. backUVs?: Vector4;
  52281. }, scene: any): Mesh;
  52282. }
  52283. }
  52284. declare module "babylonjs/Meshes/polygonMesh" {
  52285. import { Scene } from "babylonjs/scene";
  52286. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52287. import { Mesh } from "babylonjs/Meshes/mesh";
  52288. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52289. /**
  52290. * Polygon
  52291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52292. */
  52293. export class Polygon {
  52294. /**
  52295. * Creates a rectangle
  52296. * @param xmin bottom X coord
  52297. * @param ymin bottom Y coord
  52298. * @param xmax top X coord
  52299. * @param ymax top Y coord
  52300. * @returns points that make the resulting rectation
  52301. */
  52302. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52303. /**
  52304. * Creates a circle
  52305. * @param radius radius of circle
  52306. * @param cx scale in x
  52307. * @param cy scale in y
  52308. * @param numberOfSides number of sides that make up the circle
  52309. * @returns points that make the resulting circle
  52310. */
  52311. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52312. /**
  52313. * Creates a polygon from input string
  52314. * @param input Input polygon data
  52315. * @returns the parsed points
  52316. */
  52317. static Parse(input: string): Vector2[];
  52318. /**
  52319. * Starts building a polygon from x and y coordinates
  52320. * @param x x coordinate
  52321. * @param y y coordinate
  52322. * @returns the started path2
  52323. */
  52324. static StartingAt(x: number, y: number): Path2;
  52325. }
  52326. /**
  52327. * Builds a polygon
  52328. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52329. */
  52330. export class PolygonMeshBuilder {
  52331. private _points;
  52332. private _outlinepoints;
  52333. private _holes;
  52334. private _name;
  52335. private _scene;
  52336. private _epoints;
  52337. private _eholes;
  52338. private _addToepoint;
  52339. /**
  52340. * Babylon reference to the earcut plugin.
  52341. */
  52342. bjsEarcut: any;
  52343. /**
  52344. * Creates a PolygonMeshBuilder
  52345. * @param name name of the builder
  52346. * @param contours Path of the polygon
  52347. * @param scene scene to add to when creating the mesh
  52348. * @param earcutInjection can be used to inject your own earcut reference
  52349. */
  52350. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52351. /**
  52352. * Adds a whole within the polygon
  52353. * @param hole Array of points defining the hole
  52354. * @returns this
  52355. */
  52356. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52357. /**
  52358. * Creates the polygon
  52359. * @param updatable If the mesh should be updatable
  52360. * @param depth The depth of the mesh created
  52361. * @returns the created mesh
  52362. */
  52363. build(updatable?: boolean, depth?: number): Mesh;
  52364. /**
  52365. * Creates the polygon
  52366. * @param depth The depth of the mesh created
  52367. * @returns the created VertexData
  52368. */
  52369. buildVertexData(depth?: number): VertexData;
  52370. /**
  52371. * Adds a side to the polygon
  52372. * @param positions points that make the polygon
  52373. * @param normals normals of the polygon
  52374. * @param uvs uvs of the polygon
  52375. * @param indices indices of the polygon
  52376. * @param bounds bounds of the polygon
  52377. * @param points points of the polygon
  52378. * @param depth depth of the polygon
  52379. * @param flip flip of the polygon
  52380. */
  52381. private addSide;
  52382. }
  52383. }
  52384. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52385. import { Scene } from "babylonjs/scene";
  52386. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52387. import { Mesh } from "babylonjs/Meshes/mesh";
  52388. import { Nullable } from "babylonjs/types";
  52389. /**
  52390. * Class containing static functions to help procedurally build meshes
  52391. */
  52392. export class PolygonBuilder {
  52393. /**
  52394. * Creates a polygon mesh
  52395. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52396. * * 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
  52397. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52400. * * Remember you can only change the shape positions, not their number when updating a polygon
  52401. * @param name defines the name of the mesh
  52402. * @param options defines the options used to create the mesh
  52403. * @param scene defines the hosting scene
  52404. * @param earcutInjection can be used to inject your own earcut reference
  52405. * @returns the polygon mesh
  52406. */
  52407. static CreatePolygon(name: string, options: {
  52408. shape: Vector3[];
  52409. holes?: Vector3[][];
  52410. depth?: number;
  52411. faceUV?: Vector4[];
  52412. faceColors?: Color4[];
  52413. updatable?: boolean;
  52414. sideOrientation?: number;
  52415. frontUVs?: Vector4;
  52416. backUVs?: Vector4;
  52417. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52418. /**
  52419. * Creates an extruded polygon mesh, with depth in the Y direction.
  52420. * * 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)
  52421. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52422. * @param name defines the name of the mesh
  52423. * @param options defines the options used to create the mesh
  52424. * @param scene defines the hosting scene
  52425. * @param earcutInjection can be used to inject your own earcut reference
  52426. * @returns the polygon mesh
  52427. */
  52428. static ExtrudePolygon(name: string, options: {
  52429. shape: Vector3[];
  52430. holes?: Vector3[][];
  52431. depth?: number;
  52432. faceUV?: Vector4[];
  52433. faceColors?: Color4[];
  52434. updatable?: boolean;
  52435. sideOrientation?: number;
  52436. frontUVs?: Vector4;
  52437. backUVs?: Vector4;
  52438. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52439. }
  52440. }
  52441. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52442. import { Scene } from "babylonjs/scene";
  52443. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52444. import { Mesh } from "babylonjs/Meshes/mesh";
  52445. import { Nullable } from "babylonjs/types";
  52446. /**
  52447. * Class containing static functions to help procedurally build meshes
  52448. */
  52449. export class LatheBuilder {
  52450. /**
  52451. * Creates lathe mesh.
  52452. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52453. * * 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
  52454. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52455. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52456. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52457. * * 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
  52458. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52459. * * 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
  52460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52462. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52464. * @param name defines the name of the mesh
  52465. * @param options defines the options used to create the mesh
  52466. * @param scene defines the hosting scene
  52467. * @returns the lathe mesh
  52468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52469. */
  52470. static CreateLathe(name: string, options: {
  52471. shape: Vector3[];
  52472. radius?: number;
  52473. tessellation?: number;
  52474. clip?: number;
  52475. arc?: number;
  52476. closed?: boolean;
  52477. updatable?: boolean;
  52478. sideOrientation?: number;
  52479. frontUVs?: Vector4;
  52480. backUVs?: Vector4;
  52481. cap?: number;
  52482. invertUV?: boolean;
  52483. }, scene?: Nullable<Scene>): Mesh;
  52484. }
  52485. }
  52486. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52487. import { Nullable } from "babylonjs/types";
  52488. import { Scene } from "babylonjs/scene";
  52489. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52490. import { Mesh } from "babylonjs/Meshes/mesh";
  52491. /**
  52492. * Class containing static functions to help procedurally build meshes
  52493. */
  52494. export class TubeBuilder {
  52495. /**
  52496. * Creates a tube mesh.
  52497. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52498. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52499. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52500. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52501. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52502. * * 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)
  52503. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52504. * * 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
  52505. * * 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
  52506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52508. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52510. * @param name defines the name of the mesh
  52511. * @param options defines the options used to create the mesh
  52512. * @param scene defines the hosting scene
  52513. * @returns the tube mesh
  52514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52515. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52516. */
  52517. static CreateTube(name: string, options: {
  52518. path: Vector3[];
  52519. radius?: number;
  52520. tessellation?: number;
  52521. radiusFunction?: {
  52522. (i: number, distance: number): number;
  52523. };
  52524. cap?: number;
  52525. arc?: number;
  52526. updatable?: boolean;
  52527. sideOrientation?: number;
  52528. frontUVs?: Vector4;
  52529. backUVs?: Vector4;
  52530. instance?: Mesh;
  52531. invertUV?: boolean;
  52532. }, scene?: Nullable<Scene>): Mesh;
  52533. }
  52534. }
  52535. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52536. import { Scene } from "babylonjs/scene";
  52537. import { Vector4 } from "babylonjs/Maths/math";
  52538. import { Mesh } from "babylonjs/Meshes/mesh";
  52539. import { Nullable } from "babylonjs/types";
  52540. /**
  52541. * Class containing static functions to help procedurally build meshes
  52542. */
  52543. export class IcoSphereBuilder {
  52544. /**
  52545. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52546. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52547. * * 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`)
  52548. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52549. * * 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
  52550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52553. * @param name defines the name of the mesh
  52554. * @param options defines the options used to create the mesh
  52555. * @param scene defines the hosting scene
  52556. * @returns the icosahedron mesh
  52557. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52558. */
  52559. static CreateIcoSphere(name: string, options: {
  52560. radius?: number;
  52561. radiusX?: number;
  52562. radiusY?: number;
  52563. radiusZ?: number;
  52564. flat?: boolean;
  52565. subdivisions?: number;
  52566. sideOrientation?: number;
  52567. frontUVs?: Vector4;
  52568. backUVs?: Vector4;
  52569. updatable?: boolean;
  52570. }, scene?: Nullable<Scene>): Mesh;
  52571. }
  52572. }
  52573. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52574. import { Vector3 } from "babylonjs/Maths/math";
  52575. import { Mesh } from "babylonjs/Meshes/mesh";
  52576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52577. /**
  52578. * Class containing static functions to help procedurally build meshes
  52579. */
  52580. export class DecalBuilder {
  52581. /**
  52582. * Creates a decal mesh.
  52583. * 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
  52584. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52585. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52586. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52587. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52588. * @param name defines the name of the mesh
  52589. * @param sourceMesh defines the mesh where the decal must be applied
  52590. * @param options defines the options used to create the mesh
  52591. * @param scene defines the hosting scene
  52592. * @returns the decal mesh
  52593. * @see https://doc.babylonjs.com/how_to/decals
  52594. */
  52595. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52596. position?: Vector3;
  52597. normal?: Vector3;
  52598. size?: Vector3;
  52599. angle?: number;
  52600. }): Mesh;
  52601. }
  52602. }
  52603. declare module "babylonjs/Meshes/meshBuilder" {
  52604. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52605. import { Nullable } from "babylonjs/types";
  52606. import { Scene } from "babylonjs/scene";
  52607. import { Mesh } from "babylonjs/Meshes/mesh";
  52608. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52609. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52611. /**
  52612. * Class containing static functions to help procedurally build meshes
  52613. */
  52614. export class MeshBuilder {
  52615. /**
  52616. * Creates a box mesh
  52617. * * The parameter `size` sets the size (float) of each box side (default 1)
  52618. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52619. * * 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)
  52620. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52624. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52625. * @param name defines the name of the mesh
  52626. * @param options defines the options used to create the mesh
  52627. * @param scene defines the hosting scene
  52628. * @returns the box mesh
  52629. */
  52630. static CreateBox(name: string, options: {
  52631. size?: number;
  52632. width?: number;
  52633. height?: number;
  52634. depth?: number;
  52635. faceUV?: Vector4[];
  52636. faceColors?: Color4[];
  52637. sideOrientation?: number;
  52638. frontUVs?: Vector4;
  52639. backUVs?: Vector4;
  52640. updatable?: boolean;
  52641. }, scene?: Nullable<Scene>): Mesh;
  52642. /**
  52643. * Creates a sphere mesh
  52644. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52645. * * 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`)
  52646. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52647. * * 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
  52648. * * 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)
  52649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52652. * @param name defines the name of the mesh
  52653. * @param options defines the options used to create the mesh
  52654. * @param scene defines the hosting scene
  52655. * @returns the sphere mesh
  52656. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52657. */
  52658. static CreateSphere(name: string, options: {
  52659. segments?: number;
  52660. diameter?: number;
  52661. diameterX?: number;
  52662. diameterY?: number;
  52663. diameterZ?: number;
  52664. arc?: number;
  52665. slice?: number;
  52666. sideOrientation?: number;
  52667. frontUVs?: Vector4;
  52668. backUVs?: Vector4;
  52669. updatable?: boolean;
  52670. }, scene?: Nullable<Scene>): Mesh;
  52671. /**
  52672. * Creates a plane polygonal mesh. By default, this is a disc
  52673. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52674. * * 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
  52675. * * 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
  52676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52679. * @param name defines the name of the mesh
  52680. * @param options defines the options used to create the mesh
  52681. * @param scene defines the hosting scene
  52682. * @returns the plane polygonal mesh
  52683. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52684. */
  52685. static CreateDisc(name: string, options: {
  52686. radius?: number;
  52687. tessellation?: number;
  52688. arc?: number;
  52689. updatable?: boolean;
  52690. sideOrientation?: number;
  52691. frontUVs?: Vector4;
  52692. backUVs?: Vector4;
  52693. }, scene?: Nullable<Scene>): Mesh;
  52694. /**
  52695. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52696. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52697. * * 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`)
  52698. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52699. * * 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
  52700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52703. * @param name defines the name of the mesh
  52704. * @param options defines the options used to create the mesh
  52705. * @param scene defines the hosting scene
  52706. * @returns the icosahedron mesh
  52707. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52708. */
  52709. static CreateIcoSphere(name: string, options: {
  52710. radius?: number;
  52711. radiusX?: number;
  52712. radiusY?: number;
  52713. radiusZ?: number;
  52714. flat?: boolean;
  52715. subdivisions?: number;
  52716. sideOrientation?: number;
  52717. frontUVs?: Vector4;
  52718. backUVs?: Vector4;
  52719. updatable?: boolean;
  52720. }, scene?: Nullable<Scene>): Mesh;
  52721. /**
  52722. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52723. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52724. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52725. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52726. * * 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
  52727. * * 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
  52728. * * 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
  52729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52731. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52732. * * 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
  52733. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52734. * * 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
  52735. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52737. * @param name defines the name of the mesh
  52738. * @param options defines the options used to create the mesh
  52739. * @param scene defines the hosting scene
  52740. * @returns the ribbon mesh
  52741. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52742. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52743. */
  52744. static CreateRibbon(name: string, options: {
  52745. pathArray: Vector3[][];
  52746. closeArray?: boolean;
  52747. closePath?: boolean;
  52748. offset?: number;
  52749. updatable?: boolean;
  52750. sideOrientation?: number;
  52751. frontUVs?: Vector4;
  52752. backUVs?: Vector4;
  52753. instance?: Mesh;
  52754. invertUV?: boolean;
  52755. uvs?: Vector2[];
  52756. colors?: Color4[];
  52757. }, scene?: Nullable<Scene>): Mesh;
  52758. /**
  52759. * Creates a cylinder or a cone mesh
  52760. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52761. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52762. * * 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.
  52763. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52764. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52765. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52766. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52767. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52768. * * 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).
  52769. * * 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
  52770. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52771. * * 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
  52772. * * 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.
  52773. * * If `enclose` is false, a ring surface is one element.
  52774. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52775. * * 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
  52776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52779. * @param name defines the name of the mesh
  52780. * @param options defines the options used to create the mesh
  52781. * @param scene defines the hosting scene
  52782. * @returns the cylinder mesh
  52783. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52784. */
  52785. static CreateCylinder(name: string, options: {
  52786. height?: number;
  52787. diameterTop?: number;
  52788. diameterBottom?: number;
  52789. diameter?: number;
  52790. tessellation?: number;
  52791. subdivisions?: number;
  52792. arc?: number;
  52793. faceColors?: Color4[];
  52794. faceUV?: Vector4[];
  52795. updatable?: boolean;
  52796. hasRings?: boolean;
  52797. enclose?: boolean;
  52798. sideOrientation?: number;
  52799. frontUVs?: Vector4;
  52800. backUVs?: Vector4;
  52801. }, scene?: Nullable<Scene>): Mesh;
  52802. /**
  52803. * Creates a torus mesh
  52804. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52805. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52806. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52810. * @param name defines the name of the mesh
  52811. * @param options defines the options used to create the mesh
  52812. * @param scene defines the hosting scene
  52813. * @returns the torus mesh
  52814. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52815. */
  52816. static CreateTorus(name: string, options: {
  52817. diameter?: number;
  52818. thickness?: number;
  52819. tessellation?: number;
  52820. updatable?: boolean;
  52821. sideOrientation?: number;
  52822. frontUVs?: Vector4;
  52823. backUVs?: Vector4;
  52824. }, scene?: Nullable<Scene>): Mesh;
  52825. /**
  52826. * Creates a torus knot mesh
  52827. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52828. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52829. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52830. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52832. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52834. * @param name defines the name of the mesh
  52835. * @param options defines the options used to create the mesh
  52836. * @param scene defines the hosting scene
  52837. * @returns the torus knot mesh
  52838. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52839. */
  52840. static CreateTorusKnot(name: string, options: {
  52841. radius?: number;
  52842. tube?: number;
  52843. radialSegments?: number;
  52844. tubularSegments?: number;
  52845. p?: number;
  52846. q?: number;
  52847. updatable?: boolean;
  52848. sideOrientation?: number;
  52849. frontUVs?: Vector4;
  52850. backUVs?: Vector4;
  52851. }, scene?: Nullable<Scene>): Mesh;
  52852. /**
  52853. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52854. * * 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
  52855. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52856. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52857. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52858. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52859. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52860. * * 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
  52861. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52864. * @param name defines the name of the new line system
  52865. * @param options defines the options used to create the line system
  52866. * @param scene defines the hosting scene
  52867. * @returns a new line system mesh
  52868. */
  52869. static CreateLineSystem(name: string, options: {
  52870. lines: Vector3[][];
  52871. updatable?: boolean;
  52872. instance?: Nullable<LinesMesh>;
  52873. colors?: Nullable<Color4[][]>;
  52874. useVertexAlpha?: boolean;
  52875. }, scene: Nullable<Scene>): LinesMesh;
  52876. /**
  52877. * Creates a line mesh
  52878. * 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
  52879. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52880. * * The parameter `points` is an array successive Vector3
  52881. * * 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
  52882. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52883. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52884. * * When updating an instance, remember that only point positions can change, not the number of points
  52885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52887. * @param name defines the name of the new line system
  52888. * @param options defines the options used to create the line system
  52889. * @param scene defines the hosting scene
  52890. * @returns a new line mesh
  52891. */
  52892. static CreateLines(name: string, options: {
  52893. points: Vector3[];
  52894. updatable?: boolean;
  52895. instance?: Nullable<LinesMesh>;
  52896. colors?: Color4[];
  52897. useVertexAlpha?: boolean;
  52898. }, scene?: Nullable<Scene>): LinesMesh;
  52899. /**
  52900. * Creates a dashed line mesh
  52901. * * 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
  52902. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52903. * * The parameter `points` is an array successive Vector3
  52904. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52905. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52906. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52907. * * 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
  52908. * * When updating an instance, remember that only point positions can change, not the number of points
  52909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52910. * @param name defines the name of the mesh
  52911. * @param options defines the options used to create the mesh
  52912. * @param scene defines the hosting scene
  52913. * @returns the dashed line mesh
  52914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52915. */
  52916. static CreateDashedLines(name: string, options: {
  52917. points: Vector3[];
  52918. dashSize?: number;
  52919. gapSize?: number;
  52920. dashNb?: number;
  52921. updatable?: boolean;
  52922. instance?: LinesMesh;
  52923. }, scene?: Nullable<Scene>): LinesMesh;
  52924. /**
  52925. * 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.
  52926. * * 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.
  52927. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52928. * * 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.
  52929. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52930. * * 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
  52931. * * 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
  52932. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52935. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52937. * @param name defines the name of the mesh
  52938. * @param options defines the options used to create the mesh
  52939. * @param scene defines the hosting scene
  52940. * @returns the extruded shape mesh
  52941. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52943. */
  52944. static ExtrudeShape(name: string, options: {
  52945. shape: Vector3[];
  52946. path: Vector3[];
  52947. scale?: number;
  52948. rotation?: number;
  52949. cap?: number;
  52950. updatable?: boolean;
  52951. sideOrientation?: number;
  52952. frontUVs?: Vector4;
  52953. backUVs?: Vector4;
  52954. instance?: Mesh;
  52955. invertUV?: boolean;
  52956. }, scene?: Nullable<Scene>): Mesh;
  52957. /**
  52958. * Creates an custom extruded shape mesh.
  52959. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52960. * * 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.
  52961. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52962. * * 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
  52963. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52964. * * 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
  52965. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52966. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52967. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52968. * * 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
  52969. * * 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
  52970. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52973. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52975. * @param name defines the name of the mesh
  52976. * @param options defines the options used to create the mesh
  52977. * @param scene defines the hosting scene
  52978. * @returns the custom extruded shape mesh
  52979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52980. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52982. */
  52983. static ExtrudeShapeCustom(name: string, options: {
  52984. shape: Vector3[];
  52985. path: Vector3[];
  52986. scaleFunction?: any;
  52987. rotationFunction?: any;
  52988. ribbonCloseArray?: boolean;
  52989. ribbonClosePath?: boolean;
  52990. cap?: number;
  52991. updatable?: boolean;
  52992. sideOrientation?: number;
  52993. frontUVs?: Vector4;
  52994. backUVs?: Vector4;
  52995. instance?: Mesh;
  52996. invertUV?: boolean;
  52997. }, scene?: Nullable<Scene>): Mesh;
  52998. /**
  52999. * Creates lathe mesh.
  53000. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53001. * * 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
  53002. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53003. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53004. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53005. * * 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
  53006. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53007. * * 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
  53008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53010. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53012. * @param name defines the name of the mesh
  53013. * @param options defines the options used to create the mesh
  53014. * @param scene defines the hosting scene
  53015. * @returns the lathe mesh
  53016. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53017. */
  53018. static CreateLathe(name: string, options: {
  53019. shape: Vector3[];
  53020. radius?: number;
  53021. tessellation?: number;
  53022. clip?: number;
  53023. arc?: number;
  53024. closed?: boolean;
  53025. updatable?: boolean;
  53026. sideOrientation?: number;
  53027. frontUVs?: Vector4;
  53028. backUVs?: Vector4;
  53029. cap?: number;
  53030. invertUV?: boolean;
  53031. }, scene?: Nullable<Scene>): Mesh;
  53032. /**
  53033. * Creates a plane mesh
  53034. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53035. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53036. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53040. * @param name defines the name of the mesh
  53041. * @param options defines the options used to create the mesh
  53042. * @param scene defines the hosting scene
  53043. * @returns the plane mesh
  53044. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53045. */
  53046. static CreatePlane(name: string, options: {
  53047. size?: number;
  53048. width?: number;
  53049. height?: number;
  53050. sideOrientation?: number;
  53051. frontUVs?: Vector4;
  53052. backUVs?: Vector4;
  53053. updatable?: boolean;
  53054. sourcePlane?: Plane;
  53055. }, scene?: Nullable<Scene>): Mesh;
  53056. /**
  53057. * Creates a ground mesh
  53058. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53059. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53061. * @param name defines the name of the mesh
  53062. * @param options defines the options used to create the mesh
  53063. * @param scene defines the hosting scene
  53064. * @returns the ground mesh
  53065. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53066. */
  53067. static CreateGround(name: string, options: {
  53068. width?: number;
  53069. height?: number;
  53070. subdivisions?: number;
  53071. subdivisionsX?: number;
  53072. subdivisionsY?: number;
  53073. updatable?: boolean;
  53074. }, scene?: Nullable<Scene>): Mesh;
  53075. /**
  53076. * Creates a tiled ground mesh
  53077. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53078. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53079. * * 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
  53080. * * 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
  53081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53082. * @param name defines the name of the mesh
  53083. * @param options defines the options used to create the mesh
  53084. * @param scene defines the hosting scene
  53085. * @returns the tiled ground mesh
  53086. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53087. */
  53088. static CreateTiledGround(name: string, options: {
  53089. xmin: number;
  53090. zmin: number;
  53091. xmax: number;
  53092. zmax: number;
  53093. subdivisions?: {
  53094. w: number;
  53095. h: number;
  53096. };
  53097. precision?: {
  53098. w: number;
  53099. h: number;
  53100. };
  53101. updatable?: boolean;
  53102. }, scene?: Nullable<Scene>): Mesh;
  53103. /**
  53104. * Creates a ground mesh from a height map
  53105. * * The parameter `url` sets the URL of the height map image resource.
  53106. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53107. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53108. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53109. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53110. * * 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.
  53111. * * 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).
  53112. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53114. * @param name defines the name of the mesh
  53115. * @param url defines the url to the height map
  53116. * @param options defines the options used to create the mesh
  53117. * @param scene defines the hosting scene
  53118. * @returns the ground mesh
  53119. * @see https://doc.babylonjs.com/babylon101/height_map
  53120. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53121. */
  53122. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53123. width?: number;
  53124. height?: number;
  53125. subdivisions?: number;
  53126. minHeight?: number;
  53127. maxHeight?: number;
  53128. colorFilter?: Color3;
  53129. alphaFilter?: number;
  53130. updatable?: boolean;
  53131. onReady?: (mesh: GroundMesh) => void;
  53132. }, scene?: Nullable<Scene>): GroundMesh;
  53133. /**
  53134. * Creates a polygon mesh
  53135. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53136. * * 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
  53137. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53140. * * Remember you can only change the shape positions, not their number when updating a polygon
  53141. * @param name defines the name of the mesh
  53142. * @param options defines the options used to create the mesh
  53143. * @param scene defines the hosting scene
  53144. * @param earcutInjection can be used to inject your own earcut reference
  53145. * @returns the polygon mesh
  53146. */
  53147. static CreatePolygon(name: string, options: {
  53148. shape: Vector3[];
  53149. holes?: Vector3[][];
  53150. depth?: number;
  53151. faceUV?: Vector4[];
  53152. faceColors?: Color4[];
  53153. updatable?: boolean;
  53154. sideOrientation?: number;
  53155. frontUVs?: Vector4;
  53156. backUVs?: Vector4;
  53157. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53158. /**
  53159. * Creates an extruded polygon mesh, with depth in the Y direction.
  53160. * * 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)
  53161. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53162. * @param name defines the name of the mesh
  53163. * @param options defines the options used to create the mesh
  53164. * @param scene defines the hosting scene
  53165. * @param earcutInjection can be used to inject your own earcut reference
  53166. * @returns the polygon mesh
  53167. */
  53168. static ExtrudePolygon(name: string, options: {
  53169. shape: Vector3[];
  53170. holes?: Vector3[][];
  53171. depth?: number;
  53172. faceUV?: Vector4[];
  53173. faceColors?: Color4[];
  53174. updatable?: boolean;
  53175. sideOrientation?: number;
  53176. frontUVs?: Vector4;
  53177. backUVs?: Vector4;
  53178. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53179. /**
  53180. * Creates a tube mesh.
  53181. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53182. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53183. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53184. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53185. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53186. * * 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)
  53187. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53188. * * 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
  53189. * * 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
  53190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53194. * @param name defines the name of the mesh
  53195. * @param options defines the options used to create the mesh
  53196. * @param scene defines the hosting scene
  53197. * @returns the tube mesh
  53198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53199. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53200. */
  53201. static CreateTube(name: string, options: {
  53202. path: Vector3[];
  53203. radius?: number;
  53204. tessellation?: number;
  53205. radiusFunction?: {
  53206. (i: number, distance: number): number;
  53207. };
  53208. cap?: number;
  53209. arc?: number;
  53210. updatable?: boolean;
  53211. sideOrientation?: number;
  53212. frontUVs?: Vector4;
  53213. backUVs?: Vector4;
  53214. instance?: Mesh;
  53215. invertUV?: boolean;
  53216. }, scene?: Nullable<Scene>): Mesh;
  53217. /**
  53218. * Creates a polyhedron mesh
  53219. * * 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
  53220. * * The parameter `size` (positive float, default 1) sets the polygon size
  53221. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53222. * * 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`
  53223. * * 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
  53224. * * 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)`)
  53225. * * 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
  53226. * * 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
  53227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53230. * @param name defines the name of the mesh
  53231. * @param options defines the options used to create the mesh
  53232. * @param scene defines the hosting scene
  53233. * @returns the polyhedron mesh
  53234. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53235. */
  53236. static CreatePolyhedron(name: string, options: {
  53237. type?: number;
  53238. size?: number;
  53239. sizeX?: number;
  53240. sizeY?: number;
  53241. sizeZ?: number;
  53242. custom?: any;
  53243. faceUV?: Vector4[];
  53244. faceColors?: Color4[];
  53245. flat?: boolean;
  53246. updatable?: boolean;
  53247. sideOrientation?: number;
  53248. frontUVs?: Vector4;
  53249. backUVs?: Vector4;
  53250. }, scene?: Nullable<Scene>): Mesh;
  53251. /**
  53252. * Creates a decal mesh.
  53253. * 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
  53254. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53255. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53256. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53257. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53258. * @param name defines the name of the mesh
  53259. * @param sourceMesh defines the mesh where the decal must be applied
  53260. * @param options defines the options used to create the mesh
  53261. * @param scene defines the hosting scene
  53262. * @returns the decal mesh
  53263. * @see https://doc.babylonjs.com/how_to/decals
  53264. */
  53265. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53266. position?: Vector3;
  53267. normal?: Vector3;
  53268. size?: Vector3;
  53269. angle?: number;
  53270. }): Mesh;
  53271. }
  53272. }
  53273. declare module "babylonjs/Meshes/meshSimplification" {
  53274. import { Mesh } from "babylonjs/Meshes/mesh";
  53275. /**
  53276. * A simplifier interface for future simplification implementations
  53277. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53278. */
  53279. export interface ISimplifier {
  53280. /**
  53281. * Simplification of a given mesh according to the given settings.
  53282. * Since this requires computation, it is assumed that the function runs async.
  53283. * @param settings The settings of the simplification, including quality and distance
  53284. * @param successCallback A callback that will be called after the mesh was simplified.
  53285. * @param errorCallback in case of an error, this callback will be called. optional.
  53286. */
  53287. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53288. }
  53289. /**
  53290. * Expected simplification settings.
  53291. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53292. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53293. */
  53294. export interface ISimplificationSettings {
  53295. /**
  53296. * Gets or sets the expected quality
  53297. */
  53298. quality: number;
  53299. /**
  53300. * Gets or sets the distance when this optimized version should be used
  53301. */
  53302. distance: number;
  53303. /**
  53304. * Gets an already optimized mesh
  53305. */
  53306. optimizeMesh?: boolean;
  53307. }
  53308. /**
  53309. * Class used to specify simplification options
  53310. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53311. */
  53312. export class SimplificationSettings implements ISimplificationSettings {
  53313. /** expected quality */
  53314. quality: number;
  53315. /** distance when this optimized version should be used */
  53316. distance: number;
  53317. /** already optimized mesh */
  53318. optimizeMesh?: boolean | undefined;
  53319. /**
  53320. * Creates a SimplificationSettings
  53321. * @param quality expected quality
  53322. * @param distance distance when this optimized version should be used
  53323. * @param optimizeMesh already optimized mesh
  53324. */
  53325. constructor(
  53326. /** expected quality */
  53327. quality: number,
  53328. /** distance when this optimized version should be used */
  53329. distance: number,
  53330. /** already optimized mesh */
  53331. optimizeMesh?: boolean | undefined);
  53332. }
  53333. /**
  53334. * Interface used to define a simplification task
  53335. */
  53336. export interface ISimplificationTask {
  53337. /**
  53338. * Array of settings
  53339. */
  53340. settings: Array<ISimplificationSettings>;
  53341. /**
  53342. * Simplification type
  53343. */
  53344. simplificationType: SimplificationType;
  53345. /**
  53346. * Mesh to simplify
  53347. */
  53348. mesh: Mesh;
  53349. /**
  53350. * Callback called on success
  53351. */
  53352. successCallback?: () => void;
  53353. /**
  53354. * Defines if parallel processing can be used
  53355. */
  53356. parallelProcessing: boolean;
  53357. }
  53358. /**
  53359. * Queue used to order the simplification tasks
  53360. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53361. */
  53362. export class SimplificationQueue {
  53363. private _simplificationArray;
  53364. /**
  53365. * Gets a boolean indicating that the process is still running
  53366. */
  53367. running: boolean;
  53368. /**
  53369. * Creates a new queue
  53370. */
  53371. constructor();
  53372. /**
  53373. * Adds a new simplification task
  53374. * @param task defines a task to add
  53375. */
  53376. addTask(task: ISimplificationTask): void;
  53377. /**
  53378. * Execute next task
  53379. */
  53380. executeNext(): void;
  53381. /**
  53382. * Execute a simplification task
  53383. * @param task defines the task to run
  53384. */
  53385. runSimplification(task: ISimplificationTask): void;
  53386. private getSimplifier;
  53387. }
  53388. /**
  53389. * The implemented types of simplification
  53390. * At the moment only Quadratic Error Decimation is implemented
  53391. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53392. */
  53393. export enum SimplificationType {
  53394. /** Quadratic error decimation */
  53395. QUADRATIC = 0
  53396. }
  53397. }
  53398. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53399. import { Scene } from "babylonjs/scene";
  53400. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53401. import { ISceneComponent } from "babylonjs/sceneComponent";
  53402. module "babylonjs/scene" {
  53403. interface Scene {
  53404. /** @hidden (Backing field) */
  53405. _simplificationQueue: SimplificationQueue;
  53406. /**
  53407. * Gets or sets the simplification queue attached to the scene
  53408. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53409. */
  53410. simplificationQueue: SimplificationQueue;
  53411. }
  53412. }
  53413. module "babylonjs/Meshes/mesh" {
  53414. interface Mesh {
  53415. /**
  53416. * Simplify the mesh according to the given array of settings.
  53417. * Function will return immediately and will simplify async
  53418. * @param settings a collection of simplification settings
  53419. * @param parallelProcessing should all levels calculate parallel or one after the other
  53420. * @param simplificationType the type of simplification to run
  53421. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53422. * @returns the current mesh
  53423. */
  53424. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53425. }
  53426. }
  53427. /**
  53428. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53429. * created in a scene
  53430. */
  53431. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53432. /**
  53433. * The component name helpfull to identify the component in the list of scene components.
  53434. */
  53435. readonly name: string;
  53436. /**
  53437. * The scene the component belongs to.
  53438. */
  53439. scene: Scene;
  53440. /**
  53441. * Creates a new instance of the component for the given scene
  53442. * @param scene Defines the scene to register the component in
  53443. */
  53444. constructor(scene: Scene);
  53445. /**
  53446. * Registers the component in a given scene
  53447. */
  53448. register(): void;
  53449. /**
  53450. * Rebuilds the elements related to this component in case of
  53451. * context lost for instance.
  53452. */
  53453. rebuild(): void;
  53454. /**
  53455. * Disposes the component and the associated ressources
  53456. */
  53457. dispose(): void;
  53458. private _beforeCameraUpdate;
  53459. }
  53460. }
  53461. declare module "babylonjs/Meshes/Builders/index" {
  53462. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53463. export * from "babylonjs/Meshes/Builders/discBuilder";
  53464. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53465. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53466. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53467. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53468. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53469. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53470. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53471. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53472. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53473. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53474. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53475. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53476. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53477. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53478. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53479. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53480. }
  53481. declare module "babylonjs/Meshes/index" {
  53482. export * from "babylonjs/Meshes/abstractMesh";
  53483. export * from "babylonjs/Meshes/buffer";
  53484. export * from "babylonjs/Meshes/Compression/index";
  53485. export * from "babylonjs/Meshes/csg";
  53486. export * from "babylonjs/Meshes/geometry";
  53487. export * from "babylonjs/Meshes/groundMesh";
  53488. export * from "babylonjs/Meshes/trailMesh";
  53489. export * from "babylonjs/Meshes/instancedMesh";
  53490. export * from "babylonjs/Meshes/linesMesh";
  53491. export * from "babylonjs/Meshes/mesh";
  53492. export * from "babylonjs/Meshes/mesh.vertexData";
  53493. export * from "babylonjs/Meshes/meshBuilder";
  53494. export * from "babylonjs/Meshes/meshSimplification";
  53495. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53496. export * from "babylonjs/Meshes/polygonMesh";
  53497. export * from "babylonjs/Meshes/subMesh";
  53498. export * from "babylonjs/Meshes/meshLODLevel";
  53499. export * from "babylonjs/Meshes/transformNode";
  53500. export * from "babylonjs/Meshes/Builders/index";
  53501. export * from "babylonjs/Meshes/dataBuffer";
  53502. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53503. }
  53504. declare module "babylonjs/Morph/index" {
  53505. export * from "babylonjs/Morph/morphTarget";
  53506. export * from "babylonjs/Morph/morphTargetManager";
  53507. }
  53508. declare module "babylonjs/Offline/database" {
  53509. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53510. /**
  53511. * Class used to enable access to IndexedDB
  53512. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53513. */
  53514. export class Database implements IOfflineProvider {
  53515. private _callbackManifestChecked;
  53516. private _currentSceneUrl;
  53517. private _db;
  53518. private _enableSceneOffline;
  53519. private _enableTexturesOffline;
  53520. private _manifestVersionFound;
  53521. private _mustUpdateRessources;
  53522. private _hasReachedQuota;
  53523. private _isSupported;
  53524. private _idbFactory;
  53525. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53526. private static IsUASupportingBlobStorage;
  53527. /**
  53528. * Gets a boolean indicating if Database storate is enabled (off by default)
  53529. */
  53530. static IDBStorageEnabled: boolean;
  53531. /**
  53532. * Gets a boolean indicating if scene must be saved in the database
  53533. */
  53534. readonly enableSceneOffline: boolean;
  53535. /**
  53536. * Gets a boolean indicating if textures must be saved in the database
  53537. */
  53538. readonly enableTexturesOffline: boolean;
  53539. /**
  53540. * Creates a new Database
  53541. * @param urlToScene defines the url to load the scene
  53542. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53543. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53544. */
  53545. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53546. private static _ParseURL;
  53547. private static _ReturnFullUrlLocation;
  53548. private _checkManifestFile;
  53549. /**
  53550. * Open the database and make it available
  53551. * @param successCallback defines the callback to call on success
  53552. * @param errorCallback defines the callback to call on error
  53553. */
  53554. open(successCallback: () => void, errorCallback: () => void): void;
  53555. /**
  53556. * Loads an image from the database
  53557. * @param url defines the url to load from
  53558. * @param image defines the target DOM image
  53559. */
  53560. loadImage(url: string, image: HTMLImageElement): void;
  53561. private _loadImageFromDBAsync;
  53562. private _saveImageIntoDBAsync;
  53563. private _checkVersionFromDB;
  53564. private _loadVersionFromDBAsync;
  53565. private _saveVersionIntoDBAsync;
  53566. /**
  53567. * Loads a file from database
  53568. * @param url defines the URL to load from
  53569. * @param sceneLoaded defines a callback to call on success
  53570. * @param progressCallBack defines a callback to call when progress changed
  53571. * @param errorCallback defines a callback to call on error
  53572. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53573. */
  53574. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53575. private _loadFileAsync;
  53576. private _saveFileAsync;
  53577. /**
  53578. * Validates if xhr data is correct
  53579. * @param xhr defines the request to validate
  53580. * @param dataType defines the expected data type
  53581. * @returns true if data is correct
  53582. */
  53583. private static _ValidateXHRData;
  53584. }
  53585. }
  53586. declare module "babylonjs/Offline/index" {
  53587. export * from "babylonjs/Offline/database";
  53588. export * from "babylonjs/Offline/IOfflineProvider";
  53589. }
  53590. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53591. /** @hidden */
  53592. export var gpuUpdateParticlesPixelShader: {
  53593. name: string;
  53594. shader: string;
  53595. };
  53596. }
  53597. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53598. /** @hidden */
  53599. export var gpuUpdateParticlesVertexShader: {
  53600. name: string;
  53601. shader: string;
  53602. };
  53603. }
  53604. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53605. /** @hidden */
  53606. export var clipPlaneFragmentDeclaration2: {
  53607. name: string;
  53608. shader: string;
  53609. };
  53610. }
  53611. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53612. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53613. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53614. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53615. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53616. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53617. /** @hidden */
  53618. export var gpuRenderParticlesPixelShader: {
  53619. name: string;
  53620. shader: string;
  53621. };
  53622. }
  53623. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53624. /** @hidden */
  53625. export var clipPlaneVertexDeclaration2: {
  53626. name: string;
  53627. shader: string;
  53628. };
  53629. }
  53630. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53631. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53632. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53633. /** @hidden */
  53634. export var gpuRenderParticlesVertexShader: {
  53635. name: string;
  53636. shader: string;
  53637. };
  53638. }
  53639. declare module "babylonjs/Particles/gpuParticleSystem" {
  53640. import { Nullable } from "babylonjs/types";
  53641. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53642. import { Observable } from "babylonjs/Misc/observable";
  53643. import { Color4, Color3 } from "babylonjs/Maths/math";
  53644. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53645. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53646. import { Scene, IDisposable } from "babylonjs/scene";
  53647. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53648. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53649. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53650. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53651. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53652. /**
  53653. * This represents a GPU particle system in Babylon
  53654. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53655. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53656. */
  53657. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53658. /**
  53659. * The layer mask we are rendering the particles through.
  53660. */
  53661. layerMask: number;
  53662. private _capacity;
  53663. private _activeCount;
  53664. private _currentActiveCount;
  53665. private _accumulatedCount;
  53666. private _renderEffect;
  53667. private _updateEffect;
  53668. private _buffer0;
  53669. private _buffer1;
  53670. private _spriteBuffer;
  53671. private _updateVAO;
  53672. private _renderVAO;
  53673. private _targetIndex;
  53674. private _sourceBuffer;
  53675. private _targetBuffer;
  53676. private _engine;
  53677. private _currentRenderId;
  53678. private _started;
  53679. private _stopped;
  53680. private _timeDelta;
  53681. private _randomTexture;
  53682. private _randomTexture2;
  53683. private _attributesStrideSize;
  53684. private _updateEffectOptions;
  53685. private _randomTextureSize;
  53686. private _actualFrame;
  53687. private readonly _rawTextureWidth;
  53688. /**
  53689. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53690. */
  53691. static readonly IsSupported: boolean;
  53692. /**
  53693. * An event triggered when the system is disposed.
  53694. */
  53695. onDisposeObservable: Observable<GPUParticleSystem>;
  53696. /**
  53697. * Gets the maximum number of particles active at the same time.
  53698. * @returns The max number of active particles.
  53699. */
  53700. getCapacity(): number;
  53701. /**
  53702. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53703. * to override the particles.
  53704. */
  53705. forceDepthWrite: boolean;
  53706. /**
  53707. * Gets or set the number of active particles
  53708. */
  53709. activeParticleCount: number;
  53710. private _preWarmDone;
  53711. /**
  53712. * Is this system ready to be used/rendered
  53713. * @return true if the system is ready
  53714. */
  53715. isReady(): boolean;
  53716. /**
  53717. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53718. * @returns True if it has been started, otherwise false.
  53719. */
  53720. isStarted(): boolean;
  53721. /**
  53722. * Starts the particle system and begins to emit
  53723. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53724. */
  53725. start(delay?: number): void;
  53726. /**
  53727. * Stops the particle system.
  53728. */
  53729. stop(): void;
  53730. /**
  53731. * Remove all active particles
  53732. */
  53733. reset(): void;
  53734. /**
  53735. * Returns the string "GPUParticleSystem"
  53736. * @returns a string containing the class name
  53737. */
  53738. getClassName(): string;
  53739. private _colorGradientsTexture;
  53740. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53741. /**
  53742. * Adds a new color gradient
  53743. * @param gradient defines the gradient to use (between 0 and 1)
  53744. * @param color1 defines the color to affect to the specified gradient
  53745. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53746. * @returns the current particle system
  53747. */
  53748. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53749. /**
  53750. * Remove a specific color gradient
  53751. * @param gradient defines the gradient to remove
  53752. * @returns the current particle system
  53753. */
  53754. removeColorGradient(gradient: number): GPUParticleSystem;
  53755. private _angularSpeedGradientsTexture;
  53756. private _sizeGradientsTexture;
  53757. private _velocityGradientsTexture;
  53758. private _limitVelocityGradientsTexture;
  53759. private _dragGradientsTexture;
  53760. private _addFactorGradient;
  53761. /**
  53762. * Adds a new size gradient
  53763. * @param gradient defines the gradient to use (between 0 and 1)
  53764. * @param factor defines the size factor to affect to the specified gradient
  53765. * @returns the current particle system
  53766. */
  53767. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53768. /**
  53769. * Remove a specific size gradient
  53770. * @param gradient defines the gradient to remove
  53771. * @returns the current particle system
  53772. */
  53773. removeSizeGradient(gradient: number): GPUParticleSystem;
  53774. /**
  53775. * Adds a new angular speed gradient
  53776. * @param gradient defines the gradient to use (between 0 and 1)
  53777. * @param factor defines the angular speed to affect to the specified gradient
  53778. * @returns the current particle system
  53779. */
  53780. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53781. /**
  53782. * Remove a specific angular speed gradient
  53783. * @param gradient defines the gradient to remove
  53784. * @returns the current particle system
  53785. */
  53786. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53787. /**
  53788. * Adds a new velocity gradient
  53789. * @param gradient defines the gradient to use (between 0 and 1)
  53790. * @param factor defines the velocity to affect to the specified gradient
  53791. * @returns the current particle system
  53792. */
  53793. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53794. /**
  53795. * Remove a specific velocity gradient
  53796. * @param gradient defines the gradient to remove
  53797. * @returns the current particle system
  53798. */
  53799. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53800. /**
  53801. * Adds a new limit velocity gradient
  53802. * @param gradient defines the gradient to use (between 0 and 1)
  53803. * @param factor defines the limit velocity value to affect to the specified gradient
  53804. * @returns the current particle system
  53805. */
  53806. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53807. /**
  53808. * Remove a specific limit velocity gradient
  53809. * @param gradient defines the gradient to remove
  53810. * @returns the current particle system
  53811. */
  53812. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53813. /**
  53814. * Adds a new drag gradient
  53815. * @param gradient defines the gradient to use (between 0 and 1)
  53816. * @param factor defines the drag value to affect to the specified gradient
  53817. * @returns the current particle system
  53818. */
  53819. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53820. /**
  53821. * Remove a specific drag gradient
  53822. * @param gradient defines the gradient to remove
  53823. * @returns the current particle system
  53824. */
  53825. removeDragGradient(gradient: number): GPUParticleSystem;
  53826. /**
  53827. * Not supported by GPUParticleSystem
  53828. * @param gradient defines the gradient to use (between 0 and 1)
  53829. * @param factor defines the emit rate value to affect to the specified gradient
  53830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53831. * @returns the current particle system
  53832. */
  53833. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53834. /**
  53835. * Not supported by GPUParticleSystem
  53836. * @param gradient defines the gradient to remove
  53837. * @returns the current particle system
  53838. */
  53839. removeEmitRateGradient(gradient: number): IParticleSystem;
  53840. /**
  53841. * Not supported by GPUParticleSystem
  53842. * @param gradient defines the gradient to use (between 0 and 1)
  53843. * @param factor defines the start size value to affect to the specified gradient
  53844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53845. * @returns the current particle system
  53846. */
  53847. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53848. /**
  53849. * Not supported by GPUParticleSystem
  53850. * @param gradient defines the gradient to remove
  53851. * @returns the current particle system
  53852. */
  53853. removeStartSizeGradient(gradient: number): IParticleSystem;
  53854. /**
  53855. * Not supported by GPUParticleSystem
  53856. * @param gradient defines the gradient to use (between 0 and 1)
  53857. * @param min defines the color remap minimal range
  53858. * @param max defines the color remap maximal range
  53859. * @returns the current particle system
  53860. */
  53861. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53862. /**
  53863. * Not supported by GPUParticleSystem
  53864. * @param gradient defines the gradient to remove
  53865. * @returns the current particle system
  53866. */
  53867. removeColorRemapGradient(): IParticleSystem;
  53868. /**
  53869. * Not supported by GPUParticleSystem
  53870. * @param gradient defines the gradient to use (between 0 and 1)
  53871. * @param min defines the alpha remap minimal range
  53872. * @param max defines the alpha remap maximal range
  53873. * @returns the current particle system
  53874. */
  53875. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53876. /**
  53877. * Not supported by GPUParticleSystem
  53878. * @param gradient defines the gradient to remove
  53879. * @returns the current particle system
  53880. */
  53881. removeAlphaRemapGradient(): IParticleSystem;
  53882. /**
  53883. * Not supported by GPUParticleSystem
  53884. * @param gradient defines the gradient to use (between 0 and 1)
  53885. * @param color defines the color to affect to the specified gradient
  53886. * @returns the current particle system
  53887. */
  53888. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53889. /**
  53890. * Not supported by GPUParticleSystem
  53891. * @param gradient defines the gradient to remove
  53892. * @returns the current particle system
  53893. */
  53894. removeRampGradient(): IParticleSystem;
  53895. /**
  53896. * Not supported by GPUParticleSystem
  53897. * @returns the list of ramp gradients
  53898. */
  53899. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53900. /**
  53901. * Not supported by GPUParticleSystem
  53902. * Gets or sets a boolean indicating that ramp gradients must be used
  53903. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53904. */
  53905. useRampGradients: boolean;
  53906. /**
  53907. * Not supported by GPUParticleSystem
  53908. * @param gradient defines the gradient to use (between 0 and 1)
  53909. * @param factor defines the life time factor to affect to the specified gradient
  53910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53911. * @returns the current particle system
  53912. */
  53913. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53914. /**
  53915. * Not supported by GPUParticleSystem
  53916. * @param gradient defines the gradient to remove
  53917. * @returns the current particle system
  53918. */
  53919. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53920. /**
  53921. * Instantiates a GPU particle system.
  53922. * 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.
  53923. * @param name The name of the particle system
  53924. * @param options The options used to create the system
  53925. * @param scene The scene the particle system belongs to
  53926. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53927. */
  53928. constructor(name: string, options: Partial<{
  53929. capacity: number;
  53930. randomTextureSize: number;
  53931. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53932. protected _reset(): void;
  53933. private _createUpdateVAO;
  53934. private _createRenderVAO;
  53935. private _initialize;
  53936. /** @hidden */
  53937. _recreateUpdateEffect(): void;
  53938. /** @hidden */
  53939. _recreateRenderEffect(): void;
  53940. /**
  53941. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53942. * @param preWarm defines if we are in the pre-warmimg phase
  53943. */
  53944. animate(preWarm?: boolean): void;
  53945. private _createFactorGradientTexture;
  53946. private _createSizeGradientTexture;
  53947. private _createAngularSpeedGradientTexture;
  53948. private _createVelocityGradientTexture;
  53949. private _createLimitVelocityGradientTexture;
  53950. private _createDragGradientTexture;
  53951. private _createColorGradientTexture;
  53952. /**
  53953. * Renders the particle system in its current state
  53954. * @param preWarm defines if the system should only update the particles but not render them
  53955. * @returns the current number of particles
  53956. */
  53957. render(preWarm?: boolean): number;
  53958. /**
  53959. * Rebuilds the particle system
  53960. */
  53961. rebuild(): void;
  53962. private _releaseBuffers;
  53963. private _releaseVAOs;
  53964. /**
  53965. * Disposes the particle system and free the associated resources
  53966. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53967. */
  53968. dispose(disposeTexture?: boolean): void;
  53969. /**
  53970. * Clones the particle system.
  53971. * @param name The name of the cloned object
  53972. * @param newEmitter The new emitter to use
  53973. * @returns the cloned particle system
  53974. */
  53975. clone(name: string, newEmitter: any): GPUParticleSystem;
  53976. /**
  53977. * Serializes the particle system to a JSON object.
  53978. * @returns the JSON object
  53979. */
  53980. serialize(): any;
  53981. /**
  53982. * Parses a JSON object to create a GPU particle system.
  53983. * @param parsedParticleSystem The JSON object to parse
  53984. * @param scene The scene to create the particle system in
  53985. * @param rootUrl The root url to use to load external dependencies like texture
  53986. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53987. * @returns the parsed GPU particle system
  53988. */
  53989. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53990. }
  53991. }
  53992. declare module "babylonjs/Particles/particleSystemSet" {
  53993. import { Nullable } from "babylonjs/types";
  53994. import { Color3 } from "babylonjs/Maths/math";
  53995. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53997. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53998. import { Scene, IDisposable } from "babylonjs/scene";
  53999. /**
  54000. * Represents a set of particle systems working together to create a specific effect
  54001. */
  54002. export class ParticleSystemSet implements IDisposable {
  54003. private _emitterCreationOptions;
  54004. private _emitterNode;
  54005. /**
  54006. * Gets the particle system list
  54007. */
  54008. systems: IParticleSystem[];
  54009. /**
  54010. * Gets the emitter node used with this set
  54011. */
  54012. readonly emitterNode: Nullable<TransformNode>;
  54013. /**
  54014. * Creates a new emitter mesh as a sphere
  54015. * @param options defines the options used to create the sphere
  54016. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54017. * @param scene defines the hosting scene
  54018. */
  54019. setEmitterAsSphere(options: {
  54020. diameter: number;
  54021. segments: number;
  54022. color: Color3;
  54023. }, renderingGroupId: number, scene: Scene): void;
  54024. /**
  54025. * Starts all particle systems of the set
  54026. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54027. */
  54028. start(emitter?: AbstractMesh): void;
  54029. /**
  54030. * Release all associated resources
  54031. */
  54032. dispose(): void;
  54033. /**
  54034. * Serialize the set into a JSON compatible object
  54035. * @returns a JSON compatible representation of the set
  54036. */
  54037. serialize(): any;
  54038. /**
  54039. * Parse a new ParticleSystemSet from a serialized source
  54040. * @param data defines a JSON compatible representation of the set
  54041. * @param scene defines the hosting scene
  54042. * @param gpu defines if we want GPU particles or CPU particles
  54043. * @returns a new ParticleSystemSet
  54044. */
  54045. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54046. }
  54047. }
  54048. declare module "babylonjs/Particles/particleHelper" {
  54049. import { Nullable } from "babylonjs/types";
  54050. import { Scene } from "babylonjs/scene";
  54051. import { Vector3 } from "babylonjs/Maths/math";
  54052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54053. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54054. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54055. /**
  54056. * This class is made for on one-liner static method to help creating particle system set.
  54057. */
  54058. export class ParticleHelper {
  54059. /**
  54060. * Gets or sets base Assets URL
  54061. */
  54062. static BaseAssetsUrl: string;
  54063. /**
  54064. * Create a default particle system that you can tweak
  54065. * @param emitter defines the emitter to use
  54066. * @param capacity defines the system capacity (default is 500 particles)
  54067. * @param scene defines the hosting scene
  54068. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54069. * @returns the new Particle system
  54070. */
  54071. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54072. /**
  54073. * This is the main static method (one-liner) of this helper to create different particle systems
  54074. * @param type This string represents the type to the particle system to create
  54075. * @param scene The scene where the particle system should live
  54076. * @param gpu If the system will use gpu
  54077. * @returns the ParticleSystemSet created
  54078. */
  54079. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54080. /**
  54081. * Static function used to export a particle system to a ParticleSystemSet variable.
  54082. * Please note that the emitter shape is not exported
  54083. * @param systems defines the particle systems to export
  54084. * @returns the created particle system set
  54085. */
  54086. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54087. }
  54088. }
  54089. declare module "babylonjs/Particles/particleSystemComponent" {
  54090. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54091. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54092. import "babylonjs/Shaders/particles.vertex";
  54093. module "babylonjs/Engines/engine" {
  54094. interface Engine {
  54095. /**
  54096. * Create an effect to use with particle systems.
  54097. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54098. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54099. * @param uniformsNames defines a list of attribute names
  54100. * @param samplers defines an array of string used to represent textures
  54101. * @param defines defines the string containing the defines to use to compile the shaders
  54102. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54103. * @param onCompiled defines a function to call when the effect creation is successful
  54104. * @param onError defines a function to call when the effect creation has failed
  54105. * @returns the new Effect
  54106. */
  54107. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54108. }
  54109. }
  54110. module "babylonjs/Meshes/mesh" {
  54111. interface Mesh {
  54112. /**
  54113. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54114. * @returns an array of IParticleSystem
  54115. */
  54116. getEmittedParticleSystems(): IParticleSystem[];
  54117. /**
  54118. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54119. * @returns an array of IParticleSystem
  54120. */
  54121. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54122. }
  54123. }
  54124. /**
  54125. * @hidden
  54126. */
  54127. export var _IDoNeedToBeInTheBuild: number;
  54128. }
  54129. declare module "babylonjs/Particles/index" {
  54130. export * from "babylonjs/Particles/baseParticleSystem";
  54131. export * from "babylonjs/Particles/EmitterTypes/index";
  54132. export * from "babylonjs/Particles/gpuParticleSystem";
  54133. export * from "babylonjs/Particles/IParticleSystem";
  54134. export * from "babylonjs/Particles/particle";
  54135. export * from "babylonjs/Particles/particleHelper";
  54136. export * from "babylonjs/Particles/particleSystem";
  54137. export * from "babylonjs/Particles/particleSystemComponent";
  54138. export * from "babylonjs/Particles/particleSystemSet";
  54139. export * from "babylonjs/Particles/solidParticle";
  54140. export * from "babylonjs/Particles/solidParticleSystem";
  54141. export * from "babylonjs/Particles/subEmitter";
  54142. }
  54143. declare module "babylonjs/Physics/physicsEngineComponent" {
  54144. import { Nullable } from "babylonjs/types";
  54145. import { Observable, Observer } from "babylonjs/Misc/observable";
  54146. import { Vector3 } from "babylonjs/Maths/math";
  54147. import { Mesh } from "babylonjs/Meshes/mesh";
  54148. import { ISceneComponent } from "babylonjs/sceneComponent";
  54149. import { Scene } from "babylonjs/scene";
  54150. import { Node } from "babylonjs/node";
  54151. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54152. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54153. module "babylonjs/scene" {
  54154. interface Scene {
  54155. /** @hidden (Backing field) */
  54156. _physicsEngine: Nullable<IPhysicsEngine>;
  54157. /**
  54158. * Gets the current physics engine
  54159. * @returns a IPhysicsEngine or null if none attached
  54160. */
  54161. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54162. /**
  54163. * Enables physics to the current scene
  54164. * @param gravity defines the scene's gravity for the physics engine
  54165. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54166. * @return a boolean indicating if the physics engine was initialized
  54167. */
  54168. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54169. /**
  54170. * Disables and disposes the physics engine associated with the scene
  54171. */
  54172. disablePhysicsEngine(): void;
  54173. /**
  54174. * Gets a boolean indicating if there is an active physics engine
  54175. * @returns a boolean indicating if there is an active physics engine
  54176. */
  54177. isPhysicsEnabled(): boolean;
  54178. /**
  54179. * Deletes a physics compound impostor
  54180. * @param compound defines the compound to delete
  54181. */
  54182. deleteCompoundImpostor(compound: any): void;
  54183. /**
  54184. * An event triggered when physic simulation is about to be run
  54185. */
  54186. onBeforePhysicsObservable: Observable<Scene>;
  54187. /**
  54188. * An event triggered when physic simulation has been done
  54189. */
  54190. onAfterPhysicsObservable: Observable<Scene>;
  54191. }
  54192. }
  54193. module "babylonjs/Meshes/abstractMesh" {
  54194. interface AbstractMesh {
  54195. /** @hidden */
  54196. _physicsImpostor: Nullable<PhysicsImpostor>;
  54197. /**
  54198. * Gets or sets impostor used for physic simulation
  54199. * @see http://doc.babylonjs.com/features/physics_engine
  54200. */
  54201. physicsImpostor: Nullable<PhysicsImpostor>;
  54202. /**
  54203. * Gets the current physics impostor
  54204. * @see http://doc.babylonjs.com/features/physics_engine
  54205. * @returns a physics impostor or null
  54206. */
  54207. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54208. /** Apply a physic impulse to the mesh
  54209. * @param force defines the force to apply
  54210. * @param contactPoint defines where to apply the force
  54211. * @returns the current mesh
  54212. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54213. */
  54214. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54215. /**
  54216. * Creates a physic joint between two meshes
  54217. * @param otherMesh defines the other mesh to use
  54218. * @param pivot1 defines the pivot to use on this mesh
  54219. * @param pivot2 defines the pivot to use on the other mesh
  54220. * @param options defines additional options (can be plugin dependent)
  54221. * @returns the current mesh
  54222. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54223. */
  54224. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54225. /** @hidden */
  54226. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54227. }
  54228. }
  54229. /**
  54230. * Defines the physics engine scene component responsible to manage a physics engine
  54231. */
  54232. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54233. /**
  54234. * The component name helpful to identify the component in the list of scene components.
  54235. */
  54236. readonly name: string;
  54237. /**
  54238. * The scene the component belongs to.
  54239. */
  54240. scene: Scene;
  54241. /**
  54242. * Creates a new instance of the component for the given scene
  54243. * @param scene Defines the scene to register the component in
  54244. */
  54245. constructor(scene: Scene);
  54246. /**
  54247. * Registers the component in a given scene
  54248. */
  54249. register(): void;
  54250. /**
  54251. * Rebuilds the elements related to this component in case of
  54252. * context lost for instance.
  54253. */
  54254. rebuild(): void;
  54255. /**
  54256. * Disposes the component and the associated ressources
  54257. */
  54258. dispose(): void;
  54259. }
  54260. }
  54261. declare module "babylonjs/Physics/physicsHelper" {
  54262. import { Nullable } from "babylonjs/types";
  54263. import { Vector3 } from "babylonjs/Maths/math";
  54264. import { Mesh } from "babylonjs/Meshes/mesh";
  54265. import { Scene } from "babylonjs/scene";
  54266. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54267. /**
  54268. * A helper for physics simulations
  54269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54270. */
  54271. export class PhysicsHelper {
  54272. private _scene;
  54273. private _physicsEngine;
  54274. /**
  54275. * Initializes the Physics helper
  54276. * @param scene Babylon.js scene
  54277. */
  54278. constructor(scene: Scene);
  54279. /**
  54280. * Applies a radial explosion impulse
  54281. * @param origin the origin of the explosion
  54282. * @param radiusOrEventOptions the radius or the options of radial explosion
  54283. * @param strength the explosion strength
  54284. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54285. * @returns A physics radial explosion event, or null
  54286. */
  54287. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54288. /**
  54289. * Applies a radial explosion force
  54290. * @param origin the origin of the explosion
  54291. * @param radiusOrEventOptions the radius or the options of radial explosion
  54292. * @param strength the explosion strength
  54293. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54294. * @returns A physics radial explosion event, or null
  54295. */
  54296. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54297. /**
  54298. * Creates a gravitational field
  54299. * @param origin the origin of the explosion
  54300. * @param radiusOrEventOptions the radius or the options of radial explosion
  54301. * @param strength the explosion strength
  54302. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54303. * @returns A physics gravitational field event, or null
  54304. */
  54305. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54306. /**
  54307. * Creates a physics updraft event
  54308. * @param origin the origin of the updraft
  54309. * @param radiusOrEventOptions the radius or the options of the updraft
  54310. * @param strength the strength of the updraft
  54311. * @param height the height of the updraft
  54312. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54313. * @returns A physics updraft event, or null
  54314. */
  54315. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54316. /**
  54317. * Creates a physics vortex event
  54318. * @param origin the of the vortex
  54319. * @param radiusOrEventOptions the radius or the options of the vortex
  54320. * @param strength the strength of the vortex
  54321. * @param height the height of the vortex
  54322. * @returns a Physics vortex event, or null
  54323. * A physics vortex event or null
  54324. */
  54325. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54326. }
  54327. /**
  54328. * Represents a physics radial explosion event
  54329. */
  54330. class PhysicsRadialExplosionEvent {
  54331. private _scene;
  54332. private _options;
  54333. private _sphere;
  54334. private _dataFetched;
  54335. /**
  54336. * Initializes a radial explosioin event
  54337. * @param _scene BabylonJS scene
  54338. * @param _options The options for the vortex event
  54339. */
  54340. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54341. /**
  54342. * Returns the data related to the radial explosion event (sphere).
  54343. * @returns The radial explosion event data
  54344. */
  54345. getData(): PhysicsRadialExplosionEventData;
  54346. /**
  54347. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54348. * @param impostor A physics imposter
  54349. * @param origin the origin of the explosion
  54350. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54351. */
  54352. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54353. /**
  54354. * Triggers affecterd impostors callbacks
  54355. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54356. */
  54357. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54358. /**
  54359. * Disposes the sphere.
  54360. * @param force Specifies if the sphere should be disposed by force
  54361. */
  54362. dispose(force?: boolean): void;
  54363. /*** Helpers ***/
  54364. private _prepareSphere;
  54365. private _intersectsWithSphere;
  54366. }
  54367. /**
  54368. * Represents a gravitational field event
  54369. */
  54370. class PhysicsGravitationalFieldEvent {
  54371. private _physicsHelper;
  54372. private _scene;
  54373. private _origin;
  54374. private _options;
  54375. private _tickCallback;
  54376. private _sphere;
  54377. private _dataFetched;
  54378. /**
  54379. * Initializes the physics gravitational field event
  54380. * @param _physicsHelper A physics helper
  54381. * @param _scene BabylonJS scene
  54382. * @param _origin The origin position of the gravitational field event
  54383. * @param _options The options for the vortex event
  54384. */
  54385. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54386. /**
  54387. * Returns the data related to the gravitational field event (sphere).
  54388. * @returns A gravitational field event
  54389. */
  54390. getData(): PhysicsGravitationalFieldEventData;
  54391. /**
  54392. * Enables the gravitational field.
  54393. */
  54394. enable(): void;
  54395. /**
  54396. * Disables the gravitational field.
  54397. */
  54398. disable(): void;
  54399. /**
  54400. * Disposes the sphere.
  54401. * @param force The force to dispose from the gravitational field event
  54402. */
  54403. dispose(force?: boolean): void;
  54404. private _tick;
  54405. }
  54406. /**
  54407. * Represents a physics updraft event
  54408. */
  54409. class PhysicsUpdraftEvent {
  54410. private _scene;
  54411. private _origin;
  54412. private _options;
  54413. private _physicsEngine;
  54414. private _originTop;
  54415. private _originDirection;
  54416. private _tickCallback;
  54417. private _cylinder;
  54418. private _cylinderPosition;
  54419. private _dataFetched;
  54420. /**
  54421. * Initializes the physics updraft event
  54422. * @param _scene BabylonJS scene
  54423. * @param _origin The origin position of the updraft
  54424. * @param _options The options for the updraft event
  54425. */
  54426. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54427. /**
  54428. * Returns the data related to the updraft event (cylinder).
  54429. * @returns A physics updraft event
  54430. */
  54431. getData(): PhysicsUpdraftEventData;
  54432. /**
  54433. * Enables the updraft.
  54434. */
  54435. enable(): void;
  54436. /**
  54437. * Disables the updraft.
  54438. */
  54439. disable(): void;
  54440. /**
  54441. * Disposes the cylinder.
  54442. * @param force Specifies if the updraft should be disposed by force
  54443. */
  54444. dispose(force?: boolean): void;
  54445. private getImpostorHitData;
  54446. private _tick;
  54447. /*** Helpers ***/
  54448. private _prepareCylinder;
  54449. private _intersectsWithCylinder;
  54450. }
  54451. /**
  54452. * Represents a physics vortex event
  54453. */
  54454. class PhysicsVortexEvent {
  54455. private _scene;
  54456. private _origin;
  54457. private _options;
  54458. private _physicsEngine;
  54459. private _originTop;
  54460. private _tickCallback;
  54461. private _cylinder;
  54462. private _cylinderPosition;
  54463. private _dataFetched;
  54464. /**
  54465. * Initializes the physics vortex event
  54466. * @param _scene The BabylonJS scene
  54467. * @param _origin The origin position of the vortex
  54468. * @param _options The options for the vortex event
  54469. */
  54470. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54471. /**
  54472. * Returns the data related to the vortex event (cylinder).
  54473. * @returns The physics vortex event data
  54474. */
  54475. getData(): PhysicsVortexEventData;
  54476. /**
  54477. * Enables the vortex.
  54478. */
  54479. enable(): void;
  54480. /**
  54481. * Disables the cortex.
  54482. */
  54483. disable(): void;
  54484. /**
  54485. * Disposes the sphere.
  54486. * @param force
  54487. */
  54488. dispose(force?: boolean): void;
  54489. private getImpostorHitData;
  54490. private _tick;
  54491. /*** Helpers ***/
  54492. private _prepareCylinder;
  54493. private _intersectsWithCylinder;
  54494. }
  54495. /**
  54496. * Options fot the radial explosion event
  54497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54498. */
  54499. export class PhysicsRadialExplosionEventOptions {
  54500. /**
  54501. * The radius of the sphere for the radial explosion.
  54502. */
  54503. radius: number;
  54504. /**
  54505. * The strenth of the explosion.
  54506. */
  54507. strength: number;
  54508. /**
  54509. * The strenght of the force in correspondence to the distance of the affected object
  54510. */
  54511. falloff: PhysicsRadialImpulseFalloff;
  54512. /**
  54513. * Sphere options for the radial explosion.
  54514. */
  54515. sphere: {
  54516. segments: number;
  54517. diameter: number;
  54518. };
  54519. /**
  54520. * Sphere options for the radial explosion.
  54521. */
  54522. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54523. }
  54524. /**
  54525. * Options fot the updraft event
  54526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54527. */
  54528. export class PhysicsUpdraftEventOptions {
  54529. /**
  54530. * The radius of the cylinder for the vortex
  54531. */
  54532. radius: number;
  54533. /**
  54534. * The strenth of the updraft.
  54535. */
  54536. strength: number;
  54537. /**
  54538. * The height of the cylinder for the updraft.
  54539. */
  54540. height: number;
  54541. /**
  54542. * The mode for the the updraft.
  54543. */
  54544. updraftMode: PhysicsUpdraftMode;
  54545. }
  54546. /**
  54547. * Options fot the vortex event
  54548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54549. */
  54550. export class PhysicsVortexEventOptions {
  54551. /**
  54552. * The radius of the cylinder for the vortex
  54553. */
  54554. radius: number;
  54555. /**
  54556. * The strenth of the vortex.
  54557. */
  54558. strength: number;
  54559. /**
  54560. * The height of the cylinder for the vortex.
  54561. */
  54562. height: number;
  54563. /**
  54564. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54565. */
  54566. centripetalForceThreshold: number;
  54567. /**
  54568. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54569. */
  54570. centripetalForceMultiplier: number;
  54571. /**
  54572. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54573. */
  54574. centrifugalForceMultiplier: number;
  54575. /**
  54576. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54577. */
  54578. updraftForceMultiplier: number;
  54579. }
  54580. /**
  54581. * The strenght of the force in correspondence to the distance of the affected object
  54582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54583. */
  54584. export enum PhysicsRadialImpulseFalloff {
  54585. /** Defines that impulse is constant in strength across it's whole radius */
  54586. Constant = 0,
  54587. /** Defines that impulse gets weaker if it's further from the origin */
  54588. Linear = 1
  54589. }
  54590. /**
  54591. * The strength of the force in correspondence to the distance of the affected object
  54592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54593. */
  54594. export enum PhysicsUpdraftMode {
  54595. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54596. Center = 0,
  54597. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54598. Perpendicular = 1
  54599. }
  54600. /**
  54601. * Interface for a physics hit data
  54602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54603. */
  54604. export interface PhysicsHitData {
  54605. /**
  54606. * The force applied at the contact point
  54607. */
  54608. force: Vector3;
  54609. /**
  54610. * The contact point
  54611. */
  54612. contactPoint: Vector3;
  54613. /**
  54614. * The distance from the origin to the contact point
  54615. */
  54616. distanceFromOrigin: number;
  54617. }
  54618. /**
  54619. * Interface for radial explosion event data
  54620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54621. */
  54622. export interface PhysicsRadialExplosionEventData {
  54623. /**
  54624. * A sphere used for the radial explosion event
  54625. */
  54626. sphere: Mesh;
  54627. }
  54628. /**
  54629. * Interface for gravitational field event data
  54630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54631. */
  54632. export interface PhysicsGravitationalFieldEventData {
  54633. /**
  54634. * A sphere mesh used for the gravitational field event
  54635. */
  54636. sphere: Mesh;
  54637. }
  54638. /**
  54639. * Interface for updraft event data
  54640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54641. */
  54642. export interface PhysicsUpdraftEventData {
  54643. /**
  54644. * A cylinder used for the updraft event
  54645. */
  54646. cylinder: Mesh;
  54647. }
  54648. /**
  54649. * Interface for vortex event data
  54650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54651. */
  54652. export interface PhysicsVortexEventData {
  54653. /**
  54654. * A cylinder used for the vortex event
  54655. */
  54656. cylinder: Mesh;
  54657. }
  54658. /**
  54659. * Interface for an affected physics impostor
  54660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54661. */
  54662. export interface PhysicsAffectedImpostorWithData {
  54663. /**
  54664. * The impostor affected by the effect
  54665. */
  54666. impostor: PhysicsImpostor;
  54667. /**
  54668. * The data about the hit/horce from the explosion
  54669. */
  54670. hitData: PhysicsHitData;
  54671. }
  54672. }
  54673. declare module "babylonjs/Physics/Plugins/index" {
  54674. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54675. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54676. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54677. }
  54678. declare module "babylonjs/Physics/index" {
  54679. export * from "babylonjs/Physics/IPhysicsEngine";
  54680. export * from "babylonjs/Physics/physicsEngine";
  54681. export * from "babylonjs/Physics/physicsEngineComponent";
  54682. export * from "babylonjs/Physics/physicsHelper";
  54683. export * from "babylonjs/Physics/physicsImpostor";
  54684. export * from "babylonjs/Physics/physicsJoint";
  54685. export * from "babylonjs/Physics/Plugins/index";
  54686. }
  54687. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54688. /** @hidden */
  54689. export var blackAndWhitePixelShader: {
  54690. name: string;
  54691. shader: string;
  54692. };
  54693. }
  54694. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54695. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54696. import { Camera } from "babylonjs/Cameras/camera";
  54697. import { Engine } from "babylonjs/Engines/engine";
  54698. import "babylonjs/Shaders/blackAndWhite.fragment";
  54699. /**
  54700. * Post process used to render in black and white
  54701. */
  54702. export class BlackAndWhitePostProcess extends PostProcess {
  54703. /**
  54704. * Linear about to convert he result to black and white (default: 1)
  54705. */
  54706. degree: number;
  54707. /**
  54708. * Creates a black and white post process
  54709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54710. * @param name The name of the effect.
  54711. * @param options The required width/height ratio to downsize to before computing the render pass.
  54712. * @param camera The camera to apply the render pass to.
  54713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54714. * @param engine The engine which the post process will be applied. (default: current engine)
  54715. * @param reusable If the post process can be reused on the same frame. (default: false)
  54716. */
  54717. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54718. }
  54719. }
  54720. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54721. import { Nullable } from "babylonjs/types";
  54722. import { Camera } from "babylonjs/Cameras/camera";
  54723. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54724. import { Engine } from "babylonjs/Engines/engine";
  54725. /**
  54726. * This represents a set of one or more post processes in Babylon.
  54727. * A post process can be used to apply a shader to a texture after it is rendered.
  54728. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54729. */
  54730. export class PostProcessRenderEffect {
  54731. private _postProcesses;
  54732. private _getPostProcesses;
  54733. private _singleInstance;
  54734. private _cameras;
  54735. private _indicesForCamera;
  54736. /**
  54737. * Name of the effect
  54738. * @hidden
  54739. */
  54740. _name: string;
  54741. /**
  54742. * Instantiates a post process render effect.
  54743. * A post process can be used to apply a shader to a texture after it is rendered.
  54744. * @param engine The engine the effect is tied to
  54745. * @param name The name of the effect
  54746. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54747. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54748. */
  54749. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54750. /**
  54751. * Checks if all the post processes in the effect are supported.
  54752. */
  54753. readonly isSupported: boolean;
  54754. /**
  54755. * Updates the current state of the effect
  54756. * @hidden
  54757. */
  54758. _update(): void;
  54759. /**
  54760. * Attaches the effect on cameras
  54761. * @param cameras The camera to attach to.
  54762. * @hidden
  54763. */
  54764. _attachCameras(cameras: Camera): void;
  54765. /**
  54766. * Attaches the effect on cameras
  54767. * @param cameras The camera to attach to.
  54768. * @hidden
  54769. */
  54770. _attachCameras(cameras: Camera[]): void;
  54771. /**
  54772. * Detaches the effect on cameras
  54773. * @param cameras The camera to detatch from.
  54774. * @hidden
  54775. */
  54776. _detachCameras(cameras: Camera): void;
  54777. /**
  54778. * Detatches the effect on cameras
  54779. * @param cameras The camera to detatch from.
  54780. * @hidden
  54781. */
  54782. _detachCameras(cameras: Camera[]): void;
  54783. /**
  54784. * Enables the effect on given cameras
  54785. * @param cameras The camera to enable.
  54786. * @hidden
  54787. */
  54788. _enable(cameras: Camera): void;
  54789. /**
  54790. * Enables the effect on given cameras
  54791. * @param cameras The camera to enable.
  54792. * @hidden
  54793. */
  54794. _enable(cameras: Nullable<Camera[]>): void;
  54795. /**
  54796. * Disables the effect on the given cameras
  54797. * @param cameras The camera to disable.
  54798. * @hidden
  54799. */
  54800. _disable(cameras: Camera): void;
  54801. /**
  54802. * Disables the effect on the given cameras
  54803. * @param cameras The camera to disable.
  54804. * @hidden
  54805. */
  54806. _disable(cameras: Nullable<Camera[]>): void;
  54807. /**
  54808. * Gets a list of the post processes contained in the effect.
  54809. * @param camera The camera to get the post processes on.
  54810. * @returns The list of the post processes in the effect.
  54811. */
  54812. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54813. }
  54814. }
  54815. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54816. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54817. /** @hidden */
  54818. export var extractHighlightsPixelShader: {
  54819. name: string;
  54820. shader: string;
  54821. };
  54822. }
  54823. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54824. import { Nullable } from "babylonjs/types";
  54825. import { Camera } from "babylonjs/Cameras/camera";
  54826. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54827. import { Engine } from "babylonjs/Engines/engine";
  54828. import "babylonjs/Shaders/extractHighlights.fragment";
  54829. /**
  54830. * 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.
  54831. */
  54832. export class ExtractHighlightsPostProcess extends PostProcess {
  54833. /**
  54834. * The luminance threshold, pixels below this value will be set to black.
  54835. */
  54836. threshold: number;
  54837. /** @hidden */
  54838. _exposure: number;
  54839. /**
  54840. * Post process which has the input texture to be used when performing highlight extraction
  54841. * @hidden
  54842. */
  54843. _inputPostProcess: Nullable<PostProcess>;
  54844. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54845. }
  54846. }
  54847. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54848. /** @hidden */
  54849. export var bloomMergePixelShader: {
  54850. name: string;
  54851. shader: string;
  54852. };
  54853. }
  54854. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54855. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54856. import { Nullable } from "babylonjs/types";
  54857. import { Engine } from "babylonjs/Engines/engine";
  54858. import { Camera } from "babylonjs/Cameras/camera";
  54859. import "babylonjs/Shaders/bloomMerge.fragment";
  54860. /**
  54861. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54862. */
  54863. export class BloomMergePostProcess extends PostProcess {
  54864. /** Weight of the bloom to be added to the original input. */
  54865. weight: number;
  54866. /**
  54867. * Creates a new instance of @see BloomMergePostProcess
  54868. * @param name The name of the effect.
  54869. * @param originalFromInput Post process which's input will be used for the merge.
  54870. * @param blurred Blurred highlights post process which's output will be used.
  54871. * @param weight Weight of the bloom to be added to the original input.
  54872. * @param options The required width/height ratio to downsize to before computing the render pass.
  54873. * @param camera The camera to apply the render pass to.
  54874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54875. * @param engine The engine which the post process will be applied. (default: current engine)
  54876. * @param reusable If the post process can be reused on the same frame. (default: false)
  54877. * @param textureType Type of textures used when performing the post process. (default: 0)
  54878. * @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)
  54879. */
  54880. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54881. /** Weight of the bloom to be added to the original input. */
  54882. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54883. }
  54884. }
  54885. declare module "babylonjs/PostProcesses/bloomEffect" {
  54886. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54888. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54889. import { Camera } from "babylonjs/Cameras/camera";
  54890. import { Scene } from "babylonjs/scene";
  54891. /**
  54892. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54893. */
  54894. export class BloomEffect extends PostProcessRenderEffect {
  54895. private bloomScale;
  54896. /**
  54897. * @hidden Internal
  54898. */
  54899. _effects: Array<PostProcess>;
  54900. /**
  54901. * @hidden Internal
  54902. */
  54903. _downscale: ExtractHighlightsPostProcess;
  54904. private _blurX;
  54905. private _blurY;
  54906. private _merge;
  54907. /**
  54908. * The luminance threshold to find bright areas of the image to bloom.
  54909. */
  54910. threshold: number;
  54911. /**
  54912. * The strength of the bloom.
  54913. */
  54914. weight: number;
  54915. /**
  54916. * Specifies the size of the bloom blur kernel, relative to the final output size
  54917. */
  54918. kernel: number;
  54919. /**
  54920. * Creates a new instance of @see BloomEffect
  54921. * @param scene The scene the effect belongs to.
  54922. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54923. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54924. * @param bloomWeight The the strength of bloom.
  54925. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54926. * @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)
  54927. */
  54928. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54929. /**
  54930. * Disposes each of the internal effects for a given camera.
  54931. * @param camera The camera to dispose the effect on.
  54932. */
  54933. disposeEffects(camera: Camera): void;
  54934. /**
  54935. * @hidden Internal
  54936. */
  54937. _updateEffects(): void;
  54938. /**
  54939. * Internal
  54940. * @returns if all the contained post processes are ready.
  54941. * @hidden
  54942. */
  54943. _isReady(): boolean;
  54944. }
  54945. }
  54946. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54947. /** @hidden */
  54948. export var chromaticAberrationPixelShader: {
  54949. name: string;
  54950. shader: string;
  54951. };
  54952. }
  54953. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54954. import { Vector2 } from "babylonjs/Maths/math";
  54955. import { Nullable } from "babylonjs/types";
  54956. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54957. import { Camera } from "babylonjs/Cameras/camera";
  54958. import { Engine } from "babylonjs/Engines/engine";
  54959. import "babylonjs/Shaders/chromaticAberration.fragment";
  54960. /**
  54961. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54962. */
  54963. export class ChromaticAberrationPostProcess extends PostProcess {
  54964. /**
  54965. * The amount of seperation of rgb channels (default: 30)
  54966. */
  54967. aberrationAmount: number;
  54968. /**
  54969. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54970. */
  54971. radialIntensity: number;
  54972. /**
  54973. * 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))
  54974. */
  54975. direction: Vector2;
  54976. /**
  54977. * 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))
  54978. */
  54979. centerPosition: Vector2;
  54980. /**
  54981. * Creates a new instance ChromaticAberrationPostProcess
  54982. * @param name The name of the effect.
  54983. * @param screenWidth The width of the screen to apply the effect on.
  54984. * @param screenHeight The height of the screen to apply the effect on.
  54985. * @param options The required width/height ratio to downsize to before computing the render pass.
  54986. * @param camera The camera to apply the render pass to.
  54987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54988. * @param engine The engine which the post process will be applied. (default: current engine)
  54989. * @param reusable If the post process can be reused on the same frame. (default: false)
  54990. * @param textureType Type of textures used when performing the post process. (default: 0)
  54991. * @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)
  54992. */
  54993. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54994. }
  54995. }
  54996. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54997. /** @hidden */
  54998. export var circleOfConfusionPixelShader: {
  54999. name: string;
  55000. shader: string;
  55001. };
  55002. }
  55003. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  55004. import { Nullable } from "babylonjs/types";
  55005. import { Engine } from "babylonjs/Engines/engine";
  55006. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55008. import { Camera } from "babylonjs/Cameras/camera";
  55009. import "babylonjs/Shaders/circleOfConfusion.fragment";
  55010. /**
  55011. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55012. */
  55013. export class CircleOfConfusionPostProcess extends PostProcess {
  55014. /**
  55015. * 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.
  55016. */
  55017. lensSize: number;
  55018. /**
  55019. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55020. */
  55021. fStop: number;
  55022. /**
  55023. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55024. */
  55025. focusDistance: number;
  55026. /**
  55027. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55028. */
  55029. focalLength: number;
  55030. private _depthTexture;
  55031. /**
  55032. * Creates a new instance CircleOfConfusionPostProcess
  55033. * @param name The name of the effect.
  55034. * @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.
  55035. * @param options The required width/height ratio to downsize to before computing the render pass.
  55036. * @param camera The camera to apply the render pass to.
  55037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55038. * @param engine The engine which the post process will be applied. (default: current engine)
  55039. * @param reusable If the post process can be reused on the same frame. (default: false)
  55040. * @param textureType Type of textures used when performing the post process. (default: 0)
  55041. * @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)
  55042. */
  55043. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55044. /**
  55045. * 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.
  55046. */
  55047. depthTexture: RenderTargetTexture;
  55048. }
  55049. }
  55050. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55051. /** @hidden */
  55052. export var colorCorrectionPixelShader: {
  55053. name: string;
  55054. shader: string;
  55055. };
  55056. }
  55057. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55058. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55059. import { Engine } from "babylonjs/Engines/engine";
  55060. import { Camera } from "babylonjs/Cameras/camera";
  55061. import "babylonjs/Shaders/colorCorrection.fragment";
  55062. /**
  55063. *
  55064. * This post-process allows the modification of rendered colors by using
  55065. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55066. *
  55067. * The object needs to be provided an url to a texture containing the color
  55068. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55069. * Use an image editing software to tweak the LUT to match your needs.
  55070. *
  55071. * For an example of a color LUT, see here:
  55072. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55073. * For explanations on color grading, see here:
  55074. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55075. *
  55076. */
  55077. export class ColorCorrectionPostProcess extends PostProcess {
  55078. private _colorTableTexture;
  55079. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55080. }
  55081. }
  55082. declare module "babylonjs/Shaders/convolution.fragment" {
  55083. /** @hidden */
  55084. export var convolutionPixelShader: {
  55085. name: string;
  55086. shader: string;
  55087. };
  55088. }
  55089. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55090. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55091. import { Nullable } from "babylonjs/types";
  55092. import { Camera } from "babylonjs/Cameras/camera";
  55093. import { Engine } from "babylonjs/Engines/engine";
  55094. import "babylonjs/Shaders/convolution.fragment";
  55095. /**
  55096. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55097. * input texture to perform effects such as edge detection or sharpening
  55098. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55099. */
  55100. export class ConvolutionPostProcess extends PostProcess {
  55101. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55102. kernel: number[];
  55103. /**
  55104. * Creates a new instance ConvolutionPostProcess
  55105. * @param name The name of the effect.
  55106. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55107. * @param options The required width/height ratio to downsize to before computing the render pass.
  55108. * @param camera The camera to apply the render pass to.
  55109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55110. * @param engine The engine which the post process will be applied. (default: current engine)
  55111. * @param reusable If the post process can be reused on the same frame. (default: false)
  55112. * @param textureType Type of textures used when performing the post process. (default: 0)
  55113. */
  55114. constructor(name: string,
  55115. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55116. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55117. /**
  55118. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55119. */
  55120. static EdgeDetect0Kernel: number[];
  55121. /**
  55122. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55123. */
  55124. static EdgeDetect1Kernel: number[];
  55125. /**
  55126. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55127. */
  55128. static EdgeDetect2Kernel: number[];
  55129. /**
  55130. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55131. */
  55132. static SharpenKernel: number[];
  55133. /**
  55134. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55135. */
  55136. static EmbossKernel: number[];
  55137. /**
  55138. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55139. */
  55140. static GaussianKernel: number[];
  55141. }
  55142. }
  55143. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55144. import { Nullable } from "babylonjs/types";
  55145. import { Vector2 } from "babylonjs/Maths/math";
  55146. import { Camera } from "babylonjs/Cameras/camera";
  55147. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55148. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55149. import { Engine } from "babylonjs/Engines/engine";
  55150. import { Scene } from "babylonjs/scene";
  55151. /**
  55152. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55153. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55154. * based on samples that have a large difference in distance than the center pixel.
  55155. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55156. */
  55157. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55158. direction: Vector2;
  55159. /**
  55160. * Creates a new instance CircleOfConfusionPostProcess
  55161. * @param name The name of the effect.
  55162. * @param scene The scene the effect belongs to.
  55163. * @param direction The direction the blur should be applied.
  55164. * @param kernel The size of the kernel used to blur.
  55165. * @param options The required width/height ratio to downsize to before computing the render pass.
  55166. * @param camera The camera to apply the render pass to.
  55167. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55168. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55170. * @param engine The engine which the post process will be applied. (default: current engine)
  55171. * @param reusable If the post process can be reused on the same frame. (default: false)
  55172. * @param textureType Type of textures used when performing the post process. (default: 0)
  55173. * @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)
  55174. */
  55175. 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);
  55176. }
  55177. }
  55178. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55179. /** @hidden */
  55180. export var depthOfFieldMergePixelShader: {
  55181. name: string;
  55182. shader: string;
  55183. };
  55184. }
  55185. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55186. import { Nullable } from "babylonjs/types";
  55187. import { Camera } from "babylonjs/Cameras/camera";
  55188. import { Effect } from "babylonjs/Materials/effect";
  55189. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55190. import { Engine } from "babylonjs/Engines/engine";
  55191. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55192. /**
  55193. * Options to be set when merging outputs from the default pipeline.
  55194. */
  55195. export class DepthOfFieldMergePostProcessOptions {
  55196. /**
  55197. * The original image to merge on top of
  55198. */
  55199. originalFromInput: PostProcess;
  55200. /**
  55201. * Parameters to perform the merge of the depth of field effect
  55202. */
  55203. depthOfField?: {
  55204. circleOfConfusion: PostProcess;
  55205. blurSteps: Array<PostProcess>;
  55206. };
  55207. /**
  55208. * Parameters to perform the merge of bloom effect
  55209. */
  55210. bloom?: {
  55211. blurred: PostProcess;
  55212. weight: number;
  55213. };
  55214. }
  55215. /**
  55216. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55217. */
  55218. export class DepthOfFieldMergePostProcess extends PostProcess {
  55219. private blurSteps;
  55220. /**
  55221. * Creates a new instance of DepthOfFieldMergePostProcess
  55222. * @param name The name of the effect.
  55223. * @param originalFromInput Post process which's input will be used for the merge.
  55224. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55225. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55226. * @param options The required width/height ratio to downsize to before computing the render pass.
  55227. * @param camera The camera to apply the render pass to.
  55228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55229. * @param engine The engine which the post process will be applied. (default: current engine)
  55230. * @param reusable If the post process can be reused on the same frame. (default: false)
  55231. * @param textureType Type of textures used when performing the post process. (default: 0)
  55232. * @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)
  55233. */
  55234. 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);
  55235. /**
  55236. * Updates the effect with the current post process compile time values and recompiles the shader.
  55237. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55238. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55239. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55240. * @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
  55241. * @param onCompiled Called when the shader has been compiled.
  55242. * @param onError Called if there is an error when compiling a shader.
  55243. */
  55244. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55245. }
  55246. }
  55247. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55248. import { Nullable } from "babylonjs/types";
  55249. import { Camera } from "babylonjs/Cameras/camera";
  55250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55251. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55252. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55253. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55254. import { Scene } from "babylonjs/scene";
  55255. /**
  55256. * Specifies the level of max blur that should be applied when using the depth of field effect
  55257. */
  55258. export enum DepthOfFieldEffectBlurLevel {
  55259. /**
  55260. * Subtle blur
  55261. */
  55262. Low = 0,
  55263. /**
  55264. * Medium blur
  55265. */
  55266. Medium = 1,
  55267. /**
  55268. * Large blur
  55269. */
  55270. High = 2
  55271. }
  55272. /**
  55273. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55274. */
  55275. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55276. private _circleOfConfusion;
  55277. /**
  55278. * @hidden Internal, blurs from high to low
  55279. */
  55280. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55281. private _depthOfFieldBlurY;
  55282. private _dofMerge;
  55283. /**
  55284. * @hidden Internal post processes in depth of field effect
  55285. */
  55286. _effects: Array<PostProcess>;
  55287. /**
  55288. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55289. */
  55290. focalLength: number;
  55291. /**
  55292. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55293. */
  55294. fStop: number;
  55295. /**
  55296. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55297. */
  55298. focusDistance: number;
  55299. /**
  55300. * 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.
  55301. */
  55302. lensSize: number;
  55303. /**
  55304. * Creates a new instance DepthOfFieldEffect
  55305. * @param scene The scene the effect belongs to.
  55306. * @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.
  55307. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55308. * @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)
  55309. */
  55310. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55311. /**
  55312. * Get the current class name of the current effet
  55313. * @returns "DepthOfFieldEffect"
  55314. */
  55315. getClassName(): string;
  55316. /**
  55317. * 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.
  55318. */
  55319. depthTexture: RenderTargetTexture;
  55320. /**
  55321. * Disposes each of the internal effects for a given camera.
  55322. * @param camera The camera to dispose the effect on.
  55323. */
  55324. disposeEffects(camera: Camera): void;
  55325. /**
  55326. * @hidden Internal
  55327. */
  55328. _updateEffects(): void;
  55329. /**
  55330. * Internal
  55331. * @returns if all the contained post processes are ready.
  55332. * @hidden
  55333. */
  55334. _isReady(): boolean;
  55335. }
  55336. }
  55337. declare module "babylonjs/Shaders/displayPass.fragment" {
  55338. /** @hidden */
  55339. export var displayPassPixelShader: {
  55340. name: string;
  55341. shader: string;
  55342. };
  55343. }
  55344. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55345. import { Nullable } from "babylonjs/types";
  55346. import { Camera } from "babylonjs/Cameras/camera";
  55347. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55348. import { Engine } from "babylonjs/Engines/engine";
  55349. import "babylonjs/Shaders/displayPass.fragment";
  55350. /**
  55351. * DisplayPassPostProcess which produces an output the same as it's input
  55352. */
  55353. export class DisplayPassPostProcess extends PostProcess {
  55354. /**
  55355. * Creates the DisplayPassPostProcess
  55356. * @param name The name of the effect.
  55357. * @param options The required width/height ratio to downsize to before computing the render pass.
  55358. * @param camera The camera to apply the render pass to.
  55359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55360. * @param engine The engine which the post process will be applied. (default: current engine)
  55361. * @param reusable If the post process can be reused on the same frame. (default: false)
  55362. */
  55363. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55364. }
  55365. }
  55366. declare module "babylonjs/Shaders/filter.fragment" {
  55367. /** @hidden */
  55368. export var filterPixelShader: {
  55369. name: string;
  55370. shader: string;
  55371. };
  55372. }
  55373. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55374. import { Nullable } from "babylonjs/types";
  55375. import { Matrix } from "babylonjs/Maths/math";
  55376. import { Camera } from "babylonjs/Cameras/camera";
  55377. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55378. import { Engine } from "babylonjs/Engines/engine";
  55379. import "babylonjs/Shaders/filter.fragment";
  55380. /**
  55381. * Applies a kernel filter to the image
  55382. */
  55383. export class FilterPostProcess extends PostProcess {
  55384. /** The matrix to be applied to the image */
  55385. kernelMatrix: Matrix;
  55386. /**
  55387. *
  55388. * @param name The name of the effect.
  55389. * @param kernelMatrix The matrix to be applied to the image
  55390. * @param options The required width/height ratio to downsize to before computing the render pass.
  55391. * @param camera The camera to apply the render pass to.
  55392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55393. * @param engine The engine which the post process will be applied. (default: current engine)
  55394. * @param reusable If the post process can be reused on the same frame. (default: false)
  55395. */
  55396. constructor(name: string,
  55397. /** The matrix to be applied to the image */
  55398. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55399. }
  55400. }
  55401. declare module "babylonjs/Shaders/fxaa.fragment" {
  55402. /** @hidden */
  55403. export var fxaaPixelShader: {
  55404. name: string;
  55405. shader: string;
  55406. };
  55407. }
  55408. declare module "babylonjs/Shaders/fxaa.vertex" {
  55409. /** @hidden */
  55410. export var fxaaVertexShader: {
  55411. name: string;
  55412. shader: string;
  55413. };
  55414. }
  55415. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55416. import { Nullable } from "babylonjs/types";
  55417. import { Camera } from "babylonjs/Cameras/camera";
  55418. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55419. import { Engine } from "babylonjs/Engines/engine";
  55420. import "babylonjs/Shaders/fxaa.fragment";
  55421. import "babylonjs/Shaders/fxaa.vertex";
  55422. /**
  55423. * Fxaa post process
  55424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55425. */
  55426. export class FxaaPostProcess extends PostProcess {
  55427. /** @hidden */
  55428. texelWidth: number;
  55429. /** @hidden */
  55430. texelHeight: number;
  55431. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55432. private _getDefines;
  55433. }
  55434. }
  55435. declare module "babylonjs/Shaders/grain.fragment" {
  55436. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55437. /** @hidden */
  55438. export var grainPixelShader: {
  55439. name: string;
  55440. shader: string;
  55441. };
  55442. }
  55443. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55444. import { Nullable } from "babylonjs/types";
  55445. import { Camera } from "babylonjs/Cameras/camera";
  55446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55447. import { Engine } from "babylonjs/Engines/engine";
  55448. import "babylonjs/Shaders/grain.fragment";
  55449. /**
  55450. * The GrainPostProcess adds noise to the image at mid luminance levels
  55451. */
  55452. export class GrainPostProcess extends PostProcess {
  55453. /**
  55454. * The intensity of the grain added (default: 30)
  55455. */
  55456. intensity: number;
  55457. /**
  55458. * If the grain should be randomized on every frame
  55459. */
  55460. animated: boolean;
  55461. /**
  55462. * Creates a new instance of @see GrainPostProcess
  55463. * @param name The name of the effect.
  55464. * @param options The required width/height ratio to downsize to before computing the render pass.
  55465. * @param camera The camera to apply the render pass to.
  55466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55467. * @param engine The engine which the post process will be applied. (default: current engine)
  55468. * @param reusable If the post process can be reused on the same frame. (default: false)
  55469. * @param textureType Type of textures used when performing the post process. (default: 0)
  55470. * @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)
  55471. */
  55472. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55473. }
  55474. }
  55475. declare module "babylonjs/Shaders/highlights.fragment" {
  55476. /** @hidden */
  55477. export var highlightsPixelShader: {
  55478. name: string;
  55479. shader: string;
  55480. };
  55481. }
  55482. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55483. import { Nullable } from "babylonjs/types";
  55484. import { Camera } from "babylonjs/Cameras/camera";
  55485. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55486. import { Engine } from "babylonjs/Engines/engine";
  55487. import "babylonjs/Shaders/highlights.fragment";
  55488. /**
  55489. * Extracts highlights from the image
  55490. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55491. */
  55492. export class HighlightsPostProcess extends PostProcess {
  55493. /**
  55494. * Extracts highlights from the image
  55495. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55496. * @param name The name of the effect.
  55497. * @param options The required width/height ratio to downsize to before computing the render pass.
  55498. * @param camera The camera to apply the render pass to.
  55499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55500. * @param engine The engine which the post process will be applied. (default: current engine)
  55501. * @param reusable If the post process can be reused on the same frame. (default: false)
  55502. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55503. */
  55504. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55505. }
  55506. }
  55507. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55508. /** @hidden */
  55509. export var mrtFragmentDeclaration: {
  55510. name: string;
  55511. shader: string;
  55512. };
  55513. }
  55514. declare module "babylonjs/Shaders/geometry.fragment" {
  55515. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55516. /** @hidden */
  55517. export var geometryPixelShader: {
  55518. name: string;
  55519. shader: string;
  55520. };
  55521. }
  55522. declare module "babylonjs/Shaders/geometry.vertex" {
  55523. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55524. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55525. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55526. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55527. /** @hidden */
  55528. export var geometryVertexShader: {
  55529. name: string;
  55530. shader: string;
  55531. };
  55532. }
  55533. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55534. import { Matrix } from "babylonjs/Maths/math";
  55535. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55536. import { Mesh } from "babylonjs/Meshes/mesh";
  55537. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55538. import { Effect } from "babylonjs/Materials/effect";
  55539. import { Scene } from "babylonjs/scene";
  55540. import "babylonjs/Shaders/geometry.fragment";
  55541. import "babylonjs/Shaders/geometry.vertex";
  55542. /**
  55543. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55544. */
  55545. export class GeometryBufferRenderer {
  55546. /**
  55547. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55548. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55549. */
  55550. static readonly POSITION_TEXTURE_TYPE: number;
  55551. /**
  55552. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55553. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55554. */
  55555. static readonly VELOCITY_TEXTURE_TYPE: number;
  55556. /**
  55557. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55558. * in order to compute objects velocities when enableVelocity is set to "true"
  55559. * @hidden
  55560. */
  55561. _previousTransformationMatrices: {
  55562. [index: number]: Matrix;
  55563. };
  55564. private _scene;
  55565. private _multiRenderTarget;
  55566. private _ratio;
  55567. private _enablePosition;
  55568. private _enableVelocity;
  55569. private _positionIndex;
  55570. private _velocityIndex;
  55571. protected _effect: Effect;
  55572. protected _cachedDefines: string;
  55573. /**
  55574. * Set the render list (meshes to be rendered) used in the G buffer.
  55575. */
  55576. renderList: Mesh[];
  55577. /**
  55578. * Gets wether or not G buffer are supported by the running hardware.
  55579. * This requires draw buffer supports
  55580. */
  55581. readonly isSupported: boolean;
  55582. /**
  55583. * Returns the index of the given texture type in the G-Buffer textures array
  55584. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55585. * @returns the index of the given texture type in the G-Buffer textures array
  55586. */
  55587. getTextureIndex(textureType: number): number;
  55588. /**
  55589. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55590. */
  55591. /**
  55592. * Sets whether or not objects positions are enabled for the G buffer.
  55593. */
  55594. enablePosition: boolean;
  55595. /**
  55596. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55597. */
  55598. /**
  55599. * Sets wether or not objects velocities are enabled for the G buffer.
  55600. */
  55601. enableVelocity: boolean;
  55602. /**
  55603. * Gets the scene associated with the buffer.
  55604. */
  55605. readonly scene: Scene;
  55606. /**
  55607. * Gets the ratio used by the buffer during its creation.
  55608. * How big is the buffer related to the main canvas.
  55609. */
  55610. readonly ratio: number;
  55611. /** @hidden */
  55612. static _SceneComponentInitialization: (scene: Scene) => void;
  55613. /**
  55614. * Creates a new G Buffer for the scene
  55615. * @param scene The scene the buffer belongs to
  55616. * @param ratio How big is the buffer related to the main canvas.
  55617. */
  55618. constructor(scene: Scene, ratio?: number);
  55619. /**
  55620. * Checks wether everything is ready to render a submesh to the G buffer.
  55621. * @param subMesh the submesh to check readiness for
  55622. * @param useInstances is the mesh drawn using instance or not
  55623. * @returns true if ready otherwise false
  55624. */
  55625. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55626. /**
  55627. * Gets the current underlying G Buffer.
  55628. * @returns the buffer
  55629. */
  55630. getGBuffer(): MultiRenderTarget;
  55631. /**
  55632. * Gets the number of samples used to render the buffer (anti aliasing).
  55633. */
  55634. /**
  55635. * Sets the number of samples used to render the buffer (anti aliasing).
  55636. */
  55637. samples: number;
  55638. /**
  55639. * Disposes the renderer and frees up associated resources.
  55640. */
  55641. dispose(): void;
  55642. protected _createRenderTargets(): void;
  55643. }
  55644. }
  55645. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55646. import { Nullable } from "babylonjs/types";
  55647. import { Scene } from "babylonjs/scene";
  55648. import { ISceneComponent } from "babylonjs/sceneComponent";
  55649. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55650. module "babylonjs/scene" {
  55651. interface Scene {
  55652. /** @hidden (Backing field) */
  55653. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55654. /**
  55655. * Gets or Sets the current geometry buffer associated to the scene.
  55656. */
  55657. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55658. /**
  55659. * Enables a GeometryBufferRender and associates it with the scene
  55660. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55661. * @returns the GeometryBufferRenderer
  55662. */
  55663. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55664. /**
  55665. * Disables the GeometryBufferRender associated with the scene
  55666. */
  55667. disableGeometryBufferRenderer(): void;
  55668. }
  55669. }
  55670. /**
  55671. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55672. * in several rendering techniques.
  55673. */
  55674. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55675. /**
  55676. * The component name helpful to identify the component in the list of scene components.
  55677. */
  55678. readonly name: string;
  55679. /**
  55680. * The scene the component belongs to.
  55681. */
  55682. scene: Scene;
  55683. /**
  55684. * Creates a new instance of the component for the given scene
  55685. * @param scene Defines the scene to register the component in
  55686. */
  55687. constructor(scene: Scene);
  55688. /**
  55689. * Registers the component in a given scene
  55690. */
  55691. register(): void;
  55692. /**
  55693. * Rebuilds the elements related to this component in case of
  55694. * context lost for instance.
  55695. */
  55696. rebuild(): void;
  55697. /**
  55698. * Disposes the component and the associated ressources
  55699. */
  55700. dispose(): void;
  55701. private _gatherRenderTargets;
  55702. }
  55703. }
  55704. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55705. /** @hidden */
  55706. export var motionBlurPixelShader: {
  55707. name: string;
  55708. shader: string;
  55709. };
  55710. }
  55711. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55712. import { Nullable } from "babylonjs/types";
  55713. import { Camera } from "babylonjs/Cameras/camera";
  55714. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55715. import { Scene } from "babylonjs/scene";
  55716. import "babylonjs/Animations/animatable";
  55717. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55718. import "babylonjs/Shaders/motionBlur.fragment";
  55719. import { Engine } from "babylonjs/Engines/engine";
  55720. /**
  55721. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55722. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55723. * As an example, all you have to do is to create the post-process:
  55724. * var mb = new BABYLON.MotionBlurPostProcess(
  55725. * 'mb', // The name of the effect.
  55726. * scene, // The scene containing the objects to blur according to their velocity.
  55727. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55728. * camera // The camera to apply the render pass to.
  55729. * );
  55730. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55731. */
  55732. export class MotionBlurPostProcess extends PostProcess {
  55733. /**
  55734. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55735. */
  55736. motionStrength: number;
  55737. /**
  55738. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55739. */
  55740. /**
  55741. * Sets the number of iterations to be used for motion blur quality
  55742. */
  55743. motionBlurSamples: number;
  55744. private _motionBlurSamples;
  55745. private _geometryBufferRenderer;
  55746. /**
  55747. * Creates a new instance MotionBlurPostProcess
  55748. * @param name The name of the effect.
  55749. * @param scene The scene containing the objects to blur according to their velocity.
  55750. * @param options The required width/height ratio to downsize to before computing the render pass.
  55751. * @param camera The camera to apply the render pass to.
  55752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55753. * @param engine The engine which the post process will be applied. (default: current engine)
  55754. * @param reusable If the post process can be reused on the same frame. (default: false)
  55755. * @param textureType Type of textures used when performing the post process. (default: 0)
  55756. * @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)
  55757. */
  55758. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55759. /**
  55760. * Disposes the post process.
  55761. * @param camera The camera to dispose the post process on.
  55762. */
  55763. dispose(camera?: Camera): void;
  55764. }
  55765. }
  55766. declare module "babylonjs/Shaders/refraction.fragment" {
  55767. /** @hidden */
  55768. export var refractionPixelShader: {
  55769. name: string;
  55770. shader: string;
  55771. };
  55772. }
  55773. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55774. import { Color3 } from "babylonjs/Maths/math";
  55775. import { Camera } from "babylonjs/Cameras/camera";
  55776. import { Texture } from "babylonjs/Materials/Textures/texture";
  55777. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55778. import { Engine } from "babylonjs/Engines/engine";
  55779. import "babylonjs/Shaders/refraction.fragment";
  55780. /**
  55781. * Post process which applies a refractin texture
  55782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55783. */
  55784. export class RefractionPostProcess extends PostProcess {
  55785. /** the base color of the refraction (used to taint the rendering) */
  55786. color: Color3;
  55787. /** simulated refraction depth */
  55788. depth: number;
  55789. /** the coefficient of the base color (0 to remove base color tainting) */
  55790. colorLevel: number;
  55791. private _refTexture;
  55792. private _ownRefractionTexture;
  55793. /**
  55794. * Gets or sets the refraction texture
  55795. * Please note that you are responsible for disposing the texture if you set it manually
  55796. */
  55797. refractionTexture: Texture;
  55798. /**
  55799. * Initializes the RefractionPostProcess
  55800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55801. * @param name The name of the effect.
  55802. * @param refractionTextureUrl Url of the refraction texture to use
  55803. * @param color the base color of the refraction (used to taint the rendering)
  55804. * @param depth simulated refraction depth
  55805. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55806. * @param camera The camera to apply the render pass to.
  55807. * @param options The required width/height ratio to downsize to before computing the render pass.
  55808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55809. * @param engine The engine which the post process will be applied. (default: current engine)
  55810. * @param reusable If the post process can be reused on the same frame. (default: false)
  55811. */
  55812. constructor(name: string, refractionTextureUrl: string,
  55813. /** the base color of the refraction (used to taint the rendering) */
  55814. color: Color3,
  55815. /** simulated refraction depth */
  55816. depth: number,
  55817. /** the coefficient of the base color (0 to remove base color tainting) */
  55818. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55819. /**
  55820. * Disposes of the post process
  55821. * @param camera Camera to dispose post process on
  55822. */
  55823. dispose(camera: Camera): void;
  55824. }
  55825. }
  55826. declare module "babylonjs/Shaders/sharpen.fragment" {
  55827. /** @hidden */
  55828. export var sharpenPixelShader: {
  55829. name: string;
  55830. shader: string;
  55831. };
  55832. }
  55833. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55834. import { Nullable } from "babylonjs/types";
  55835. import { Camera } from "babylonjs/Cameras/camera";
  55836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55837. import "babylonjs/Shaders/sharpen.fragment";
  55838. import { Engine } from "babylonjs/Engines/engine";
  55839. /**
  55840. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55841. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55842. */
  55843. export class SharpenPostProcess extends PostProcess {
  55844. /**
  55845. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55846. */
  55847. colorAmount: number;
  55848. /**
  55849. * How much sharpness should be applied (default: 0.3)
  55850. */
  55851. edgeAmount: number;
  55852. /**
  55853. * Creates a new instance ConvolutionPostProcess
  55854. * @param name The name of the effect.
  55855. * @param options The required width/height ratio to downsize to before computing the render pass.
  55856. * @param camera The camera to apply the render pass to.
  55857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55858. * @param engine The engine which the post process will be applied. (default: current engine)
  55859. * @param reusable If the post process can be reused on the same frame. (default: false)
  55860. * @param textureType Type of textures used when performing the post process. (default: 0)
  55861. * @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)
  55862. */
  55863. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55864. }
  55865. }
  55866. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55867. import { Nullable } from "babylonjs/types";
  55868. import { Camera } from "babylonjs/Cameras/camera";
  55869. import { Engine } from "babylonjs/Engines/engine";
  55870. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55871. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55872. /**
  55873. * PostProcessRenderPipeline
  55874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55875. */
  55876. export class PostProcessRenderPipeline {
  55877. private engine;
  55878. private _renderEffects;
  55879. private _renderEffectsForIsolatedPass;
  55880. /**
  55881. * List of inspectable custom properties (used by the Inspector)
  55882. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55883. */
  55884. inspectableCustomProperties: IInspectable[];
  55885. /**
  55886. * @hidden
  55887. */
  55888. protected _cameras: Camera[];
  55889. /** @hidden */
  55890. _name: string;
  55891. /**
  55892. * Gets pipeline name
  55893. */
  55894. readonly name: string;
  55895. /**
  55896. * Initializes a PostProcessRenderPipeline
  55897. * @param engine engine to add the pipeline to
  55898. * @param name name of the pipeline
  55899. */
  55900. constructor(engine: Engine, name: string);
  55901. /**
  55902. * Gets the class name
  55903. * @returns "PostProcessRenderPipeline"
  55904. */
  55905. getClassName(): string;
  55906. /**
  55907. * If all the render effects in the pipeline are supported
  55908. */
  55909. readonly isSupported: boolean;
  55910. /**
  55911. * Adds an effect to the pipeline
  55912. * @param renderEffect the effect to add
  55913. */
  55914. addEffect(renderEffect: PostProcessRenderEffect): void;
  55915. /** @hidden */
  55916. _rebuild(): void;
  55917. /** @hidden */
  55918. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55919. /** @hidden */
  55920. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55921. /** @hidden */
  55922. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55923. /** @hidden */
  55924. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55925. /** @hidden */
  55926. _attachCameras(cameras: Camera, unique: boolean): void;
  55927. /** @hidden */
  55928. _attachCameras(cameras: Camera[], unique: boolean): void;
  55929. /** @hidden */
  55930. _detachCameras(cameras: Camera): void;
  55931. /** @hidden */
  55932. _detachCameras(cameras: Nullable<Camera[]>): void;
  55933. /** @hidden */
  55934. _update(): void;
  55935. /** @hidden */
  55936. _reset(): void;
  55937. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55938. /**
  55939. * Disposes of the pipeline
  55940. */
  55941. dispose(): void;
  55942. }
  55943. }
  55944. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55945. import { Camera } from "babylonjs/Cameras/camera";
  55946. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55947. /**
  55948. * PostProcessRenderPipelineManager class
  55949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55950. */
  55951. export class PostProcessRenderPipelineManager {
  55952. private _renderPipelines;
  55953. /**
  55954. * Initializes a PostProcessRenderPipelineManager
  55955. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55956. */
  55957. constructor();
  55958. /**
  55959. * Gets the list of supported render pipelines
  55960. */
  55961. readonly supportedPipelines: PostProcessRenderPipeline[];
  55962. /**
  55963. * Adds a pipeline to the manager
  55964. * @param renderPipeline The pipeline to add
  55965. */
  55966. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55967. /**
  55968. * Attaches a camera to the pipeline
  55969. * @param renderPipelineName The name of the pipeline to attach to
  55970. * @param cameras the camera to attach
  55971. * @param unique if the camera can be attached multiple times to the pipeline
  55972. */
  55973. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55974. /**
  55975. * Detaches a camera from the pipeline
  55976. * @param renderPipelineName The name of the pipeline to detach from
  55977. * @param cameras the camera to detach
  55978. */
  55979. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55980. /**
  55981. * Enables an effect by name on a pipeline
  55982. * @param renderPipelineName the name of the pipeline to enable the effect in
  55983. * @param renderEffectName the name of the effect to enable
  55984. * @param cameras the cameras that the effect should be enabled on
  55985. */
  55986. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55987. /**
  55988. * Disables an effect by name on a pipeline
  55989. * @param renderPipelineName the name of the pipeline to disable the effect in
  55990. * @param renderEffectName the name of the effect to disable
  55991. * @param cameras the cameras that the effect should be disabled on
  55992. */
  55993. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55994. /**
  55995. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55996. */
  55997. update(): void;
  55998. /** @hidden */
  55999. _rebuild(): void;
  56000. /**
  56001. * Disposes of the manager and pipelines
  56002. */
  56003. dispose(): void;
  56004. }
  56005. }
  56006. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  56007. import { ISceneComponent } from "babylonjs/sceneComponent";
  56008. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56009. import { Scene } from "babylonjs/scene";
  56010. module "babylonjs/scene" {
  56011. interface Scene {
  56012. /** @hidden (Backing field) */
  56013. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56014. /**
  56015. * Gets the postprocess render pipeline manager
  56016. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56017. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56018. */
  56019. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56020. }
  56021. }
  56022. /**
  56023. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56024. */
  56025. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56026. /**
  56027. * The component name helpfull to identify the component in the list of scene components.
  56028. */
  56029. readonly name: string;
  56030. /**
  56031. * The scene the component belongs to.
  56032. */
  56033. scene: Scene;
  56034. /**
  56035. * Creates a new instance of the component for the given scene
  56036. * @param scene Defines the scene to register the component in
  56037. */
  56038. constructor(scene: Scene);
  56039. /**
  56040. * Registers the component in a given scene
  56041. */
  56042. register(): void;
  56043. /**
  56044. * Rebuilds the elements related to this component in case of
  56045. * context lost for instance.
  56046. */
  56047. rebuild(): void;
  56048. /**
  56049. * Disposes the component and the associated ressources
  56050. */
  56051. dispose(): void;
  56052. private _gatherRenderTargets;
  56053. }
  56054. }
  56055. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56056. import { Nullable } from "babylonjs/types";
  56057. import { IAnimatable } from "babylonjs/Misc/tools";
  56058. import { Camera } from "babylonjs/Cameras/camera";
  56059. import { IDisposable } from "babylonjs/scene";
  56060. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  56061. import { Scene } from "babylonjs/scene";
  56062. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56063. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56064. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56065. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56066. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56067. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56068. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56069. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56070. import { Animation } from "babylonjs/Animations/animation";
  56071. /**
  56072. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56073. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56074. */
  56075. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56076. private _scene;
  56077. private _camerasToBeAttached;
  56078. /**
  56079. * ID of the sharpen post process,
  56080. */
  56081. private readonly SharpenPostProcessId;
  56082. /**
  56083. * @ignore
  56084. * ID of the image processing post process;
  56085. */
  56086. readonly ImageProcessingPostProcessId: string;
  56087. /**
  56088. * @ignore
  56089. * ID of the Fast Approximate Anti-Aliasing post process;
  56090. */
  56091. readonly FxaaPostProcessId: string;
  56092. /**
  56093. * ID of the chromatic aberration post process,
  56094. */
  56095. private readonly ChromaticAberrationPostProcessId;
  56096. /**
  56097. * ID of the grain post process
  56098. */
  56099. private readonly GrainPostProcessId;
  56100. /**
  56101. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56102. */
  56103. sharpen: SharpenPostProcess;
  56104. private _sharpenEffect;
  56105. private bloom;
  56106. /**
  56107. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56108. */
  56109. depthOfField: DepthOfFieldEffect;
  56110. /**
  56111. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56112. */
  56113. fxaa: FxaaPostProcess;
  56114. /**
  56115. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56116. */
  56117. imageProcessing: ImageProcessingPostProcess;
  56118. /**
  56119. * Chromatic aberration post process which will shift rgb colors in the image
  56120. */
  56121. chromaticAberration: ChromaticAberrationPostProcess;
  56122. private _chromaticAberrationEffect;
  56123. /**
  56124. * Grain post process which add noise to the image
  56125. */
  56126. grain: GrainPostProcess;
  56127. private _grainEffect;
  56128. /**
  56129. * Glow post process which adds a glow to emissive areas of the image
  56130. */
  56131. private _glowLayer;
  56132. /**
  56133. * Animations which can be used to tweak settings over a period of time
  56134. */
  56135. animations: Animation[];
  56136. private _imageProcessingConfigurationObserver;
  56137. private _sharpenEnabled;
  56138. private _bloomEnabled;
  56139. private _depthOfFieldEnabled;
  56140. private _depthOfFieldBlurLevel;
  56141. private _fxaaEnabled;
  56142. private _imageProcessingEnabled;
  56143. private _defaultPipelineTextureType;
  56144. private _bloomScale;
  56145. private _chromaticAberrationEnabled;
  56146. private _grainEnabled;
  56147. private _buildAllowed;
  56148. /**
  56149. * Gets active scene
  56150. */
  56151. readonly scene: Scene;
  56152. /**
  56153. * Enable or disable the sharpen process from the pipeline
  56154. */
  56155. sharpenEnabled: boolean;
  56156. private _resizeObserver;
  56157. private _hardwareScaleLevel;
  56158. private _bloomKernel;
  56159. /**
  56160. * Specifies the size of the bloom blur kernel, relative to the final output size
  56161. */
  56162. bloomKernel: number;
  56163. /**
  56164. * Specifies the weight of the bloom in the final rendering
  56165. */
  56166. private _bloomWeight;
  56167. /**
  56168. * Specifies the luma threshold for the area that will be blurred by the bloom
  56169. */
  56170. private _bloomThreshold;
  56171. private _hdr;
  56172. /**
  56173. * The strength of the bloom.
  56174. */
  56175. bloomWeight: number;
  56176. /**
  56177. * The strength of the bloom.
  56178. */
  56179. bloomThreshold: number;
  56180. /**
  56181. * The scale of the bloom, lower value will provide better performance.
  56182. */
  56183. bloomScale: number;
  56184. /**
  56185. * Enable or disable the bloom from the pipeline
  56186. */
  56187. bloomEnabled: boolean;
  56188. private _rebuildBloom;
  56189. /**
  56190. * If the depth of field is enabled.
  56191. */
  56192. depthOfFieldEnabled: boolean;
  56193. /**
  56194. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56195. */
  56196. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56197. /**
  56198. * If the anti aliasing is enabled.
  56199. */
  56200. fxaaEnabled: boolean;
  56201. private _samples;
  56202. /**
  56203. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56204. */
  56205. samples: number;
  56206. /**
  56207. * If image processing is enabled.
  56208. */
  56209. imageProcessingEnabled: boolean;
  56210. /**
  56211. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56212. */
  56213. glowLayerEnabled: boolean;
  56214. /**
  56215. * Gets the glow layer (or null if not defined)
  56216. */
  56217. readonly glowLayer: Nullable<GlowLayer>;
  56218. /**
  56219. * Enable or disable the chromaticAberration process from the pipeline
  56220. */
  56221. chromaticAberrationEnabled: boolean;
  56222. /**
  56223. * Enable or disable the grain process from the pipeline
  56224. */
  56225. grainEnabled: boolean;
  56226. /**
  56227. * @constructor
  56228. * @param name - The rendering pipeline name (default: "")
  56229. * @param hdr - If high dynamic range textures should be used (default: true)
  56230. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56231. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56232. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56233. */
  56234. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56235. /**
  56236. * Get the class name
  56237. * @returns "DefaultRenderingPipeline"
  56238. */
  56239. getClassName(): string;
  56240. /**
  56241. * Force the compilation of the entire pipeline.
  56242. */
  56243. prepare(): void;
  56244. private _hasCleared;
  56245. private _prevPostProcess;
  56246. private _prevPrevPostProcess;
  56247. private _setAutoClearAndTextureSharing;
  56248. private _depthOfFieldSceneObserver;
  56249. private _buildPipeline;
  56250. private _disposePostProcesses;
  56251. /**
  56252. * Adds a camera to the pipeline
  56253. * @param camera the camera to be added
  56254. */
  56255. addCamera(camera: Camera): void;
  56256. /**
  56257. * Removes a camera from the pipeline
  56258. * @param camera the camera to remove
  56259. */
  56260. removeCamera(camera: Camera): void;
  56261. /**
  56262. * Dispose of the pipeline and stop all post processes
  56263. */
  56264. dispose(): void;
  56265. /**
  56266. * Serialize the rendering pipeline (Used when exporting)
  56267. * @returns the serialized object
  56268. */
  56269. serialize(): any;
  56270. /**
  56271. * Parse the serialized pipeline
  56272. * @param source Source pipeline.
  56273. * @param scene The scene to load the pipeline to.
  56274. * @param rootUrl The URL of the serialized pipeline.
  56275. * @returns An instantiated pipeline from the serialized object.
  56276. */
  56277. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56278. }
  56279. }
  56280. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56281. /** @hidden */
  56282. export var lensHighlightsPixelShader: {
  56283. name: string;
  56284. shader: string;
  56285. };
  56286. }
  56287. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56288. /** @hidden */
  56289. export var depthOfFieldPixelShader: {
  56290. name: string;
  56291. shader: string;
  56292. };
  56293. }
  56294. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56295. import { Camera } from "babylonjs/Cameras/camera";
  56296. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56297. import { Scene } from "babylonjs/scene";
  56298. import "babylonjs/Shaders/chromaticAberration.fragment";
  56299. import "babylonjs/Shaders/lensHighlights.fragment";
  56300. import "babylonjs/Shaders/depthOfField.fragment";
  56301. /**
  56302. * BABYLON.JS Chromatic Aberration GLSL Shader
  56303. * Author: Olivier Guyot
  56304. * Separates very slightly R, G and B colors on the edges of the screen
  56305. * Inspired by Francois Tarlier & Martins Upitis
  56306. */
  56307. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56308. /**
  56309. * @ignore
  56310. * The chromatic aberration PostProcess id in the pipeline
  56311. */
  56312. LensChromaticAberrationEffect: string;
  56313. /**
  56314. * @ignore
  56315. * The highlights enhancing PostProcess id in the pipeline
  56316. */
  56317. HighlightsEnhancingEffect: string;
  56318. /**
  56319. * @ignore
  56320. * The depth-of-field PostProcess id in the pipeline
  56321. */
  56322. LensDepthOfFieldEffect: string;
  56323. private _scene;
  56324. private _depthTexture;
  56325. private _grainTexture;
  56326. private _chromaticAberrationPostProcess;
  56327. private _highlightsPostProcess;
  56328. private _depthOfFieldPostProcess;
  56329. private _edgeBlur;
  56330. private _grainAmount;
  56331. private _chromaticAberration;
  56332. private _distortion;
  56333. private _highlightsGain;
  56334. private _highlightsThreshold;
  56335. private _dofDistance;
  56336. private _dofAperture;
  56337. private _dofDarken;
  56338. private _dofPentagon;
  56339. private _blurNoise;
  56340. /**
  56341. * @constructor
  56342. *
  56343. * Effect parameters are as follow:
  56344. * {
  56345. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56346. * edge_blur: number; // from 0 to x (1 for realism)
  56347. * distortion: number; // from 0 to x (1 for realism)
  56348. * grain_amount: number; // from 0 to 1
  56349. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56350. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56351. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56352. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56353. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56354. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56355. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56356. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56357. * }
  56358. * Note: if an effect parameter is unset, effect is disabled
  56359. *
  56360. * @param name The rendering pipeline name
  56361. * @param parameters - An object containing all parameters (see above)
  56362. * @param scene The scene linked to this pipeline
  56363. * @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)
  56364. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56365. */
  56366. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56367. /**
  56368. * Get the class name
  56369. * @returns "LensRenderingPipeline"
  56370. */
  56371. getClassName(): string;
  56372. /**
  56373. * Gets associated scene
  56374. */
  56375. readonly scene: Scene;
  56376. /**
  56377. * Gets or sets the edge blur
  56378. */
  56379. edgeBlur: number;
  56380. /**
  56381. * Gets or sets the grain amount
  56382. */
  56383. grainAmount: number;
  56384. /**
  56385. * Gets or sets the chromatic aberration amount
  56386. */
  56387. chromaticAberration: number;
  56388. /**
  56389. * Gets or sets the depth of field aperture
  56390. */
  56391. dofAperture: number;
  56392. /**
  56393. * Gets or sets the edge distortion
  56394. */
  56395. edgeDistortion: number;
  56396. /**
  56397. * Gets or sets the depth of field distortion
  56398. */
  56399. dofDistortion: number;
  56400. /**
  56401. * Gets or sets the darken out of focus amount
  56402. */
  56403. darkenOutOfFocus: number;
  56404. /**
  56405. * Gets or sets a boolean indicating if blur noise is enabled
  56406. */
  56407. blurNoise: boolean;
  56408. /**
  56409. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56410. */
  56411. pentagonBokeh: boolean;
  56412. /**
  56413. * Gets or sets the highlight grain amount
  56414. */
  56415. highlightsGain: number;
  56416. /**
  56417. * Gets or sets the highlight threshold
  56418. */
  56419. highlightsThreshold: number;
  56420. /**
  56421. * Sets the amount of blur at the edges
  56422. * @param amount blur amount
  56423. */
  56424. setEdgeBlur(amount: number): void;
  56425. /**
  56426. * Sets edge blur to 0
  56427. */
  56428. disableEdgeBlur(): void;
  56429. /**
  56430. * Sets the amout of grain
  56431. * @param amount Amount of grain
  56432. */
  56433. setGrainAmount(amount: number): void;
  56434. /**
  56435. * Set grain amount to 0
  56436. */
  56437. disableGrain(): void;
  56438. /**
  56439. * Sets the chromatic aberration amount
  56440. * @param amount amount of chromatic aberration
  56441. */
  56442. setChromaticAberration(amount: number): void;
  56443. /**
  56444. * Sets chromatic aberration amount to 0
  56445. */
  56446. disableChromaticAberration(): void;
  56447. /**
  56448. * Sets the EdgeDistortion amount
  56449. * @param amount amount of EdgeDistortion
  56450. */
  56451. setEdgeDistortion(amount: number): void;
  56452. /**
  56453. * Sets edge distortion to 0
  56454. */
  56455. disableEdgeDistortion(): void;
  56456. /**
  56457. * Sets the FocusDistance amount
  56458. * @param amount amount of FocusDistance
  56459. */
  56460. setFocusDistance(amount: number): void;
  56461. /**
  56462. * Disables depth of field
  56463. */
  56464. disableDepthOfField(): void;
  56465. /**
  56466. * Sets the Aperture amount
  56467. * @param amount amount of Aperture
  56468. */
  56469. setAperture(amount: number): void;
  56470. /**
  56471. * Sets the DarkenOutOfFocus amount
  56472. * @param amount amount of DarkenOutOfFocus
  56473. */
  56474. setDarkenOutOfFocus(amount: number): void;
  56475. private _pentagonBokehIsEnabled;
  56476. /**
  56477. * Creates a pentagon bokeh effect
  56478. */
  56479. enablePentagonBokeh(): void;
  56480. /**
  56481. * Disables the pentagon bokeh effect
  56482. */
  56483. disablePentagonBokeh(): void;
  56484. /**
  56485. * Enables noise blur
  56486. */
  56487. enableNoiseBlur(): void;
  56488. /**
  56489. * Disables noise blur
  56490. */
  56491. disableNoiseBlur(): void;
  56492. /**
  56493. * Sets the HighlightsGain amount
  56494. * @param amount amount of HighlightsGain
  56495. */
  56496. setHighlightsGain(amount: number): void;
  56497. /**
  56498. * Sets the HighlightsThreshold amount
  56499. * @param amount amount of HighlightsThreshold
  56500. */
  56501. setHighlightsThreshold(amount: number): void;
  56502. /**
  56503. * Disables highlights
  56504. */
  56505. disableHighlights(): void;
  56506. /**
  56507. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56508. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56509. */
  56510. dispose(disableDepthRender?: boolean): void;
  56511. private _createChromaticAberrationPostProcess;
  56512. private _createHighlightsPostProcess;
  56513. private _createDepthOfFieldPostProcess;
  56514. private _createGrainTexture;
  56515. }
  56516. }
  56517. declare module "babylonjs/Shaders/ssao2.fragment" {
  56518. /** @hidden */
  56519. export var ssao2PixelShader: {
  56520. name: string;
  56521. shader: string;
  56522. };
  56523. }
  56524. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56525. /** @hidden */
  56526. export var ssaoCombinePixelShader: {
  56527. name: string;
  56528. shader: string;
  56529. };
  56530. }
  56531. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56532. import { Camera } from "babylonjs/Cameras/camera";
  56533. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56534. import { Scene } from "babylonjs/scene";
  56535. import "babylonjs/Shaders/ssao2.fragment";
  56536. import "babylonjs/Shaders/ssaoCombine.fragment";
  56537. /**
  56538. * Render pipeline to produce ssao effect
  56539. */
  56540. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56541. /**
  56542. * @ignore
  56543. * The PassPostProcess id in the pipeline that contains the original scene color
  56544. */
  56545. SSAOOriginalSceneColorEffect: string;
  56546. /**
  56547. * @ignore
  56548. * The SSAO PostProcess id in the pipeline
  56549. */
  56550. SSAORenderEffect: string;
  56551. /**
  56552. * @ignore
  56553. * The horizontal blur PostProcess id in the pipeline
  56554. */
  56555. SSAOBlurHRenderEffect: string;
  56556. /**
  56557. * @ignore
  56558. * The vertical blur PostProcess id in the pipeline
  56559. */
  56560. SSAOBlurVRenderEffect: string;
  56561. /**
  56562. * @ignore
  56563. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56564. */
  56565. SSAOCombineRenderEffect: string;
  56566. /**
  56567. * The output strength of the SSAO post-process. Default value is 1.0.
  56568. */
  56569. totalStrength: number;
  56570. /**
  56571. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56572. */
  56573. maxZ: number;
  56574. /**
  56575. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56576. */
  56577. minZAspect: number;
  56578. private _samples;
  56579. /**
  56580. * Number of samples used for the SSAO calculations. Default value is 8
  56581. */
  56582. samples: number;
  56583. private _textureSamples;
  56584. /**
  56585. * Number of samples to use for antialiasing
  56586. */
  56587. textureSamples: number;
  56588. /**
  56589. * Ratio object used for SSAO ratio and blur ratio
  56590. */
  56591. private _ratio;
  56592. /**
  56593. * Dynamically generated sphere sampler.
  56594. */
  56595. private _sampleSphere;
  56596. /**
  56597. * Blur filter offsets
  56598. */
  56599. private _samplerOffsets;
  56600. private _expensiveBlur;
  56601. /**
  56602. * If bilateral blur should be used
  56603. */
  56604. expensiveBlur: boolean;
  56605. /**
  56606. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56607. */
  56608. radius: number;
  56609. /**
  56610. * The base color of the SSAO post-process
  56611. * The final result is "base + ssao" between [0, 1]
  56612. */
  56613. base: number;
  56614. /**
  56615. * Support test.
  56616. */
  56617. static readonly IsSupported: boolean;
  56618. private _scene;
  56619. private _depthTexture;
  56620. private _normalTexture;
  56621. private _randomTexture;
  56622. private _originalColorPostProcess;
  56623. private _ssaoPostProcess;
  56624. private _blurHPostProcess;
  56625. private _blurVPostProcess;
  56626. private _ssaoCombinePostProcess;
  56627. private _firstUpdate;
  56628. /**
  56629. * Gets active scene
  56630. */
  56631. readonly scene: Scene;
  56632. /**
  56633. * @constructor
  56634. * @param name The rendering pipeline name
  56635. * @param scene The scene linked to this pipeline
  56636. * @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 }
  56637. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56638. */
  56639. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56640. /**
  56641. * Get the class name
  56642. * @returns "SSAO2RenderingPipeline"
  56643. */
  56644. getClassName(): string;
  56645. /**
  56646. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56647. */
  56648. dispose(disableGeometryBufferRenderer?: boolean): void;
  56649. private _createBlurPostProcess;
  56650. /** @hidden */
  56651. _rebuild(): void;
  56652. private _bits;
  56653. private _radicalInverse_VdC;
  56654. private _hammersley;
  56655. private _hemisphereSample_uniform;
  56656. private _generateHemisphere;
  56657. private _createSSAOPostProcess;
  56658. private _createSSAOCombinePostProcess;
  56659. private _createRandomTexture;
  56660. /**
  56661. * Serialize the rendering pipeline (Used when exporting)
  56662. * @returns the serialized object
  56663. */
  56664. serialize(): any;
  56665. /**
  56666. * Parse the serialized pipeline
  56667. * @param source Source pipeline.
  56668. * @param scene The scene to load the pipeline to.
  56669. * @param rootUrl The URL of the serialized pipeline.
  56670. * @returns An instantiated pipeline from the serialized object.
  56671. */
  56672. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56673. }
  56674. }
  56675. declare module "babylonjs/Shaders/ssao.fragment" {
  56676. /** @hidden */
  56677. export var ssaoPixelShader: {
  56678. name: string;
  56679. shader: string;
  56680. };
  56681. }
  56682. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56683. import { Camera } from "babylonjs/Cameras/camera";
  56684. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56685. import { Scene } from "babylonjs/scene";
  56686. import "babylonjs/Shaders/ssao.fragment";
  56687. import "babylonjs/Shaders/ssaoCombine.fragment";
  56688. /**
  56689. * Render pipeline to produce ssao effect
  56690. */
  56691. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56692. /**
  56693. * @ignore
  56694. * The PassPostProcess id in the pipeline that contains the original scene color
  56695. */
  56696. SSAOOriginalSceneColorEffect: string;
  56697. /**
  56698. * @ignore
  56699. * The SSAO PostProcess id in the pipeline
  56700. */
  56701. SSAORenderEffect: string;
  56702. /**
  56703. * @ignore
  56704. * The horizontal blur PostProcess id in the pipeline
  56705. */
  56706. SSAOBlurHRenderEffect: string;
  56707. /**
  56708. * @ignore
  56709. * The vertical blur PostProcess id in the pipeline
  56710. */
  56711. SSAOBlurVRenderEffect: string;
  56712. /**
  56713. * @ignore
  56714. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56715. */
  56716. SSAOCombineRenderEffect: string;
  56717. /**
  56718. * The output strength of the SSAO post-process. Default value is 1.0.
  56719. */
  56720. totalStrength: number;
  56721. /**
  56722. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56723. */
  56724. radius: number;
  56725. /**
  56726. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56727. * Must not be equal to fallOff and superior to fallOff.
  56728. * Default value is 0.0075
  56729. */
  56730. area: number;
  56731. /**
  56732. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56733. * Must not be equal to area and inferior to area.
  56734. * Default value is 0.000001
  56735. */
  56736. fallOff: number;
  56737. /**
  56738. * The base color of the SSAO post-process
  56739. * The final result is "base + ssao" between [0, 1]
  56740. */
  56741. base: number;
  56742. private _scene;
  56743. private _depthTexture;
  56744. private _randomTexture;
  56745. private _originalColorPostProcess;
  56746. private _ssaoPostProcess;
  56747. private _blurHPostProcess;
  56748. private _blurVPostProcess;
  56749. private _ssaoCombinePostProcess;
  56750. private _firstUpdate;
  56751. /**
  56752. * Gets active scene
  56753. */
  56754. readonly scene: Scene;
  56755. /**
  56756. * @constructor
  56757. * @param name - The rendering pipeline name
  56758. * @param scene - The scene linked to this pipeline
  56759. * @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 }
  56760. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56761. */
  56762. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56763. /**
  56764. * Get the class name
  56765. * @returns "SSAORenderingPipeline"
  56766. */
  56767. getClassName(): string;
  56768. /**
  56769. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56770. */
  56771. dispose(disableDepthRender?: boolean): void;
  56772. private _createBlurPostProcess;
  56773. /** @hidden */
  56774. _rebuild(): void;
  56775. private _createSSAOPostProcess;
  56776. private _createSSAOCombinePostProcess;
  56777. private _createRandomTexture;
  56778. }
  56779. }
  56780. declare module "babylonjs/Shaders/standard.fragment" {
  56781. /** @hidden */
  56782. export var standardPixelShader: {
  56783. name: string;
  56784. shader: string;
  56785. };
  56786. }
  56787. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56788. import { Nullable } from "babylonjs/types";
  56789. import { IAnimatable } from "babylonjs/Misc/tools";
  56790. import { Camera } from "babylonjs/Cameras/camera";
  56791. import { Texture } from "babylonjs/Materials/Textures/texture";
  56792. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56793. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56794. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56795. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56796. import { IDisposable } from "babylonjs/scene";
  56797. import { SpotLight } from "babylonjs/Lights/spotLight";
  56798. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56799. import { Scene } from "babylonjs/scene";
  56800. import { Animation } from "babylonjs/Animations/animation";
  56801. import "babylonjs/Shaders/standard.fragment";
  56802. /**
  56803. * Standard rendering pipeline
  56804. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56805. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56806. */
  56807. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56808. /**
  56809. * Public members
  56810. */
  56811. /**
  56812. * Post-process which contains the original scene color before the pipeline applies all the effects
  56813. */
  56814. originalPostProcess: Nullable<PostProcess>;
  56815. /**
  56816. * Post-process used to down scale an image x4
  56817. */
  56818. downSampleX4PostProcess: Nullable<PostProcess>;
  56819. /**
  56820. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56821. */
  56822. brightPassPostProcess: Nullable<PostProcess>;
  56823. /**
  56824. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56825. */
  56826. blurHPostProcesses: PostProcess[];
  56827. /**
  56828. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56829. */
  56830. blurVPostProcesses: PostProcess[];
  56831. /**
  56832. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56833. */
  56834. textureAdderPostProcess: Nullable<PostProcess>;
  56835. /**
  56836. * Post-process used to create volumetric lighting effect
  56837. */
  56838. volumetricLightPostProcess: Nullable<PostProcess>;
  56839. /**
  56840. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56841. */
  56842. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56843. /**
  56844. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56845. */
  56846. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56847. /**
  56848. * Post-process used to merge the volumetric light effect and the real scene color
  56849. */
  56850. volumetricLightMergePostProces: Nullable<PostProcess>;
  56851. /**
  56852. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56853. */
  56854. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56855. /**
  56856. * Base post-process used to calculate the average luminance of the final image for HDR
  56857. */
  56858. luminancePostProcess: Nullable<PostProcess>;
  56859. /**
  56860. * Post-processes used to create down sample post-processes in order to get
  56861. * the average luminance of the final image for HDR
  56862. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56863. */
  56864. luminanceDownSamplePostProcesses: PostProcess[];
  56865. /**
  56866. * Post-process used to create a HDR effect (light adaptation)
  56867. */
  56868. hdrPostProcess: Nullable<PostProcess>;
  56869. /**
  56870. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56871. */
  56872. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56873. /**
  56874. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56875. */
  56876. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56877. /**
  56878. * Post-process used to merge the final HDR post-process and the real scene color
  56879. */
  56880. hdrFinalPostProcess: Nullable<PostProcess>;
  56881. /**
  56882. * Post-process used to create a lens flare effect
  56883. */
  56884. lensFlarePostProcess: Nullable<PostProcess>;
  56885. /**
  56886. * Post-process that merges the result of the lens flare post-process and the real scene color
  56887. */
  56888. lensFlareComposePostProcess: Nullable<PostProcess>;
  56889. /**
  56890. * Post-process used to create a motion blur effect
  56891. */
  56892. motionBlurPostProcess: Nullable<PostProcess>;
  56893. /**
  56894. * Post-process used to create a depth of field effect
  56895. */
  56896. depthOfFieldPostProcess: Nullable<PostProcess>;
  56897. /**
  56898. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56899. */
  56900. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56901. /**
  56902. * Represents the brightness threshold in order to configure the illuminated surfaces
  56903. */
  56904. brightThreshold: number;
  56905. /**
  56906. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56907. */
  56908. blurWidth: number;
  56909. /**
  56910. * Sets if the blur for highlighted surfaces must be only horizontal
  56911. */
  56912. horizontalBlur: boolean;
  56913. /**
  56914. * Gets the overall exposure used by the pipeline
  56915. */
  56916. /**
  56917. * Sets the overall exposure used by the pipeline
  56918. */
  56919. exposure: number;
  56920. /**
  56921. * Texture used typically to simulate "dirty" on camera lens
  56922. */
  56923. lensTexture: Nullable<Texture>;
  56924. /**
  56925. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56926. */
  56927. volumetricLightCoefficient: number;
  56928. /**
  56929. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56930. */
  56931. volumetricLightPower: number;
  56932. /**
  56933. * Used the set the blur intensity to smooth the volumetric lights
  56934. */
  56935. volumetricLightBlurScale: number;
  56936. /**
  56937. * Light (spot or directional) used to generate the volumetric lights rays
  56938. * The source light must have a shadow generate so the pipeline can get its
  56939. * depth map
  56940. */
  56941. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56942. /**
  56943. * For eye adaptation, represents the minimum luminance the eye can see
  56944. */
  56945. hdrMinimumLuminance: number;
  56946. /**
  56947. * For eye adaptation, represents the decrease luminance speed
  56948. */
  56949. hdrDecreaseRate: number;
  56950. /**
  56951. * For eye adaptation, represents the increase luminance speed
  56952. */
  56953. hdrIncreaseRate: number;
  56954. /**
  56955. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56956. */
  56957. /**
  56958. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56959. */
  56960. hdrAutoExposure: boolean;
  56961. /**
  56962. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56963. */
  56964. lensColorTexture: Nullable<Texture>;
  56965. /**
  56966. * The overall strengh for the lens flare effect
  56967. */
  56968. lensFlareStrength: number;
  56969. /**
  56970. * Dispersion coefficient for lens flare ghosts
  56971. */
  56972. lensFlareGhostDispersal: number;
  56973. /**
  56974. * Main lens flare halo width
  56975. */
  56976. lensFlareHaloWidth: number;
  56977. /**
  56978. * Based on the lens distortion effect, defines how much the lens flare result
  56979. * is distorted
  56980. */
  56981. lensFlareDistortionStrength: number;
  56982. /**
  56983. * Lens star texture must be used to simulate rays on the flares and is available
  56984. * in the documentation
  56985. */
  56986. lensStarTexture: Nullable<Texture>;
  56987. /**
  56988. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56989. * flare effect by taking account of the dirt texture
  56990. */
  56991. lensFlareDirtTexture: Nullable<Texture>;
  56992. /**
  56993. * Represents the focal length for the depth of field effect
  56994. */
  56995. depthOfFieldDistance: number;
  56996. /**
  56997. * Represents the blur intensity for the blurred part of the depth of field effect
  56998. */
  56999. depthOfFieldBlurWidth: number;
  57000. /**
  57001. * For motion blur, defines how much the image is blurred by the movement
  57002. */
  57003. motionStrength: number;
  57004. /**
  57005. * List of animations for the pipeline (IAnimatable implementation)
  57006. */
  57007. animations: Animation[];
  57008. /**
  57009. * Private members
  57010. */
  57011. private _scene;
  57012. private _currentDepthOfFieldSource;
  57013. private _basePostProcess;
  57014. private _fixedExposure;
  57015. private _currentExposure;
  57016. private _hdrAutoExposure;
  57017. private _hdrCurrentLuminance;
  57018. private _floatTextureType;
  57019. private _ratio;
  57020. private _bloomEnabled;
  57021. private _depthOfFieldEnabled;
  57022. private _vlsEnabled;
  57023. private _lensFlareEnabled;
  57024. private _hdrEnabled;
  57025. private _motionBlurEnabled;
  57026. private _fxaaEnabled;
  57027. private _motionBlurSamples;
  57028. private _volumetricLightStepsCount;
  57029. private _samples;
  57030. /**
  57031. * @ignore
  57032. * Specifies if the bloom pipeline is enabled
  57033. */
  57034. BloomEnabled: boolean;
  57035. /**
  57036. * @ignore
  57037. * Specifies if the depth of field pipeline is enabed
  57038. */
  57039. DepthOfFieldEnabled: boolean;
  57040. /**
  57041. * @ignore
  57042. * Specifies if the lens flare pipeline is enabed
  57043. */
  57044. LensFlareEnabled: boolean;
  57045. /**
  57046. * @ignore
  57047. * Specifies if the HDR pipeline is enabled
  57048. */
  57049. HDREnabled: boolean;
  57050. /**
  57051. * @ignore
  57052. * Specifies if the volumetric lights scattering effect is enabled
  57053. */
  57054. VLSEnabled: boolean;
  57055. /**
  57056. * @ignore
  57057. * Specifies if the motion blur effect is enabled
  57058. */
  57059. MotionBlurEnabled: boolean;
  57060. /**
  57061. * Specifies if anti-aliasing is enabled
  57062. */
  57063. fxaaEnabled: boolean;
  57064. /**
  57065. * Specifies the number of steps used to calculate the volumetric lights
  57066. * Typically in interval [50, 200]
  57067. */
  57068. volumetricLightStepsCount: number;
  57069. /**
  57070. * Specifies the number of samples used for the motion blur effect
  57071. * Typically in interval [16, 64]
  57072. */
  57073. motionBlurSamples: number;
  57074. /**
  57075. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57076. */
  57077. samples: number;
  57078. /**
  57079. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57080. * @constructor
  57081. * @param name The rendering pipeline name
  57082. * @param scene The scene linked to this pipeline
  57083. * @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)
  57084. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57085. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57086. */
  57087. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57088. private _buildPipeline;
  57089. private _createDownSampleX4PostProcess;
  57090. private _createBrightPassPostProcess;
  57091. private _createBlurPostProcesses;
  57092. private _createTextureAdderPostProcess;
  57093. private _createVolumetricLightPostProcess;
  57094. private _createLuminancePostProcesses;
  57095. private _createHdrPostProcess;
  57096. private _createLensFlarePostProcess;
  57097. private _createDepthOfFieldPostProcess;
  57098. private _createMotionBlurPostProcess;
  57099. private _getDepthTexture;
  57100. private _disposePostProcesses;
  57101. /**
  57102. * Dispose of the pipeline and stop all post processes
  57103. */
  57104. dispose(): void;
  57105. /**
  57106. * Serialize the rendering pipeline (Used when exporting)
  57107. * @returns the serialized object
  57108. */
  57109. serialize(): any;
  57110. /**
  57111. * Parse the serialized pipeline
  57112. * @param source Source pipeline.
  57113. * @param scene The scene to load the pipeline to.
  57114. * @param rootUrl The URL of the serialized pipeline.
  57115. * @returns An instantiated pipeline from the serialized object.
  57116. */
  57117. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57118. /**
  57119. * Luminance steps
  57120. */
  57121. static LuminanceSteps: number;
  57122. }
  57123. }
  57124. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57125. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57126. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57127. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57128. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57129. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57130. }
  57131. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57132. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57133. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57134. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57135. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57136. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57137. }
  57138. declare module "babylonjs/Shaders/tonemap.fragment" {
  57139. /** @hidden */
  57140. export var tonemapPixelShader: {
  57141. name: string;
  57142. shader: string;
  57143. };
  57144. }
  57145. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57146. import { Camera } from "babylonjs/Cameras/camera";
  57147. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57148. import "babylonjs/Shaders/tonemap.fragment";
  57149. import { Engine } from "babylonjs/Engines/engine";
  57150. /** Defines operator used for tonemapping */
  57151. export enum TonemappingOperator {
  57152. /** Hable */
  57153. Hable = 0,
  57154. /** Reinhard */
  57155. Reinhard = 1,
  57156. /** HejiDawson */
  57157. HejiDawson = 2,
  57158. /** Photographic */
  57159. Photographic = 3
  57160. }
  57161. /**
  57162. * Defines a post process to apply tone mapping
  57163. */
  57164. export class TonemapPostProcess extends PostProcess {
  57165. private _operator;
  57166. /** Defines the required exposure adjustement */
  57167. exposureAdjustment: number;
  57168. /**
  57169. * Creates a new TonemapPostProcess
  57170. * @param name defines the name of the postprocess
  57171. * @param _operator defines the operator to use
  57172. * @param exposureAdjustment defines the required exposure adjustement
  57173. * @param camera defines the camera to use (can be null)
  57174. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57175. * @param engine defines the hosting engine (can be ignore if camera is set)
  57176. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57177. */
  57178. constructor(name: string, _operator: TonemappingOperator,
  57179. /** Defines the required exposure adjustement */
  57180. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57181. }
  57182. }
  57183. declare module "babylonjs/Shaders/depth.vertex" {
  57184. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57185. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57186. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57187. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57188. /** @hidden */
  57189. export var depthVertexShader: {
  57190. name: string;
  57191. shader: string;
  57192. };
  57193. }
  57194. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57195. /** @hidden */
  57196. export var volumetricLightScatteringPixelShader: {
  57197. name: string;
  57198. shader: string;
  57199. };
  57200. }
  57201. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57202. /** @hidden */
  57203. export var volumetricLightScatteringPassPixelShader: {
  57204. name: string;
  57205. shader: string;
  57206. };
  57207. }
  57208. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57209. import { Vector3 } from "babylonjs/Maths/math";
  57210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57211. import { Mesh } from "babylonjs/Meshes/mesh";
  57212. import { Camera } from "babylonjs/Cameras/camera";
  57213. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57214. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57215. import { Scene } from "babylonjs/scene";
  57216. import "babylonjs/Meshes/Builders/planeBuilder";
  57217. import "babylonjs/Shaders/depth.vertex";
  57218. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57219. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57220. import { Engine } from "babylonjs/Engines/engine";
  57221. /**
  57222. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57223. */
  57224. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57225. private _volumetricLightScatteringPass;
  57226. private _volumetricLightScatteringRTT;
  57227. private _viewPort;
  57228. private _screenCoordinates;
  57229. private _cachedDefines;
  57230. /**
  57231. * If not undefined, the mesh position is computed from the attached node position
  57232. */
  57233. attachedNode: {
  57234. position: Vector3;
  57235. };
  57236. /**
  57237. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57238. */
  57239. customMeshPosition: Vector3;
  57240. /**
  57241. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57242. */
  57243. useCustomMeshPosition: boolean;
  57244. /**
  57245. * If the post-process should inverse the light scattering direction
  57246. */
  57247. invert: boolean;
  57248. /**
  57249. * The internal mesh used by the post-process
  57250. */
  57251. mesh: Mesh;
  57252. /**
  57253. * @hidden
  57254. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57255. */
  57256. useDiffuseColor: boolean;
  57257. /**
  57258. * Array containing the excluded meshes not rendered in the internal pass
  57259. */
  57260. excludedMeshes: AbstractMesh[];
  57261. /**
  57262. * Controls the overall intensity of the post-process
  57263. */
  57264. exposure: number;
  57265. /**
  57266. * Dissipates each sample's contribution in range [0, 1]
  57267. */
  57268. decay: number;
  57269. /**
  57270. * Controls the overall intensity of each sample
  57271. */
  57272. weight: number;
  57273. /**
  57274. * Controls the density of each sample
  57275. */
  57276. density: number;
  57277. /**
  57278. * @constructor
  57279. * @param name The post-process name
  57280. * @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)
  57281. * @param camera The camera that the post-process will be attached to
  57282. * @param mesh The mesh used to create the light scattering
  57283. * @param samples The post-process quality, default 100
  57284. * @param samplingModeThe post-process filtering mode
  57285. * @param engine The babylon engine
  57286. * @param reusable If the post-process is reusable
  57287. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57288. */
  57289. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57290. /**
  57291. * Returns the string "VolumetricLightScatteringPostProcess"
  57292. * @returns "VolumetricLightScatteringPostProcess"
  57293. */
  57294. getClassName(): string;
  57295. private _isReady;
  57296. /**
  57297. * Sets the new light position for light scattering effect
  57298. * @param position The new custom light position
  57299. */
  57300. setCustomMeshPosition(position: Vector3): void;
  57301. /**
  57302. * Returns the light position for light scattering effect
  57303. * @return Vector3 The custom light position
  57304. */
  57305. getCustomMeshPosition(): Vector3;
  57306. /**
  57307. * Disposes the internal assets and detaches the post-process from the camera
  57308. */
  57309. dispose(camera: Camera): void;
  57310. /**
  57311. * Returns the render target texture used by the post-process
  57312. * @return the render target texture used by the post-process
  57313. */
  57314. getPass(): RenderTargetTexture;
  57315. private _meshExcluded;
  57316. private _createPass;
  57317. private _updateMeshScreenCoordinates;
  57318. /**
  57319. * Creates a default mesh for the Volumeric Light Scattering post-process
  57320. * @param name The mesh name
  57321. * @param scene The scene where to create the mesh
  57322. * @return the default mesh
  57323. */
  57324. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57325. }
  57326. }
  57327. declare module "babylonjs/PostProcesses/index" {
  57328. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57329. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57330. export * from "babylonjs/PostProcesses/bloomEffect";
  57331. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57332. export * from "babylonjs/PostProcesses/blurPostProcess";
  57333. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57334. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57335. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57336. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57337. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57338. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57339. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57340. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57341. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57342. export * from "babylonjs/PostProcesses/filterPostProcess";
  57343. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57344. export * from "babylonjs/PostProcesses/grainPostProcess";
  57345. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57346. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57347. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57348. export * from "babylonjs/PostProcesses/passPostProcess";
  57349. export * from "babylonjs/PostProcesses/postProcess";
  57350. export * from "babylonjs/PostProcesses/postProcessManager";
  57351. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57352. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57353. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57354. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57355. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57356. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57357. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57358. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57359. }
  57360. declare module "babylonjs/Probes/index" {
  57361. export * from "babylonjs/Probes/reflectionProbe";
  57362. }
  57363. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57364. import { Scene } from "babylonjs/scene";
  57365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57366. import { Color3 } from "babylonjs/Maths/math";
  57367. import { SmartArray } from "babylonjs/Misc/smartArray";
  57368. import { ISceneComponent } from "babylonjs/sceneComponent";
  57369. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57370. import "babylonjs/Meshes/Builders/boxBuilder";
  57371. import "babylonjs/Shaders/color.fragment";
  57372. import "babylonjs/Shaders/color.vertex";
  57373. module "babylonjs/scene" {
  57374. interface Scene {
  57375. /** @hidden (Backing field) */
  57376. _boundingBoxRenderer: BoundingBoxRenderer;
  57377. /** @hidden (Backing field) */
  57378. _forceShowBoundingBoxes: boolean;
  57379. /**
  57380. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57381. */
  57382. forceShowBoundingBoxes: boolean;
  57383. /**
  57384. * Gets the bounding box renderer associated with the scene
  57385. * @returns a BoundingBoxRenderer
  57386. */
  57387. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57388. }
  57389. }
  57390. module "babylonjs/Meshes/abstractMesh" {
  57391. interface AbstractMesh {
  57392. /** @hidden (Backing field) */
  57393. _showBoundingBox: boolean;
  57394. /**
  57395. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57396. */
  57397. showBoundingBox: boolean;
  57398. }
  57399. }
  57400. /**
  57401. * Component responsible of rendering the bounding box of the meshes in a scene.
  57402. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57403. */
  57404. export class BoundingBoxRenderer implements ISceneComponent {
  57405. /**
  57406. * The component name helpfull to identify the component in the list of scene components.
  57407. */
  57408. readonly name: string;
  57409. /**
  57410. * The scene the component belongs to.
  57411. */
  57412. scene: Scene;
  57413. /**
  57414. * Color of the bounding box lines placed in front of an object
  57415. */
  57416. frontColor: Color3;
  57417. /**
  57418. * Color of the bounding box lines placed behind an object
  57419. */
  57420. backColor: Color3;
  57421. /**
  57422. * Defines if the renderer should show the back lines or not
  57423. */
  57424. showBackLines: boolean;
  57425. /**
  57426. * @hidden
  57427. */
  57428. renderList: SmartArray<BoundingBox>;
  57429. private _colorShader;
  57430. private _vertexBuffers;
  57431. private _indexBuffer;
  57432. /**
  57433. * Instantiates a new bounding box renderer in a scene.
  57434. * @param scene the scene the renderer renders in
  57435. */
  57436. constructor(scene: Scene);
  57437. /**
  57438. * Registers the component in a given scene
  57439. */
  57440. register(): void;
  57441. private _evaluateSubMesh;
  57442. private _activeMesh;
  57443. private _prepareRessources;
  57444. private _createIndexBuffer;
  57445. /**
  57446. * Rebuilds the elements related to this component in case of
  57447. * context lost for instance.
  57448. */
  57449. rebuild(): void;
  57450. /**
  57451. * @hidden
  57452. */
  57453. reset(): void;
  57454. /**
  57455. * Render the bounding boxes of a specific rendering group
  57456. * @param renderingGroupId defines the rendering group to render
  57457. */
  57458. render(renderingGroupId: number): void;
  57459. /**
  57460. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57461. * @param mesh Define the mesh to render the occlusion bounding box for
  57462. */
  57463. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57464. /**
  57465. * Dispose and release the resources attached to this renderer.
  57466. */
  57467. dispose(): void;
  57468. }
  57469. }
  57470. declare module "babylonjs/Shaders/depth.fragment" {
  57471. /** @hidden */
  57472. export var depthPixelShader: {
  57473. name: string;
  57474. shader: string;
  57475. };
  57476. }
  57477. declare module "babylonjs/Rendering/depthRenderer" {
  57478. import { Nullable } from "babylonjs/types";
  57479. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57480. import { Scene } from "babylonjs/scene";
  57481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57482. import { Camera } from "babylonjs/Cameras/camera";
  57483. import "babylonjs/Shaders/depth.fragment";
  57484. import "babylonjs/Shaders/depth.vertex";
  57485. /**
  57486. * This represents a depth renderer in Babylon.
  57487. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57488. */
  57489. export class DepthRenderer {
  57490. private _scene;
  57491. private _depthMap;
  57492. private _effect;
  57493. private _cachedDefines;
  57494. private _camera;
  57495. /**
  57496. * Specifiess that the depth renderer will only be used within
  57497. * the camera it is created for.
  57498. * This can help forcing its rendering during the camera processing.
  57499. */
  57500. useOnlyInActiveCamera: boolean;
  57501. /** @hidden */
  57502. static _SceneComponentInitialization: (scene: Scene) => void;
  57503. /**
  57504. * Instantiates a depth renderer
  57505. * @param scene The scene the renderer belongs to
  57506. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57507. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57508. */
  57509. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57510. /**
  57511. * Creates the depth rendering effect and checks if the effect is ready.
  57512. * @param subMesh The submesh to be used to render the depth map of
  57513. * @param useInstances If multiple world instances should be used
  57514. * @returns if the depth renderer is ready to render the depth map
  57515. */
  57516. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57517. /**
  57518. * Gets the texture which the depth map will be written to.
  57519. * @returns The depth map texture
  57520. */
  57521. getDepthMap(): RenderTargetTexture;
  57522. /**
  57523. * Disposes of the depth renderer.
  57524. */
  57525. dispose(): void;
  57526. }
  57527. }
  57528. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57529. import { Nullable } from "babylonjs/types";
  57530. import { Scene } from "babylonjs/scene";
  57531. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57532. import { Camera } from "babylonjs/Cameras/camera";
  57533. import { ISceneComponent } from "babylonjs/sceneComponent";
  57534. module "babylonjs/scene" {
  57535. interface Scene {
  57536. /** @hidden (Backing field) */
  57537. _depthRenderer: {
  57538. [id: string]: DepthRenderer;
  57539. };
  57540. /**
  57541. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57542. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57543. * @returns the created depth renderer
  57544. */
  57545. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57546. /**
  57547. * Disables a depth renderer for a given camera
  57548. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57549. */
  57550. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57551. }
  57552. }
  57553. /**
  57554. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57555. * in several rendering techniques.
  57556. */
  57557. export class DepthRendererSceneComponent implements ISceneComponent {
  57558. /**
  57559. * The component name helpfull to identify the component in the list of scene components.
  57560. */
  57561. readonly name: string;
  57562. /**
  57563. * The scene the component belongs to.
  57564. */
  57565. scene: Scene;
  57566. /**
  57567. * Creates a new instance of the component for the given scene
  57568. * @param scene Defines the scene to register the component in
  57569. */
  57570. constructor(scene: Scene);
  57571. /**
  57572. * Registers the component in a given scene
  57573. */
  57574. register(): void;
  57575. /**
  57576. * Rebuilds the elements related to this component in case of
  57577. * context lost for instance.
  57578. */
  57579. rebuild(): void;
  57580. /**
  57581. * Disposes the component and the associated ressources
  57582. */
  57583. dispose(): void;
  57584. private _gatherRenderTargets;
  57585. private _gatherActiveCameraRenderTargets;
  57586. }
  57587. }
  57588. declare module "babylonjs/Shaders/outline.fragment" {
  57589. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57590. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57591. /** @hidden */
  57592. export var outlinePixelShader: {
  57593. name: string;
  57594. shader: string;
  57595. };
  57596. }
  57597. declare module "babylonjs/Shaders/outline.vertex" {
  57598. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57599. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57600. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57601. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57602. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57603. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57604. /** @hidden */
  57605. export var outlineVertexShader: {
  57606. name: string;
  57607. shader: string;
  57608. };
  57609. }
  57610. declare module "babylonjs/Rendering/outlineRenderer" {
  57611. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57612. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57613. import { Scene } from "babylonjs/scene";
  57614. import { ISceneComponent } from "babylonjs/sceneComponent";
  57615. import "babylonjs/Shaders/outline.fragment";
  57616. import "babylonjs/Shaders/outline.vertex";
  57617. module "babylonjs/scene" {
  57618. interface Scene {
  57619. /** @hidden */
  57620. _outlineRenderer: OutlineRenderer;
  57621. /**
  57622. * Gets the outline renderer associated with the scene
  57623. * @returns a OutlineRenderer
  57624. */
  57625. getOutlineRenderer(): OutlineRenderer;
  57626. }
  57627. }
  57628. module "babylonjs/Meshes/abstractMesh" {
  57629. interface AbstractMesh {
  57630. /** @hidden (Backing field) */
  57631. _renderOutline: boolean;
  57632. /**
  57633. * Gets or sets a boolean indicating if the outline must be rendered as well
  57634. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57635. */
  57636. renderOutline: boolean;
  57637. /** @hidden (Backing field) */
  57638. _renderOverlay: boolean;
  57639. /**
  57640. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57641. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57642. */
  57643. renderOverlay: boolean;
  57644. }
  57645. }
  57646. /**
  57647. * This class is responsible to draw bothe outline/overlay of meshes.
  57648. * It should not be used directly but through the available method on mesh.
  57649. */
  57650. export class OutlineRenderer implements ISceneComponent {
  57651. /**
  57652. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57653. */
  57654. private static _StencilReference;
  57655. /**
  57656. * The name of the component. Each component must have a unique name.
  57657. */
  57658. name: string;
  57659. /**
  57660. * The scene the component belongs to.
  57661. */
  57662. scene: Scene;
  57663. /**
  57664. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57665. */
  57666. zOffset: number;
  57667. private _engine;
  57668. private _effect;
  57669. private _cachedDefines;
  57670. private _savedDepthWrite;
  57671. /**
  57672. * Instantiates a new outline renderer. (There could be only one per scene).
  57673. * @param scene Defines the scene it belongs to
  57674. */
  57675. constructor(scene: Scene);
  57676. /**
  57677. * Register the component to one instance of a scene.
  57678. */
  57679. register(): void;
  57680. /**
  57681. * Rebuilds the elements related to this component in case of
  57682. * context lost for instance.
  57683. */
  57684. rebuild(): void;
  57685. /**
  57686. * Disposes the component and the associated ressources.
  57687. */
  57688. dispose(): void;
  57689. /**
  57690. * Renders the outline in the canvas.
  57691. * @param subMesh Defines the sumesh to render
  57692. * @param batch Defines the batch of meshes in case of instances
  57693. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57694. */
  57695. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57696. /**
  57697. * Returns whether or not the outline renderer is ready for a given submesh.
  57698. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57699. * @param subMesh Defines the submesh to check readyness for
  57700. * @param useInstances Defines wheter wee are trying to render instances or not
  57701. * @returns true if ready otherwise false
  57702. */
  57703. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57704. private _beforeRenderingMesh;
  57705. private _afterRenderingMesh;
  57706. }
  57707. }
  57708. declare module "babylonjs/Rendering/index" {
  57709. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57710. export * from "babylonjs/Rendering/depthRenderer";
  57711. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57712. export * from "babylonjs/Rendering/edgesRenderer";
  57713. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57714. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57715. export * from "babylonjs/Rendering/outlineRenderer";
  57716. export * from "babylonjs/Rendering/renderingGroup";
  57717. export * from "babylonjs/Rendering/renderingManager";
  57718. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57719. }
  57720. declare module "babylonjs/Sprites/index" {
  57721. export * from "babylonjs/Sprites/sprite";
  57722. export * from "babylonjs/Sprites/spriteManager";
  57723. export * from "babylonjs/Sprites/spriteSceneComponent";
  57724. }
  57725. declare module "babylonjs/Misc/assetsManager" {
  57726. import { Scene } from "babylonjs/scene";
  57727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57728. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57729. import { Skeleton } from "babylonjs/Bones/skeleton";
  57730. import { Observable } from "babylonjs/Misc/observable";
  57731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57732. import { Texture } from "babylonjs/Materials/Textures/texture";
  57733. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57734. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57735. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57736. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57737. /**
  57738. * Defines the list of states available for a task inside a AssetsManager
  57739. */
  57740. export enum AssetTaskState {
  57741. /**
  57742. * Initialization
  57743. */
  57744. INIT = 0,
  57745. /**
  57746. * Running
  57747. */
  57748. RUNNING = 1,
  57749. /**
  57750. * Done
  57751. */
  57752. DONE = 2,
  57753. /**
  57754. * Error
  57755. */
  57756. ERROR = 3
  57757. }
  57758. /**
  57759. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57760. */
  57761. export abstract class AbstractAssetTask {
  57762. /**
  57763. * Task name
  57764. */ name: string;
  57765. /**
  57766. * Callback called when the task is successful
  57767. */
  57768. onSuccess: (task: any) => void;
  57769. /**
  57770. * Callback called when the task is not successful
  57771. */
  57772. onError: (task: any, message?: string, exception?: any) => void;
  57773. /**
  57774. * Creates a new AssetsManager
  57775. * @param name defines the name of the task
  57776. */
  57777. constructor(
  57778. /**
  57779. * Task name
  57780. */ name: string);
  57781. private _isCompleted;
  57782. private _taskState;
  57783. private _errorObject;
  57784. /**
  57785. * Get if the task is completed
  57786. */
  57787. readonly isCompleted: boolean;
  57788. /**
  57789. * Gets the current state of the task
  57790. */
  57791. readonly taskState: AssetTaskState;
  57792. /**
  57793. * Gets the current error object (if task is in error)
  57794. */
  57795. readonly errorObject: {
  57796. message?: string;
  57797. exception?: any;
  57798. };
  57799. /**
  57800. * Internal only
  57801. * @hidden
  57802. */
  57803. _setErrorObject(message?: string, exception?: any): void;
  57804. /**
  57805. * Execute the current task
  57806. * @param scene defines the scene where you want your assets to be loaded
  57807. * @param onSuccess is a callback called when the task is successfully executed
  57808. * @param onError is a callback called if an error occurs
  57809. */
  57810. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57811. /**
  57812. * Execute the current task
  57813. * @param scene defines the scene where you want your assets to be loaded
  57814. * @param onSuccess is a callback called when the task is successfully executed
  57815. * @param onError is a callback called if an error occurs
  57816. */
  57817. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57818. /**
  57819. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57820. * This can be used with failed tasks that have the reason for failure fixed.
  57821. */
  57822. reset(): void;
  57823. private onErrorCallback;
  57824. private onDoneCallback;
  57825. }
  57826. /**
  57827. * Define the interface used by progress events raised during assets loading
  57828. */
  57829. export interface IAssetsProgressEvent {
  57830. /**
  57831. * Defines the number of remaining tasks to process
  57832. */
  57833. remainingCount: number;
  57834. /**
  57835. * Defines the total number of tasks
  57836. */
  57837. totalCount: number;
  57838. /**
  57839. * Defines the task that was just processed
  57840. */
  57841. task: AbstractAssetTask;
  57842. }
  57843. /**
  57844. * Class used to share progress information about assets loading
  57845. */
  57846. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57847. /**
  57848. * Defines the number of remaining tasks to process
  57849. */
  57850. remainingCount: number;
  57851. /**
  57852. * Defines the total number of tasks
  57853. */
  57854. totalCount: number;
  57855. /**
  57856. * Defines the task that was just processed
  57857. */
  57858. task: AbstractAssetTask;
  57859. /**
  57860. * Creates a AssetsProgressEvent
  57861. * @param remainingCount defines the number of remaining tasks to process
  57862. * @param totalCount defines the total number of tasks
  57863. * @param task defines the task that was just processed
  57864. */
  57865. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57866. }
  57867. /**
  57868. * Define a task used by AssetsManager to load meshes
  57869. */
  57870. export class MeshAssetTask extends AbstractAssetTask {
  57871. /**
  57872. * Defines the name of the task
  57873. */
  57874. name: string;
  57875. /**
  57876. * Defines the list of mesh's names you want to load
  57877. */
  57878. meshesNames: any;
  57879. /**
  57880. * Defines the root url to use as a base to load your meshes and associated resources
  57881. */
  57882. rootUrl: string;
  57883. /**
  57884. * Defines the filename of the scene to load from
  57885. */
  57886. sceneFilename: string;
  57887. /**
  57888. * Gets the list of loaded meshes
  57889. */
  57890. loadedMeshes: Array<AbstractMesh>;
  57891. /**
  57892. * Gets the list of loaded particle systems
  57893. */
  57894. loadedParticleSystems: Array<IParticleSystem>;
  57895. /**
  57896. * Gets the list of loaded skeletons
  57897. */
  57898. loadedSkeletons: Array<Skeleton>;
  57899. /**
  57900. * Gets the list of loaded animation groups
  57901. */
  57902. loadedAnimationGroups: Array<AnimationGroup>;
  57903. /**
  57904. * Callback called when the task is successful
  57905. */
  57906. onSuccess: (task: MeshAssetTask) => void;
  57907. /**
  57908. * Callback called when the task is successful
  57909. */
  57910. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57911. /**
  57912. * Creates a new MeshAssetTask
  57913. * @param name defines the name of the task
  57914. * @param meshesNames defines the list of mesh's names you want to load
  57915. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57916. * @param sceneFilename defines the filename of the scene to load from
  57917. */
  57918. constructor(
  57919. /**
  57920. * Defines the name of the task
  57921. */
  57922. name: string,
  57923. /**
  57924. * Defines the list of mesh's names you want to load
  57925. */
  57926. meshesNames: any,
  57927. /**
  57928. * Defines the root url to use as a base to load your meshes and associated resources
  57929. */
  57930. rootUrl: string,
  57931. /**
  57932. * Defines the filename of the scene to load from
  57933. */
  57934. sceneFilename: string);
  57935. /**
  57936. * Execute the current task
  57937. * @param scene defines the scene where you want your assets to be loaded
  57938. * @param onSuccess is a callback called when the task is successfully executed
  57939. * @param onError is a callback called if an error occurs
  57940. */
  57941. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57942. }
  57943. /**
  57944. * Define a task used by AssetsManager to load text content
  57945. */
  57946. export class TextFileAssetTask extends AbstractAssetTask {
  57947. /**
  57948. * Defines the name of the task
  57949. */
  57950. name: string;
  57951. /**
  57952. * Defines the location of the file to load
  57953. */
  57954. url: string;
  57955. /**
  57956. * Gets the loaded text string
  57957. */
  57958. text: string;
  57959. /**
  57960. * Callback called when the task is successful
  57961. */
  57962. onSuccess: (task: TextFileAssetTask) => void;
  57963. /**
  57964. * Callback called when the task is successful
  57965. */
  57966. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57967. /**
  57968. * Creates a new TextFileAssetTask object
  57969. * @param name defines the name of the task
  57970. * @param url defines the location of the file to load
  57971. */
  57972. constructor(
  57973. /**
  57974. * Defines the name of the task
  57975. */
  57976. name: string,
  57977. /**
  57978. * Defines the location of the file to load
  57979. */
  57980. url: string);
  57981. /**
  57982. * Execute the current task
  57983. * @param scene defines the scene where you want your assets to be loaded
  57984. * @param onSuccess is a callback called when the task is successfully executed
  57985. * @param onError is a callback called if an error occurs
  57986. */
  57987. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57988. }
  57989. /**
  57990. * Define a task used by AssetsManager to load binary data
  57991. */
  57992. export class BinaryFileAssetTask extends AbstractAssetTask {
  57993. /**
  57994. * Defines the name of the task
  57995. */
  57996. name: string;
  57997. /**
  57998. * Defines the location of the file to load
  57999. */
  58000. url: string;
  58001. /**
  58002. * Gets the lodaded data (as an array buffer)
  58003. */
  58004. data: ArrayBuffer;
  58005. /**
  58006. * Callback called when the task is successful
  58007. */
  58008. onSuccess: (task: BinaryFileAssetTask) => void;
  58009. /**
  58010. * Callback called when the task is successful
  58011. */
  58012. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58013. /**
  58014. * Creates a new BinaryFileAssetTask object
  58015. * @param name defines the name of the new task
  58016. * @param url defines the location of the file to load
  58017. */
  58018. constructor(
  58019. /**
  58020. * Defines the name of the task
  58021. */
  58022. name: string,
  58023. /**
  58024. * Defines the location of the file to load
  58025. */
  58026. url: string);
  58027. /**
  58028. * Execute the current task
  58029. * @param scene defines the scene where you want your assets to be loaded
  58030. * @param onSuccess is a callback called when the task is successfully executed
  58031. * @param onError is a callback called if an error occurs
  58032. */
  58033. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58034. }
  58035. /**
  58036. * Define a task used by AssetsManager to load images
  58037. */
  58038. export class ImageAssetTask extends AbstractAssetTask {
  58039. /**
  58040. * Defines the name of the task
  58041. */
  58042. name: string;
  58043. /**
  58044. * Defines the location of the image to load
  58045. */
  58046. url: string;
  58047. /**
  58048. * Gets the loaded images
  58049. */
  58050. image: HTMLImageElement;
  58051. /**
  58052. * Callback called when the task is successful
  58053. */
  58054. onSuccess: (task: ImageAssetTask) => void;
  58055. /**
  58056. * Callback called when the task is successful
  58057. */
  58058. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58059. /**
  58060. * Creates a new ImageAssetTask
  58061. * @param name defines the name of the task
  58062. * @param url defines the location of the image to load
  58063. */
  58064. constructor(
  58065. /**
  58066. * Defines the name of the task
  58067. */
  58068. name: string,
  58069. /**
  58070. * Defines the location of the image to load
  58071. */
  58072. url: string);
  58073. /**
  58074. * Execute the current task
  58075. * @param scene defines the scene where you want your assets to be loaded
  58076. * @param onSuccess is a callback called when the task is successfully executed
  58077. * @param onError is a callback called if an error occurs
  58078. */
  58079. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58080. }
  58081. /**
  58082. * Defines the interface used by texture loading tasks
  58083. */
  58084. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58085. /**
  58086. * Gets the loaded texture
  58087. */
  58088. texture: TEX;
  58089. }
  58090. /**
  58091. * Define a task used by AssetsManager to load 2D textures
  58092. */
  58093. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58094. /**
  58095. * Defines the name of the task
  58096. */
  58097. name: string;
  58098. /**
  58099. * Defines the location of the file to load
  58100. */
  58101. url: string;
  58102. /**
  58103. * Defines if mipmap should not be generated (default is false)
  58104. */
  58105. noMipmap?: boolean | undefined;
  58106. /**
  58107. * Defines if texture must be inverted on Y axis (default is false)
  58108. */
  58109. invertY?: boolean | undefined;
  58110. /**
  58111. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58112. */
  58113. samplingMode: number;
  58114. /**
  58115. * Gets the loaded texture
  58116. */
  58117. texture: Texture;
  58118. /**
  58119. * Callback called when the task is successful
  58120. */
  58121. onSuccess: (task: TextureAssetTask) => void;
  58122. /**
  58123. * Callback called when the task is successful
  58124. */
  58125. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58126. /**
  58127. * Creates a new TextureAssetTask object
  58128. * @param name defines the name of the task
  58129. * @param url defines the location of the file to load
  58130. * @param noMipmap defines if mipmap should not be generated (default is false)
  58131. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58132. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58133. */
  58134. constructor(
  58135. /**
  58136. * Defines the name of the task
  58137. */
  58138. name: string,
  58139. /**
  58140. * Defines the location of the file to load
  58141. */
  58142. url: string,
  58143. /**
  58144. * Defines if mipmap should not be generated (default is false)
  58145. */
  58146. noMipmap?: boolean | undefined,
  58147. /**
  58148. * Defines if texture must be inverted on Y axis (default is false)
  58149. */
  58150. invertY?: boolean | undefined,
  58151. /**
  58152. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58153. */
  58154. samplingMode?: number);
  58155. /**
  58156. * Execute the current task
  58157. * @param scene defines the scene where you want your assets to be loaded
  58158. * @param onSuccess is a callback called when the task is successfully executed
  58159. * @param onError is a callback called if an error occurs
  58160. */
  58161. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58162. }
  58163. /**
  58164. * Define a task used by AssetsManager to load cube textures
  58165. */
  58166. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58167. /**
  58168. * Defines the name of the task
  58169. */
  58170. name: string;
  58171. /**
  58172. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58173. */
  58174. url: string;
  58175. /**
  58176. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58177. */
  58178. extensions?: string[] | undefined;
  58179. /**
  58180. * Defines if mipmaps should not be generated (default is false)
  58181. */
  58182. noMipmap?: boolean | undefined;
  58183. /**
  58184. * Defines the explicit list of files (undefined by default)
  58185. */
  58186. files?: string[] | undefined;
  58187. /**
  58188. * Gets the loaded texture
  58189. */
  58190. texture: CubeTexture;
  58191. /**
  58192. * Callback called when the task is successful
  58193. */
  58194. onSuccess: (task: CubeTextureAssetTask) => void;
  58195. /**
  58196. * Callback called when the task is successful
  58197. */
  58198. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58199. /**
  58200. * Creates a new CubeTextureAssetTask
  58201. * @param name defines the name of the task
  58202. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58203. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58204. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58205. * @param files defines the explicit list of files (undefined by default)
  58206. */
  58207. constructor(
  58208. /**
  58209. * Defines the name of the task
  58210. */
  58211. name: string,
  58212. /**
  58213. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58214. */
  58215. url: string,
  58216. /**
  58217. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58218. */
  58219. extensions?: string[] | undefined,
  58220. /**
  58221. * Defines if mipmaps should not be generated (default is false)
  58222. */
  58223. noMipmap?: boolean | undefined,
  58224. /**
  58225. * Defines the explicit list of files (undefined by default)
  58226. */
  58227. files?: string[] | undefined);
  58228. /**
  58229. * Execute the current task
  58230. * @param scene defines the scene where you want your assets to be loaded
  58231. * @param onSuccess is a callback called when the task is successfully executed
  58232. * @param onError is a callback called if an error occurs
  58233. */
  58234. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58235. }
  58236. /**
  58237. * Define a task used by AssetsManager to load HDR cube textures
  58238. */
  58239. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58240. /**
  58241. * Defines the name of the task
  58242. */
  58243. name: string;
  58244. /**
  58245. * Defines the location of the file to load
  58246. */
  58247. url: string;
  58248. /**
  58249. * Defines the desired size (the more it increases the longer the generation will be)
  58250. */
  58251. size: number;
  58252. /**
  58253. * Defines if mipmaps should not be generated (default is false)
  58254. */
  58255. noMipmap: boolean;
  58256. /**
  58257. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58258. */
  58259. generateHarmonics: boolean;
  58260. /**
  58261. * 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)
  58262. */
  58263. gammaSpace: boolean;
  58264. /**
  58265. * Internal Use Only
  58266. */
  58267. reserved: boolean;
  58268. /**
  58269. * Gets the loaded texture
  58270. */
  58271. texture: HDRCubeTexture;
  58272. /**
  58273. * Callback called when the task is successful
  58274. */
  58275. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58276. /**
  58277. * Callback called when the task is successful
  58278. */
  58279. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58280. /**
  58281. * Creates a new HDRCubeTextureAssetTask object
  58282. * @param name defines the name of the task
  58283. * @param url defines the location of the file to load
  58284. * @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.
  58285. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58286. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58287. * @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)
  58288. * @param reserved Internal use only
  58289. */
  58290. constructor(
  58291. /**
  58292. * Defines the name of the task
  58293. */
  58294. name: string,
  58295. /**
  58296. * Defines the location of the file to load
  58297. */
  58298. url: string,
  58299. /**
  58300. * Defines the desired size (the more it increases the longer the generation will be)
  58301. */
  58302. size: number,
  58303. /**
  58304. * Defines if mipmaps should not be generated (default is false)
  58305. */
  58306. noMipmap?: boolean,
  58307. /**
  58308. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58309. */
  58310. generateHarmonics?: boolean,
  58311. /**
  58312. * 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)
  58313. */
  58314. gammaSpace?: boolean,
  58315. /**
  58316. * Internal Use Only
  58317. */
  58318. reserved?: boolean);
  58319. /**
  58320. * Execute the current task
  58321. * @param scene defines the scene where you want your assets to be loaded
  58322. * @param onSuccess is a callback called when the task is successfully executed
  58323. * @param onError is a callback called if an error occurs
  58324. */
  58325. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58326. }
  58327. /**
  58328. * Define a task used by AssetsManager to load Equirectangular cube textures
  58329. */
  58330. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58331. /**
  58332. * Defines the name of the task
  58333. */
  58334. name: string;
  58335. /**
  58336. * Defines the location of the file to load
  58337. */
  58338. url: string;
  58339. /**
  58340. * Defines the desired size (the more it increases the longer the generation will be)
  58341. */
  58342. size: number;
  58343. /**
  58344. * Defines if mipmaps should not be generated (default is false)
  58345. */
  58346. noMipmap: boolean;
  58347. /**
  58348. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58349. * but the standard material would require them in Gamma space) (default is true)
  58350. */
  58351. gammaSpace: boolean;
  58352. /**
  58353. * Gets the loaded texture
  58354. */
  58355. texture: EquiRectangularCubeTexture;
  58356. /**
  58357. * Callback called when the task is successful
  58358. */
  58359. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58360. /**
  58361. * Callback called when the task is successful
  58362. */
  58363. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58364. /**
  58365. * Creates a new EquiRectangularCubeTextureAssetTask object
  58366. * @param name defines the name of the task
  58367. * @param url defines the location of the file to load
  58368. * @param size defines the desired size (the more it increases the longer the generation will be)
  58369. * If the size is omitted this implies you are using a preprocessed cubemap.
  58370. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58371. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58372. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58373. * (default is true)
  58374. */
  58375. constructor(
  58376. /**
  58377. * Defines the name of the task
  58378. */
  58379. name: string,
  58380. /**
  58381. * Defines the location of the file to load
  58382. */
  58383. url: string,
  58384. /**
  58385. * Defines the desired size (the more it increases the longer the generation will be)
  58386. */
  58387. size: number,
  58388. /**
  58389. * Defines if mipmaps should not be generated (default is false)
  58390. */
  58391. noMipmap?: boolean,
  58392. /**
  58393. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58394. * but the standard material would require them in Gamma space) (default is true)
  58395. */
  58396. gammaSpace?: boolean);
  58397. /**
  58398. * Execute the current task
  58399. * @param scene defines the scene where you want your assets to be loaded
  58400. * @param onSuccess is a callback called when the task is successfully executed
  58401. * @param onError is a callback called if an error occurs
  58402. */
  58403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58404. }
  58405. /**
  58406. * This class can be used to easily import assets into a scene
  58407. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58408. */
  58409. export class AssetsManager {
  58410. private _scene;
  58411. private _isLoading;
  58412. protected _tasks: AbstractAssetTask[];
  58413. protected _waitingTasksCount: number;
  58414. protected _totalTasksCount: number;
  58415. /**
  58416. * Callback called when all tasks are processed
  58417. */
  58418. onFinish: (tasks: AbstractAssetTask[]) => void;
  58419. /**
  58420. * Callback called when a task is successful
  58421. */
  58422. onTaskSuccess: (task: AbstractAssetTask) => void;
  58423. /**
  58424. * Callback called when a task had an error
  58425. */
  58426. onTaskError: (task: AbstractAssetTask) => void;
  58427. /**
  58428. * Callback called when a task is done (whatever the result is)
  58429. */
  58430. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58431. /**
  58432. * Observable called when all tasks are processed
  58433. */
  58434. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58435. /**
  58436. * Observable called when a task had an error
  58437. */
  58438. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58439. /**
  58440. * Observable called when all tasks were executed
  58441. */
  58442. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58443. /**
  58444. * Observable called when a task is done (whatever the result is)
  58445. */
  58446. onProgressObservable: Observable<IAssetsProgressEvent>;
  58447. /**
  58448. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58449. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58450. */
  58451. useDefaultLoadingScreen: boolean;
  58452. /**
  58453. * Creates a new AssetsManager
  58454. * @param scene defines the scene to work on
  58455. */
  58456. constructor(scene: Scene);
  58457. /**
  58458. * Add a MeshAssetTask to the list of active tasks
  58459. * @param taskName defines the name of the new task
  58460. * @param meshesNames defines the name of meshes to load
  58461. * @param rootUrl defines the root url to use to locate files
  58462. * @param sceneFilename defines the filename of the scene file
  58463. * @returns a new MeshAssetTask object
  58464. */
  58465. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58466. /**
  58467. * Add a TextFileAssetTask to the list of active tasks
  58468. * @param taskName defines the name of the new task
  58469. * @param url defines the url of the file to load
  58470. * @returns a new TextFileAssetTask object
  58471. */
  58472. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58473. /**
  58474. * Add a BinaryFileAssetTask to the list of active tasks
  58475. * @param taskName defines the name of the new task
  58476. * @param url defines the url of the file to load
  58477. * @returns a new BinaryFileAssetTask object
  58478. */
  58479. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58480. /**
  58481. * Add a ImageAssetTask to the list of active tasks
  58482. * @param taskName defines the name of the new task
  58483. * @param url defines the url of the file to load
  58484. * @returns a new ImageAssetTask object
  58485. */
  58486. addImageTask(taskName: string, url: string): ImageAssetTask;
  58487. /**
  58488. * Add a TextureAssetTask to the list of active tasks
  58489. * @param taskName defines the name of the new task
  58490. * @param url defines the url of the file to load
  58491. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58492. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58493. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58494. * @returns a new TextureAssetTask object
  58495. */
  58496. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58497. /**
  58498. * Add a CubeTextureAssetTask to the list of active tasks
  58499. * @param taskName defines the name of the new task
  58500. * @param url defines the url of the file to load
  58501. * @param extensions defines the extension to use to load the cube map (can be null)
  58502. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58503. * @param files defines the list of files to load (can be null)
  58504. * @returns a new CubeTextureAssetTask object
  58505. */
  58506. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58507. /**
  58508. *
  58509. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58510. * @param taskName defines the name of the new task
  58511. * @param url defines the url of the file to load
  58512. * @param size defines the size you want for the cubemap (can be null)
  58513. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58514. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58515. * @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)
  58516. * @param reserved Internal use only
  58517. * @returns a new HDRCubeTextureAssetTask object
  58518. */
  58519. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58520. /**
  58521. *
  58522. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58523. * @param taskName defines the name of the new task
  58524. * @param url defines the url of the file to load
  58525. * @param size defines the size you want for the cubemap (can be null)
  58526. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58527. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58528. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58529. * @returns a new EquiRectangularCubeTextureAssetTask object
  58530. */
  58531. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58532. /**
  58533. * Remove a task from the assets manager.
  58534. * @param task the task to remove
  58535. */
  58536. removeTask(task: AbstractAssetTask): void;
  58537. private _decreaseWaitingTasksCount;
  58538. private _runTask;
  58539. /**
  58540. * Reset the AssetsManager and remove all tasks
  58541. * @return the current instance of the AssetsManager
  58542. */
  58543. reset(): AssetsManager;
  58544. /**
  58545. * Start the loading process
  58546. * @return the current instance of the AssetsManager
  58547. */
  58548. load(): AssetsManager;
  58549. /**
  58550. * Start the loading process as an async operation
  58551. * @return a promise returning the list of failed tasks
  58552. */
  58553. loadAsync(): Promise<void>;
  58554. }
  58555. }
  58556. declare module "babylonjs/Misc/deferred" {
  58557. /**
  58558. * Wrapper class for promise with external resolve and reject.
  58559. */
  58560. export class Deferred<T> {
  58561. /**
  58562. * The promise associated with this deferred object.
  58563. */
  58564. readonly promise: Promise<T>;
  58565. private _resolve;
  58566. private _reject;
  58567. /**
  58568. * The resolve method of the promise associated with this deferred object.
  58569. */
  58570. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58571. /**
  58572. * The reject method of the promise associated with this deferred object.
  58573. */
  58574. readonly reject: (reason?: any) => void;
  58575. /**
  58576. * Constructor for this deferred object.
  58577. */
  58578. constructor();
  58579. }
  58580. }
  58581. declare module "babylonjs/Misc/meshExploder" {
  58582. import { Mesh } from "babylonjs/Meshes/mesh";
  58583. /**
  58584. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58585. */
  58586. export class MeshExploder {
  58587. private _centerMesh;
  58588. private _meshes;
  58589. private _meshesOrigins;
  58590. private _toCenterVectors;
  58591. private _scaledDirection;
  58592. private _newPosition;
  58593. private _centerPosition;
  58594. /**
  58595. * Explodes meshes from a center mesh.
  58596. * @param meshes The meshes to explode.
  58597. * @param centerMesh The mesh to be center of explosion.
  58598. */
  58599. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58600. private _setCenterMesh;
  58601. /**
  58602. * Get class name
  58603. * @returns "MeshExploder"
  58604. */
  58605. getClassName(): string;
  58606. /**
  58607. * "Exploded meshes"
  58608. * @returns Array of meshes with the centerMesh at index 0.
  58609. */
  58610. getMeshes(): Array<Mesh>;
  58611. /**
  58612. * Explodes meshes giving a specific direction
  58613. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58614. */
  58615. explode(direction?: number): void;
  58616. }
  58617. }
  58618. declare module "babylonjs/Misc/filesInput" {
  58619. import { Engine } from "babylonjs/Engines/engine";
  58620. import { Scene } from "babylonjs/scene";
  58621. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58622. /**
  58623. * Class used to help managing file picking and drag'n'drop
  58624. */
  58625. export class FilesInput {
  58626. /**
  58627. * List of files ready to be loaded
  58628. */
  58629. static readonly FilesToLoad: {
  58630. [key: string]: File;
  58631. };
  58632. /**
  58633. * Callback called when a file is processed
  58634. */
  58635. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58636. private _engine;
  58637. private _currentScene;
  58638. private _sceneLoadedCallback;
  58639. private _progressCallback;
  58640. private _additionalRenderLoopLogicCallback;
  58641. private _textureLoadingCallback;
  58642. private _startingProcessingFilesCallback;
  58643. private _onReloadCallback;
  58644. private _errorCallback;
  58645. private _elementToMonitor;
  58646. private _sceneFileToLoad;
  58647. private _filesToLoad;
  58648. /**
  58649. * Creates a new FilesInput
  58650. * @param engine defines the rendering engine
  58651. * @param scene defines the hosting scene
  58652. * @param sceneLoadedCallback callback called when scene is loaded
  58653. * @param progressCallback callback called to track progress
  58654. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58655. * @param textureLoadingCallback callback called when a texture is loading
  58656. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58657. * @param onReloadCallback callback called when a reload is requested
  58658. * @param errorCallback callback call if an error occurs
  58659. */
  58660. 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);
  58661. private _dragEnterHandler;
  58662. private _dragOverHandler;
  58663. private _dropHandler;
  58664. /**
  58665. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58666. * @param elementToMonitor defines the DOM element to track
  58667. */
  58668. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58669. /**
  58670. * Release all associated resources
  58671. */
  58672. dispose(): void;
  58673. private renderFunction;
  58674. private drag;
  58675. private drop;
  58676. private _traverseFolder;
  58677. private _processFiles;
  58678. /**
  58679. * Load files from a drop event
  58680. * @param event defines the drop event to use as source
  58681. */
  58682. loadFiles(event: any): void;
  58683. private _processReload;
  58684. /**
  58685. * Reload the current scene from the loaded files
  58686. */
  58687. reload(): void;
  58688. }
  58689. }
  58690. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58691. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58692. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58693. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58694. }
  58695. declare module "babylonjs/Misc/sceneOptimizer" {
  58696. import { Scene, IDisposable } from "babylonjs/scene";
  58697. import { Observable } from "babylonjs/Misc/observable";
  58698. /**
  58699. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58700. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58701. */
  58702. export class SceneOptimization {
  58703. /**
  58704. * Defines the priority of this optimization (0 by default which means first in the list)
  58705. */
  58706. priority: number;
  58707. /**
  58708. * Gets a string describing the action executed by the current optimization
  58709. * @returns description string
  58710. */
  58711. getDescription(): string;
  58712. /**
  58713. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58714. * @param scene defines the current scene where to apply this optimization
  58715. * @param optimizer defines the current optimizer
  58716. * @returns true if everything that can be done was applied
  58717. */
  58718. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58719. /**
  58720. * Creates the SceneOptimization object
  58721. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58722. * @param desc defines the description associated with the optimization
  58723. */
  58724. constructor(
  58725. /**
  58726. * Defines the priority of this optimization (0 by default which means first in the list)
  58727. */
  58728. priority?: number);
  58729. }
  58730. /**
  58731. * Defines an optimization used to reduce the size of render target textures
  58732. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58733. */
  58734. export class TextureOptimization extends SceneOptimization {
  58735. /**
  58736. * Defines the priority of this optimization (0 by default which means first in the list)
  58737. */
  58738. priority: number;
  58739. /**
  58740. * 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
  58741. */
  58742. maximumSize: number;
  58743. /**
  58744. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58745. */
  58746. step: number;
  58747. /**
  58748. * Gets a string describing the action executed by the current optimization
  58749. * @returns description string
  58750. */
  58751. getDescription(): string;
  58752. /**
  58753. * Creates the TextureOptimization object
  58754. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58755. * @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
  58756. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58757. */
  58758. constructor(
  58759. /**
  58760. * Defines the priority of this optimization (0 by default which means first in the list)
  58761. */
  58762. priority?: number,
  58763. /**
  58764. * 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
  58765. */
  58766. maximumSize?: number,
  58767. /**
  58768. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58769. */
  58770. step?: number);
  58771. /**
  58772. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58773. * @param scene defines the current scene where to apply this optimization
  58774. * @param optimizer defines the current optimizer
  58775. * @returns true if everything that can be done was applied
  58776. */
  58777. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58778. }
  58779. /**
  58780. * Defines an optimization used to increase or decrease the rendering resolution
  58781. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58782. */
  58783. export class HardwareScalingOptimization extends SceneOptimization {
  58784. /**
  58785. * Defines the priority of this optimization (0 by default which means first in the list)
  58786. */
  58787. priority: number;
  58788. /**
  58789. * Defines the maximum scale to use (2 by default)
  58790. */
  58791. maximumScale: number;
  58792. /**
  58793. * Defines the step to use between two passes (0.5 by default)
  58794. */
  58795. step: number;
  58796. private _currentScale;
  58797. private _directionOffset;
  58798. /**
  58799. * Gets a string describing the action executed by the current optimization
  58800. * @return description string
  58801. */
  58802. getDescription(): string;
  58803. /**
  58804. * Creates the HardwareScalingOptimization object
  58805. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58806. * @param maximumScale defines the maximum scale to use (2 by default)
  58807. * @param step defines the step to use between two passes (0.5 by default)
  58808. */
  58809. constructor(
  58810. /**
  58811. * Defines the priority of this optimization (0 by default which means first in the list)
  58812. */
  58813. priority?: number,
  58814. /**
  58815. * Defines the maximum scale to use (2 by default)
  58816. */
  58817. maximumScale?: number,
  58818. /**
  58819. * Defines the step to use between two passes (0.5 by default)
  58820. */
  58821. step?: number);
  58822. /**
  58823. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58824. * @param scene defines the current scene where to apply this optimization
  58825. * @param optimizer defines the current optimizer
  58826. * @returns true if everything that can be done was applied
  58827. */
  58828. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58829. }
  58830. /**
  58831. * Defines an optimization used to remove shadows
  58832. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58833. */
  58834. export class ShadowsOptimization extends SceneOptimization {
  58835. /**
  58836. * Gets a string describing the action executed by the current optimization
  58837. * @return description string
  58838. */
  58839. getDescription(): string;
  58840. /**
  58841. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58842. * @param scene defines the current scene where to apply this optimization
  58843. * @param optimizer defines the current optimizer
  58844. * @returns true if everything that can be done was applied
  58845. */
  58846. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58847. }
  58848. /**
  58849. * Defines an optimization used to turn post-processes off
  58850. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58851. */
  58852. export class PostProcessesOptimization extends SceneOptimization {
  58853. /**
  58854. * Gets a string describing the action executed by the current optimization
  58855. * @return description string
  58856. */
  58857. getDescription(): string;
  58858. /**
  58859. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58860. * @param scene defines the current scene where to apply this optimization
  58861. * @param optimizer defines the current optimizer
  58862. * @returns true if everything that can be done was applied
  58863. */
  58864. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58865. }
  58866. /**
  58867. * Defines an optimization used to turn lens flares off
  58868. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58869. */
  58870. export class LensFlaresOptimization extends SceneOptimization {
  58871. /**
  58872. * Gets a string describing the action executed by the current optimization
  58873. * @return description string
  58874. */
  58875. getDescription(): string;
  58876. /**
  58877. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58878. * @param scene defines the current scene where to apply this optimization
  58879. * @param optimizer defines the current optimizer
  58880. * @returns true if everything that can be done was applied
  58881. */
  58882. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58883. }
  58884. /**
  58885. * Defines an optimization based on user defined callback.
  58886. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58887. */
  58888. export class CustomOptimization extends SceneOptimization {
  58889. /**
  58890. * Callback called to apply the custom optimization.
  58891. */
  58892. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58893. /**
  58894. * Callback called to get custom description
  58895. */
  58896. onGetDescription: () => string;
  58897. /**
  58898. * Gets a string describing the action executed by the current optimization
  58899. * @returns description string
  58900. */
  58901. getDescription(): string;
  58902. /**
  58903. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58904. * @param scene defines the current scene where to apply this optimization
  58905. * @param optimizer defines the current optimizer
  58906. * @returns true if everything that can be done was applied
  58907. */
  58908. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58909. }
  58910. /**
  58911. * Defines an optimization used to turn particles off
  58912. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58913. */
  58914. export class ParticlesOptimization extends SceneOptimization {
  58915. /**
  58916. * Gets a string describing the action executed by the current optimization
  58917. * @return description string
  58918. */
  58919. getDescription(): string;
  58920. /**
  58921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58922. * @param scene defines the current scene where to apply this optimization
  58923. * @param optimizer defines the current optimizer
  58924. * @returns true if everything that can be done was applied
  58925. */
  58926. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58927. }
  58928. /**
  58929. * Defines an optimization used to turn render targets off
  58930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58931. */
  58932. export class RenderTargetsOptimization extends SceneOptimization {
  58933. /**
  58934. * Gets a string describing the action executed by the current optimization
  58935. * @return description string
  58936. */
  58937. getDescription(): string;
  58938. /**
  58939. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58940. * @param scene defines the current scene where to apply this optimization
  58941. * @param optimizer defines the current optimizer
  58942. * @returns true if everything that can be done was applied
  58943. */
  58944. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58945. }
  58946. /**
  58947. * Defines an optimization used to merge meshes with compatible materials
  58948. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58949. */
  58950. export class MergeMeshesOptimization extends SceneOptimization {
  58951. private static _UpdateSelectionTree;
  58952. /**
  58953. * Gets or sets a boolean which defines if optimization octree has to be updated
  58954. */
  58955. /**
  58956. * Gets or sets a boolean which defines if optimization octree has to be updated
  58957. */
  58958. static UpdateSelectionTree: boolean;
  58959. /**
  58960. * Gets a string describing the action executed by the current optimization
  58961. * @return description string
  58962. */
  58963. getDescription(): string;
  58964. private _canBeMerged;
  58965. /**
  58966. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58967. * @param scene defines the current scene where to apply this optimization
  58968. * @param optimizer defines the current optimizer
  58969. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58970. * @returns true if everything that can be done was applied
  58971. */
  58972. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58973. }
  58974. /**
  58975. * Defines a list of options used by SceneOptimizer
  58976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58977. */
  58978. export class SceneOptimizerOptions {
  58979. /**
  58980. * Defines the target frame rate to reach (60 by default)
  58981. */
  58982. targetFrameRate: number;
  58983. /**
  58984. * Defines the interval between two checkes (2000ms by default)
  58985. */
  58986. trackerDuration: number;
  58987. /**
  58988. * Gets the list of optimizations to apply
  58989. */
  58990. optimizations: SceneOptimization[];
  58991. /**
  58992. * Creates a new list of options used by SceneOptimizer
  58993. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58994. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58995. */
  58996. constructor(
  58997. /**
  58998. * Defines the target frame rate to reach (60 by default)
  58999. */
  59000. targetFrameRate?: number,
  59001. /**
  59002. * Defines the interval between two checkes (2000ms by default)
  59003. */
  59004. trackerDuration?: number);
  59005. /**
  59006. * Add a new optimization
  59007. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59008. * @returns the current SceneOptimizerOptions
  59009. */
  59010. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59011. /**
  59012. * Add a new custom optimization
  59013. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59014. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59015. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59016. * @returns the current SceneOptimizerOptions
  59017. */
  59018. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59019. /**
  59020. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59021. * @param targetFrameRate defines the target frame rate (60 by default)
  59022. * @returns a SceneOptimizerOptions object
  59023. */
  59024. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59025. /**
  59026. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59027. * @param targetFrameRate defines the target frame rate (60 by default)
  59028. * @returns a SceneOptimizerOptions object
  59029. */
  59030. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59031. /**
  59032. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59033. * @param targetFrameRate defines the target frame rate (60 by default)
  59034. * @returns a SceneOptimizerOptions object
  59035. */
  59036. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59037. }
  59038. /**
  59039. * Class used to run optimizations in order to reach a target frame rate
  59040. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59041. */
  59042. export class SceneOptimizer implements IDisposable {
  59043. private _isRunning;
  59044. private _options;
  59045. private _scene;
  59046. private _currentPriorityLevel;
  59047. private _targetFrameRate;
  59048. private _trackerDuration;
  59049. private _currentFrameRate;
  59050. private _sceneDisposeObserver;
  59051. private _improvementMode;
  59052. /**
  59053. * Defines an observable called when the optimizer reaches the target frame rate
  59054. */
  59055. onSuccessObservable: Observable<SceneOptimizer>;
  59056. /**
  59057. * Defines an observable called when the optimizer enables an optimization
  59058. */
  59059. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59060. /**
  59061. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59062. */
  59063. onFailureObservable: Observable<SceneOptimizer>;
  59064. /**
  59065. * Gets a boolean indicating if the optimizer is in improvement mode
  59066. */
  59067. readonly isInImprovementMode: boolean;
  59068. /**
  59069. * Gets the current priority level (0 at start)
  59070. */
  59071. readonly currentPriorityLevel: number;
  59072. /**
  59073. * Gets the current frame rate checked by the SceneOptimizer
  59074. */
  59075. readonly currentFrameRate: number;
  59076. /**
  59077. * Gets or sets the current target frame rate (60 by default)
  59078. */
  59079. /**
  59080. * Gets or sets the current target frame rate (60 by default)
  59081. */
  59082. targetFrameRate: number;
  59083. /**
  59084. * Gets or sets the current interval between two checks (every 2000ms by default)
  59085. */
  59086. /**
  59087. * Gets or sets the current interval between two checks (every 2000ms by default)
  59088. */
  59089. trackerDuration: number;
  59090. /**
  59091. * Gets the list of active optimizations
  59092. */
  59093. readonly optimizations: SceneOptimization[];
  59094. /**
  59095. * Creates a new SceneOptimizer
  59096. * @param scene defines the scene to work on
  59097. * @param options defines the options to use with the SceneOptimizer
  59098. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59099. * @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)
  59100. */
  59101. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59102. /**
  59103. * Stops the current optimizer
  59104. */
  59105. stop(): void;
  59106. /**
  59107. * Reset the optimizer to initial step (current priority level = 0)
  59108. */
  59109. reset(): void;
  59110. /**
  59111. * Start the optimizer. By default it will try to reach a specific framerate
  59112. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59113. */
  59114. start(): void;
  59115. private _checkCurrentState;
  59116. /**
  59117. * Release all resources
  59118. */
  59119. dispose(): void;
  59120. /**
  59121. * Helper function to create a SceneOptimizer with one single line of code
  59122. * @param scene defines the scene to work on
  59123. * @param options defines the options to use with the SceneOptimizer
  59124. * @param onSuccess defines a callback to call on success
  59125. * @param onFailure defines a callback to call on failure
  59126. * @returns the new SceneOptimizer object
  59127. */
  59128. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59129. }
  59130. }
  59131. declare module "babylonjs/Misc/sceneSerializer" {
  59132. import { Scene } from "babylonjs/scene";
  59133. /**
  59134. * Class used to serialize a scene into a string
  59135. */
  59136. export class SceneSerializer {
  59137. /**
  59138. * Clear cache used by a previous serialization
  59139. */
  59140. static ClearCache(): void;
  59141. /**
  59142. * Serialize a scene into a JSON compatible object
  59143. * @param scene defines the scene to serialize
  59144. * @returns a JSON compatible object
  59145. */
  59146. static Serialize(scene: Scene): any;
  59147. /**
  59148. * Serialize a mesh into a JSON compatible object
  59149. * @param toSerialize defines the mesh to serialize
  59150. * @param withParents defines if parents must be serialized as well
  59151. * @param withChildren defines if children must be serialized as well
  59152. * @returns a JSON compatible object
  59153. */
  59154. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59155. }
  59156. }
  59157. declare module "babylonjs/Misc/textureTools" {
  59158. import { Texture } from "babylonjs/Materials/Textures/texture";
  59159. /**
  59160. * Class used to host texture specific utilities
  59161. */
  59162. export class TextureTools {
  59163. /**
  59164. * Uses the GPU to create a copy texture rescaled at a given size
  59165. * @param texture Texture to copy from
  59166. * @param width defines the desired width
  59167. * @param height defines the desired height
  59168. * @param useBilinearMode defines if bilinear mode has to be used
  59169. * @return the generated texture
  59170. */
  59171. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59172. }
  59173. }
  59174. declare module "babylonjs/Misc/videoRecorder" {
  59175. import { Nullable } from "babylonjs/types";
  59176. import { Engine } from "babylonjs/Engines/engine";
  59177. /**
  59178. * This represents the different options avilable for the video capture.
  59179. */
  59180. export interface VideoRecorderOptions {
  59181. /** Defines the mime type of the video */
  59182. mimeType: string;
  59183. /** Defines the video the video should be recorded at */
  59184. fps: number;
  59185. /** Defines the chunk size for the recording data */
  59186. recordChunckSize: number;
  59187. /** The audio tracks to attach to the record */
  59188. audioTracks?: MediaStreamTrack[];
  59189. }
  59190. /**
  59191. * This can helps recording videos from BabylonJS.
  59192. * This is based on the available WebRTC functionalities of the browser.
  59193. *
  59194. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59195. */
  59196. export class VideoRecorder {
  59197. private static readonly _defaultOptions;
  59198. /**
  59199. * Returns wehther or not the VideoRecorder is available in your browser.
  59200. * @param engine Defines the Babylon Engine to check the support for
  59201. * @returns true if supported otherwise false
  59202. */
  59203. static IsSupported(engine: Engine): boolean;
  59204. private readonly _options;
  59205. private _canvas;
  59206. private _mediaRecorder;
  59207. private _recordedChunks;
  59208. private _fileName;
  59209. private _resolve;
  59210. private _reject;
  59211. /**
  59212. * True wether a recording is already in progress.
  59213. */
  59214. readonly isRecording: boolean;
  59215. /**
  59216. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59217. * a video file.
  59218. * @param engine Defines the BabylonJS Engine you wish to record
  59219. * @param options Defines options that can be used to customized the capture
  59220. */
  59221. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59222. /**
  59223. * Stops the current recording before the default capture timeout passed in the startRecording
  59224. * functions.
  59225. */
  59226. stopRecording(): void;
  59227. /**
  59228. * Starts recording the canvas for a max duration specified in parameters.
  59229. * @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.
  59230. * @param maxDuration Defines the maximum recording time in seconds.
  59231. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59232. * @return a promise callback at the end of the recording with the video data in Blob.
  59233. */
  59234. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59235. /**
  59236. * Releases internal resources used during the recording.
  59237. */
  59238. dispose(): void;
  59239. private _handleDataAvailable;
  59240. private _handleError;
  59241. private _handleStop;
  59242. }
  59243. }
  59244. declare module "babylonjs/Misc/screenshotTools" {
  59245. import { Camera } from "babylonjs/Cameras/camera";
  59246. import { Engine } from "babylonjs/Engines/engine";
  59247. /**
  59248. * Class containing a set of static utilities functions for screenshots
  59249. */
  59250. export class ScreenshotTools {
  59251. /**
  59252. * Captures a screenshot of the current rendering
  59253. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59254. * @param engine defines the rendering engine
  59255. * @param camera defines the source camera
  59256. * @param size This parameter can be set to a single number or to an object with the
  59257. * following (optional) properties: precision, width, height. If a single number is passed,
  59258. * it will be used for both width and height. If an object is passed, the screenshot size
  59259. * will be derived from the parameters. The precision property is a multiplier allowing
  59260. * rendering at a higher or lower resolution
  59261. * @param successCallback defines the callback receives a single parameter which contains the
  59262. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59263. * src parameter of an <img> to display it
  59264. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59265. * Check your browser for supported MIME types
  59266. */
  59267. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59268. /**
  59269. * Generates an image screenshot from the specified camera.
  59270. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59271. * @param engine The engine to use for rendering
  59272. * @param camera The camera to use for rendering
  59273. * @param size This parameter can be set to a single number or to an object with the
  59274. * following (optional) properties: precision, width, height. If a single number is passed,
  59275. * it will be used for both width and height. If an object is passed, the screenshot size
  59276. * will be derived from the parameters. The precision property is a multiplier allowing
  59277. * rendering at a higher or lower resolution
  59278. * @param successCallback The callback receives a single parameter which contains the
  59279. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59280. * src parameter of an <img> to display it
  59281. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59282. * Check your browser for supported MIME types
  59283. * @param samples Texture samples (default: 1)
  59284. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59285. * @param fileName A name for for the downloaded file.
  59286. */
  59287. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59288. }
  59289. }
  59290. declare module "babylonjs/Misc/index" {
  59291. export * from "babylonjs/Misc/andOrNotEvaluator";
  59292. export * from "babylonjs/Misc/assetsManager";
  59293. export * from "babylonjs/Misc/dds";
  59294. export * from "babylonjs/Misc/decorators";
  59295. export * from "babylonjs/Misc/deferred";
  59296. export * from "babylonjs/Misc/environmentTextureTools";
  59297. export * from "babylonjs/Misc/meshExploder";
  59298. export * from "babylonjs/Misc/filesInput";
  59299. export * from "babylonjs/Misc/HighDynamicRange/index";
  59300. export * from "babylonjs/Misc/khronosTextureContainer";
  59301. export * from "babylonjs/Misc/observable";
  59302. export * from "babylonjs/Misc/performanceMonitor";
  59303. export * from "babylonjs/Misc/promise";
  59304. export * from "babylonjs/Misc/sceneOptimizer";
  59305. export * from "babylonjs/Misc/sceneSerializer";
  59306. export * from "babylonjs/Misc/smartArray";
  59307. export * from "babylonjs/Misc/stringDictionary";
  59308. export * from "babylonjs/Misc/tags";
  59309. export * from "babylonjs/Misc/textureTools";
  59310. export * from "babylonjs/Misc/tga";
  59311. export * from "babylonjs/Misc/tools";
  59312. export * from "babylonjs/Misc/videoRecorder";
  59313. export * from "babylonjs/Misc/virtualJoystick";
  59314. export * from "babylonjs/Misc/workerPool";
  59315. export * from "babylonjs/Misc/logger";
  59316. export * from "babylonjs/Misc/typeStore";
  59317. export * from "babylonjs/Misc/filesInputStore";
  59318. export * from "babylonjs/Misc/deepCopier";
  59319. export * from "babylonjs/Misc/pivotTools";
  59320. export * from "babylonjs/Misc/precisionDate";
  59321. export * from "babylonjs/Misc/screenshotTools";
  59322. export * from "babylonjs/Misc/typeStore";
  59323. export * from "babylonjs/Misc/webRequest";
  59324. export * from "babylonjs/Misc/iInspectable";
  59325. }
  59326. declare module "babylonjs/index" {
  59327. export * from "babylonjs/abstractScene";
  59328. export * from "babylonjs/Actions/index";
  59329. export * from "babylonjs/Animations/index";
  59330. export * from "babylonjs/assetContainer";
  59331. export * from "babylonjs/Audio/index";
  59332. export * from "babylonjs/Behaviors/index";
  59333. export * from "babylonjs/Bones/index";
  59334. export * from "babylonjs/Cameras/index";
  59335. export * from "babylonjs/Collisions/index";
  59336. export * from "babylonjs/Culling/index";
  59337. export * from "babylonjs/Debug/index";
  59338. export * from "babylonjs/Engines/index";
  59339. export * from "babylonjs/Events/index";
  59340. export * from "babylonjs/Gamepads/index";
  59341. export * from "babylonjs/Gizmos/index";
  59342. export * from "babylonjs/Helpers/index";
  59343. export * from "babylonjs/Instrumentation/index";
  59344. export * from "babylonjs/Layers/index";
  59345. export * from "babylonjs/LensFlares/index";
  59346. export * from "babylonjs/Lights/index";
  59347. export * from "babylonjs/Loading/index";
  59348. export * from "babylonjs/Materials/index";
  59349. export * from "babylonjs/Maths/index";
  59350. export * from "babylonjs/Meshes/index";
  59351. export * from "babylonjs/Morph/index";
  59352. export * from "babylonjs/node";
  59353. export * from "babylonjs/Offline/index";
  59354. export * from "babylonjs/Particles/index";
  59355. export * from "babylonjs/Physics/index";
  59356. export * from "babylonjs/PostProcesses/index";
  59357. export * from "babylonjs/Probes/index";
  59358. export * from "babylonjs/Rendering/index";
  59359. export * from "babylonjs/scene";
  59360. export * from "babylonjs/sceneComponent";
  59361. export * from "babylonjs/Sprites/index";
  59362. export * from "babylonjs/States/index";
  59363. export * from "babylonjs/Misc/index";
  59364. export * from "babylonjs/types";
  59365. }
  59366. declare module "babylonjs/Animations/pathCursor" {
  59367. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59368. /**
  59369. * A cursor which tracks a point on a path
  59370. */
  59371. export class PathCursor {
  59372. private path;
  59373. /**
  59374. * Stores path cursor callbacks for when an onchange event is triggered
  59375. */
  59376. private _onchange;
  59377. /**
  59378. * The value of the path cursor
  59379. */
  59380. value: number;
  59381. /**
  59382. * The animation array of the path cursor
  59383. */
  59384. animations: Animation[];
  59385. /**
  59386. * Initializes the path cursor
  59387. * @param path The path to track
  59388. */
  59389. constructor(path: Path2);
  59390. /**
  59391. * Gets the cursor point on the path
  59392. * @returns A point on the path cursor at the cursor location
  59393. */
  59394. getPoint(): Vector3;
  59395. /**
  59396. * Moves the cursor ahead by the step amount
  59397. * @param step The amount to move the cursor forward
  59398. * @returns This path cursor
  59399. */
  59400. moveAhead(step?: number): PathCursor;
  59401. /**
  59402. * Moves the cursor behind by the step amount
  59403. * @param step The amount to move the cursor back
  59404. * @returns This path cursor
  59405. */
  59406. moveBack(step?: number): PathCursor;
  59407. /**
  59408. * Moves the cursor by the step amount
  59409. * If the step amount is greater than one, an exception is thrown
  59410. * @param step The amount to move the cursor
  59411. * @returns This path cursor
  59412. */
  59413. move(step: number): PathCursor;
  59414. /**
  59415. * Ensures that the value is limited between zero and one
  59416. * @returns This path cursor
  59417. */
  59418. private ensureLimits;
  59419. /**
  59420. * Runs onchange callbacks on change (used by the animation engine)
  59421. * @returns This path cursor
  59422. */
  59423. private raiseOnChange;
  59424. /**
  59425. * Executes a function on change
  59426. * @param f A path cursor onchange callback
  59427. * @returns This path cursor
  59428. */
  59429. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59430. }
  59431. }
  59432. declare module "babylonjs/Legacy/legacy" {
  59433. import * as Babylon from "babylonjs/index";
  59434. export * from "babylonjs/index";
  59435. }
  59436. declare module "babylonjs/Shaders/blur.fragment" {
  59437. /** @hidden */
  59438. export var blurPixelShader: {
  59439. name: string;
  59440. shader: string;
  59441. };
  59442. }
  59443. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59444. /** @hidden */
  59445. export var bones300Declaration: {
  59446. name: string;
  59447. shader: string;
  59448. };
  59449. }
  59450. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59451. /** @hidden */
  59452. export var instances300Declaration: {
  59453. name: string;
  59454. shader: string;
  59455. };
  59456. }
  59457. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59458. /** @hidden */
  59459. export var pointCloudVertexDeclaration: {
  59460. name: string;
  59461. shader: string;
  59462. };
  59463. }
  59464. // Mixins
  59465. interface Window {
  59466. mozIndexedDB: IDBFactory;
  59467. webkitIndexedDB: IDBFactory;
  59468. msIndexedDB: IDBFactory;
  59469. webkitURL: typeof URL;
  59470. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59471. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59472. WebGLRenderingContext: WebGLRenderingContext;
  59473. MSGesture: MSGesture;
  59474. CANNON: any;
  59475. AudioContext: AudioContext;
  59476. webkitAudioContext: AudioContext;
  59477. PointerEvent: any;
  59478. Math: Math;
  59479. Uint8Array: Uint8ArrayConstructor;
  59480. Float32Array: Float32ArrayConstructor;
  59481. mozURL: typeof URL;
  59482. msURL: typeof URL;
  59483. VRFrameData: any; // WebVR, from specs 1.1
  59484. DracoDecoderModule: any;
  59485. setImmediate(handler: (...args: any[]) => void): number;
  59486. }
  59487. interface HTMLCanvasElement {
  59488. requestPointerLock(): void;
  59489. msRequestPointerLock?(): void;
  59490. mozRequestPointerLock?(): void;
  59491. webkitRequestPointerLock?(): void;
  59492. /** Track wether a record is in progress */
  59493. isRecording: boolean;
  59494. /** Capture Stream method defined by some browsers */
  59495. captureStream(fps?: number): MediaStream;
  59496. }
  59497. interface CanvasRenderingContext2D {
  59498. msImageSmoothingEnabled: boolean;
  59499. }
  59500. interface MouseEvent {
  59501. mozMovementX: number;
  59502. mozMovementY: number;
  59503. webkitMovementX: number;
  59504. webkitMovementY: number;
  59505. msMovementX: number;
  59506. msMovementY: number;
  59507. }
  59508. interface Navigator {
  59509. mozGetVRDevices: (any: any) => any;
  59510. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59511. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59512. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59513. webkitGetGamepads(): Gamepad[];
  59514. msGetGamepads(): Gamepad[];
  59515. webkitGamepads(): Gamepad[];
  59516. }
  59517. interface HTMLVideoElement {
  59518. mozSrcObject: any;
  59519. }
  59520. interface Math {
  59521. fround(x: number): number;
  59522. imul(a: number, b: number): number;
  59523. }
  59524. interface WebGLRenderingContext {
  59525. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59526. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59527. vertexAttribDivisor(index: number, divisor: number): void;
  59528. createVertexArray(): any;
  59529. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59530. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59531. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59532. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59533. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59534. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59535. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59536. // Queries
  59537. createQuery(): WebGLQuery;
  59538. deleteQuery(query: WebGLQuery): void;
  59539. beginQuery(target: number, query: WebGLQuery): void;
  59540. endQuery(target: number): void;
  59541. getQueryParameter(query: WebGLQuery, pname: number): any;
  59542. getQuery(target: number, pname: number): any;
  59543. MAX_SAMPLES: number;
  59544. RGBA8: number;
  59545. READ_FRAMEBUFFER: number;
  59546. DRAW_FRAMEBUFFER: number;
  59547. UNIFORM_BUFFER: number;
  59548. HALF_FLOAT_OES: number;
  59549. RGBA16F: number;
  59550. RGBA32F: number;
  59551. R32F: number;
  59552. RG32F: number;
  59553. RGB32F: number;
  59554. R16F: number;
  59555. RG16F: number;
  59556. RGB16F: number;
  59557. RED: number;
  59558. RG: number;
  59559. R8: number;
  59560. RG8: number;
  59561. UNSIGNED_INT_24_8: number;
  59562. DEPTH24_STENCIL8: number;
  59563. /* Multiple Render Targets */
  59564. drawBuffers(buffers: number[]): void;
  59565. readBuffer(src: number): void;
  59566. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59567. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59568. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59569. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59570. // Occlusion Query
  59571. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59572. ANY_SAMPLES_PASSED: number;
  59573. QUERY_RESULT_AVAILABLE: number;
  59574. QUERY_RESULT: number;
  59575. }
  59576. interface WebGLProgram {
  59577. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59578. }
  59579. interface EXT_disjoint_timer_query {
  59580. QUERY_COUNTER_BITS_EXT: number;
  59581. TIME_ELAPSED_EXT: number;
  59582. TIMESTAMP_EXT: number;
  59583. GPU_DISJOINT_EXT: number;
  59584. QUERY_RESULT_EXT: number;
  59585. QUERY_RESULT_AVAILABLE_EXT: number;
  59586. queryCounterEXT(query: WebGLQuery, target: number): void;
  59587. createQueryEXT(): WebGLQuery;
  59588. beginQueryEXT(target: number, query: WebGLQuery): void;
  59589. endQueryEXT(target: number): void;
  59590. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59591. deleteQueryEXT(query: WebGLQuery): void;
  59592. }
  59593. interface WebGLUniformLocation {
  59594. _currentState: any;
  59595. }
  59596. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59597. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59598. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59599. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59600. interface WebGLRenderingContext {
  59601. readonly RASTERIZER_DISCARD: number;
  59602. readonly DEPTH_COMPONENT24: number;
  59603. readonly TEXTURE_3D: number;
  59604. readonly TEXTURE_2D_ARRAY: number;
  59605. readonly TEXTURE_COMPARE_FUNC: number;
  59606. readonly TEXTURE_COMPARE_MODE: number;
  59607. readonly COMPARE_REF_TO_TEXTURE: number;
  59608. readonly TEXTURE_WRAP_R: number;
  59609. readonly HALF_FLOAT: number;
  59610. readonly RGB8: number;
  59611. readonly RED_INTEGER: number;
  59612. readonly RG_INTEGER: number;
  59613. readonly RGB_INTEGER: number;
  59614. readonly RGBA_INTEGER: number;
  59615. readonly R8_SNORM: number;
  59616. readonly RG8_SNORM: number;
  59617. readonly RGB8_SNORM: number;
  59618. readonly RGBA8_SNORM: number;
  59619. readonly R8I: number;
  59620. readonly RG8I: number;
  59621. readonly RGB8I: number;
  59622. readonly RGBA8I: number;
  59623. readonly R8UI: number;
  59624. readonly RG8UI: number;
  59625. readonly RGB8UI: number;
  59626. readonly RGBA8UI: number;
  59627. readonly R16I: number;
  59628. readonly RG16I: number;
  59629. readonly RGB16I: number;
  59630. readonly RGBA16I: number;
  59631. readonly R16UI: number;
  59632. readonly RG16UI: number;
  59633. readonly RGB16UI: number;
  59634. readonly RGBA16UI: number;
  59635. readonly R32I: number;
  59636. readonly RG32I: number;
  59637. readonly RGB32I: number;
  59638. readonly RGBA32I: number;
  59639. readonly R32UI: number;
  59640. readonly RG32UI: number;
  59641. readonly RGB32UI: number;
  59642. readonly RGBA32UI: number;
  59643. readonly RGB10_A2UI: number;
  59644. readonly R11F_G11F_B10F: number;
  59645. readonly RGB9_E5: number;
  59646. readonly RGB10_A2: number;
  59647. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59648. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59649. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59650. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59651. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59652. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59653. 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;
  59654. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59655. readonly TRANSFORM_FEEDBACK: number;
  59656. readonly INTERLEAVED_ATTRIBS: number;
  59657. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59658. createTransformFeedback(): WebGLTransformFeedback;
  59659. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59660. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59661. beginTransformFeedback(primitiveMode: number): void;
  59662. endTransformFeedback(): void;
  59663. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59664. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59665. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59666. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59667. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59668. }
  59669. interface ImageBitmap {
  59670. readonly width: number;
  59671. readonly height: number;
  59672. close(): void;
  59673. }
  59674. interface WebGLQuery extends WebGLObject {
  59675. }
  59676. declare var WebGLQuery: {
  59677. prototype: WebGLQuery;
  59678. new(): WebGLQuery;
  59679. };
  59680. interface WebGLSampler extends WebGLObject {
  59681. }
  59682. declare var WebGLSampler: {
  59683. prototype: WebGLSampler;
  59684. new(): WebGLSampler;
  59685. };
  59686. interface WebGLSync extends WebGLObject {
  59687. }
  59688. declare var WebGLSync: {
  59689. prototype: WebGLSync;
  59690. new(): WebGLSync;
  59691. };
  59692. interface WebGLTransformFeedback extends WebGLObject {
  59693. }
  59694. declare var WebGLTransformFeedback: {
  59695. prototype: WebGLTransformFeedback;
  59696. new(): WebGLTransformFeedback;
  59697. };
  59698. interface WebGLVertexArrayObject extends WebGLObject {
  59699. }
  59700. declare var WebGLVertexArrayObject: {
  59701. prototype: WebGLVertexArrayObject;
  59702. new(): WebGLVertexArrayObject;
  59703. };
  59704. // Type definitions for WebVR API
  59705. // Project: https://w3c.github.io/webvr/
  59706. // Definitions by: six a <https://github.com/lostfictions>
  59707. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59708. interface VRDisplay extends EventTarget {
  59709. /**
  59710. * Dictionary of capabilities describing the VRDisplay.
  59711. */
  59712. readonly capabilities: VRDisplayCapabilities;
  59713. /**
  59714. * z-depth defining the far plane of the eye view frustum
  59715. * enables mapping of values in the render target depth
  59716. * attachment to scene coordinates. Initially set to 10000.0.
  59717. */
  59718. depthFar: number;
  59719. /**
  59720. * z-depth defining the near plane of the eye view frustum
  59721. * enables mapping of values in the render target depth
  59722. * attachment to scene coordinates. Initially set to 0.01.
  59723. */
  59724. depthNear: number;
  59725. /**
  59726. * An identifier for this distinct VRDisplay. Used as an
  59727. * association point in the Gamepad API.
  59728. */
  59729. readonly displayId: number;
  59730. /**
  59731. * A display name, a user-readable name identifying it.
  59732. */
  59733. readonly displayName: string;
  59734. readonly isConnected: boolean;
  59735. readonly isPresenting: boolean;
  59736. /**
  59737. * If this VRDisplay supports room-scale experiences, the optional
  59738. * stage attribute contains details on the room-scale parameters.
  59739. */
  59740. readonly stageParameters: VRStageParameters | null;
  59741. /**
  59742. * Passing the value returned by `requestAnimationFrame` to
  59743. * `cancelAnimationFrame` will unregister the callback.
  59744. * @param handle Define the hanle of the request to cancel
  59745. */
  59746. cancelAnimationFrame(handle: number): void;
  59747. /**
  59748. * Stops presenting to the VRDisplay.
  59749. * @returns a promise to know when it stopped
  59750. */
  59751. exitPresent(): Promise<void>;
  59752. /**
  59753. * Return the current VREyeParameters for the given eye.
  59754. * @param whichEye Define the eye we want the parameter for
  59755. * @returns the eye parameters
  59756. */
  59757. getEyeParameters(whichEye: string): VREyeParameters;
  59758. /**
  59759. * Populates the passed VRFrameData with the information required to render
  59760. * the current frame.
  59761. * @param frameData Define the data structure to populate
  59762. * @returns true if ok otherwise false
  59763. */
  59764. getFrameData(frameData: VRFrameData): boolean;
  59765. /**
  59766. * Get the layers currently being presented.
  59767. * @returns the list of VR layers
  59768. */
  59769. getLayers(): VRLayer[];
  59770. /**
  59771. * Return a VRPose containing the future predicted pose of the VRDisplay
  59772. * when the current frame will be presented. The value returned will not
  59773. * change until JavaScript has returned control to the browser.
  59774. *
  59775. * The VRPose will contain the position, orientation, velocity,
  59776. * and acceleration of each of these properties.
  59777. * @returns the pose object
  59778. */
  59779. getPose(): VRPose;
  59780. /**
  59781. * Return the current instantaneous pose of the VRDisplay, with no
  59782. * prediction applied.
  59783. * @returns the current instantaneous pose
  59784. */
  59785. getImmediatePose(): VRPose;
  59786. /**
  59787. * The callback passed to `requestAnimationFrame` will be called
  59788. * any time a new frame should be rendered. When the VRDisplay is
  59789. * presenting the callback will be called at the native refresh
  59790. * rate of the HMD. When not presenting this function acts
  59791. * identically to how window.requestAnimationFrame acts. Content should
  59792. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59793. * asynchronously from other displays and at differing refresh rates.
  59794. * @param callback Define the eaction to run next frame
  59795. * @returns the request handle it
  59796. */
  59797. requestAnimationFrame(callback: FrameRequestCallback): number;
  59798. /**
  59799. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59800. * Repeat calls while already presenting will update the VRLayers being displayed.
  59801. * @param layers Define the list of layer to present
  59802. * @returns a promise to know when the request has been fulfilled
  59803. */
  59804. requestPresent(layers: VRLayer[]): Promise<void>;
  59805. /**
  59806. * Reset the pose for this display, treating its current position and
  59807. * orientation as the "origin/zero" values. VRPose.position,
  59808. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59809. * updated when calling resetPose(). This should be called in only
  59810. * sitting-space experiences.
  59811. */
  59812. resetPose(): void;
  59813. /**
  59814. * The VRLayer provided to the VRDisplay will be captured and presented
  59815. * in the HMD. Calling this function has the same effect on the source
  59816. * canvas as any other operation that uses its source image, and canvases
  59817. * created without preserveDrawingBuffer set to true will be cleared.
  59818. * @param pose Define the pose to submit
  59819. */
  59820. submitFrame(pose?: VRPose): void;
  59821. }
  59822. declare var VRDisplay: {
  59823. prototype: VRDisplay;
  59824. new(): VRDisplay;
  59825. };
  59826. interface VRLayer {
  59827. leftBounds?: number[] | Float32Array | null;
  59828. rightBounds?: number[] | Float32Array | null;
  59829. source?: HTMLCanvasElement | null;
  59830. }
  59831. interface VRDisplayCapabilities {
  59832. readonly canPresent: boolean;
  59833. readonly hasExternalDisplay: boolean;
  59834. readonly hasOrientation: boolean;
  59835. readonly hasPosition: boolean;
  59836. readonly maxLayers: number;
  59837. }
  59838. interface VREyeParameters {
  59839. /** @deprecated */
  59840. readonly fieldOfView: VRFieldOfView;
  59841. readonly offset: Float32Array;
  59842. readonly renderHeight: number;
  59843. readonly renderWidth: number;
  59844. }
  59845. interface VRFieldOfView {
  59846. readonly downDegrees: number;
  59847. readonly leftDegrees: number;
  59848. readonly rightDegrees: number;
  59849. readonly upDegrees: number;
  59850. }
  59851. interface VRFrameData {
  59852. readonly leftProjectionMatrix: Float32Array;
  59853. readonly leftViewMatrix: Float32Array;
  59854. readonly pose: VRPose;
  59855. readonly rightProjectionMatrix: Float32Array;
  59856. readonly rightViewMatrix: Float32Array;
  59857. readonly timestamp: number;
  59858. }
  59859. interface VRPose {
  59860. readonly angularAcceleration: Float32Array | null;
  59861. readonly angularVelocity: Float32Array | null;
  59862. readonly linearAcceleration: Float32Array | null;
  59863. readonly linearVelocity: Float32Array | null;
  59864. readonly orientation: Float32Array | null;
  59865. readonly position: Float32Array | null;
  59866. readonly timestamp: number;
  59867. }
  59868. interface VRStageParameters {
  59869. sittingToStandingTransform?: Float32Array;
  59870. sizeX?: number;
  59871. sizeY?: number;
  59872. }
  59873. interface Navigator {
  59874. getVRDisplays(): Promise<VRDisplay[]>;
  59875. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59876. }
  59877. interface Window {
  59878. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59879. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59880. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59881. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59882. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59883. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59884. }
  59885. interface Gamepad {
  59886. readonly displayId: number;
  59887. }
  59888. interface XRDevice {
  59889. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59890. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59891. }
  59892. interface XRSession {
  59893. getInputSources(): Array<any>;
  59894. baseLayer: XRWebGLLayer;
  59895. requestFrameOfReference(type: string): Promise<void>;
  59896. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59897. end(): Promise<void>;
  59898. requestAnimationFrame: Function;
  59899. addEventListener: Function;
  59900. }
  59901. interface XRSessionCreationOptions {
  59902. outputContext?: WebGLRenderingContext | null;
  59903. immersive?: boolean;
  59904. environmentIntegration?: boolean;
  59905. }
  59906. interface XRLayer {
  59907. getViewport: Function;
  59908. framebufferWidth: number;
  59909. framebufferHeight: number;
  59910. }
  59911. interface XRView {
  59912. projectionMatrix: Float32Array;
  59913. }
  59914. interface XRFrame {
  59915. getDevicePose: Function;
  59916. getInputPose: Function;
  59917. views: Array<XRView>;
  59918. baseLayer: XRLayer;
  59919. }
  59920. interface XRFrameOfReference {
  59921. }
  59922. interface XRWebGLLayer extends XRLayer {
  59923. framebuffer: WebGLFramebuffer;
  59924. }
  59925. declare var XRWebGLLayer: {
  59926. prototype: XRWebGLLayer;
  59927. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59928. };
  59929. declare module "babylonjs" {
  59930. export * from "babylonjs/Legacy/legacy";
  59931. }
  59932. declare module BABYLON {
  59933. /** Alias type for value that can be null */
  59934. export type Nullable<T> = T | null;
  59935. /**
  59936. * Alias type for number that are floats
  59937. * @ignorenaming
  59938. */
  59939. export type float = number;
  59940. /**
  59941. * Alias type for number that are doubles.
  59942. * @ignorenaming
  59943. */
  59944. export type double = number;
  59945. /**
  59946. * Alias type for number that are integer
  59947. * @ignorenaming
  59948. */
  59949. export type int = number;
  59950. /** Alias type for number array or Float32Array */
  59951. export type FloatArray = number[] | Float32Array;
  59952. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59953. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59954. /**
  59955. * Alias for types that can be used by a Buffer or VertexBuffer.
  59956. */
  59957. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59958. /**
  59959. * Alias type for primitive types
  59960. * @ignorenaming
  59961. */
  59962. type Primitive = undefined | null | boolean | string | number | Function;
  59963. /**
  59964. * Type modifier to make all the properties of an object Readonly
  59965. */
  59966. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59967. /**
  59968. * Type modifier to make all the properties of an object Readonly recursively
  59969. */
  59970. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59971. /** @hidden */
  59972. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59973. }
  59974. /** @hidden */
  59975. /** @hidden */
  59976. type DeepImmutableObject<T> = {
  59977. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59978. };
  59979. }
  59980. declare module BABYLON {
  59981. /**
  59982. * Class containing a set of static utilities functions for arrays.
  59983. */
  59984. export class ArrayTools {
  59985. /**
  59986. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59987. * @param size the number of element to construct and put in the array
  59988. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59989. * @returns a new array filled with new objects
  59990. */
  59991. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59992. }
  59993. }
  59994. declare module BABYLON {
  59995. /**
  59996. * Scalar computation library
  59997. */
  59998. export class Scalar {
  59999. /**
  60000. * Two pi constants convenient for computation.
  60001. */
  60002. static TwoPi: number;
  60003. /**
  60004. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60005. * @param a number
  60006. * @param b number
  60007. * @param epsilon (default = 1.401298E-45)
  60008. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60009. */
  60010. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  60011. /**
  60012. * Returns a string : the upper case translation of the number i to hexadecimal.
  60013. * @param i number
  60014. * @returns the upper case translation of the number i to hexadecimal.
  60015. */
  60016. static ToHex(i: number): string;
  60017. /**
  60018. * Returns -1 if value is negative and +1 is value is positive.
  60019. * @param value the value
  60020. * @returns the value itself if it's equal to zero.
  60021. */
  60022. static Sign(value: number): number;
  60023. /**
  60024. * Returns the value itself if it's between min and max.
  60025. * Returns min if the value is lower than min.
  60026. * Returns max if the value is greater than max.
  60027. * @param value the value to clmap
  60028. * @param min the min value to clamp to (default: 0)
  60029. * @param max the max value to clamp to (default: 1)
  60030. * @returns the clamped value
  60031. */
  60032. static Clamp(value: number, min?: number, max?: number): number;
  60033. /**
  60034. * the log2 of value.
  60035. * @param value the value to compute log2 of
  60036. * @returns the log2 of value.
  60037. */
  60038. static Log2(value: number): number;
  60039. /**
  60040. * Loops the value, so that it is never larger than length and never smaller than 0.
  60041. *
  60042. * This is similar to the modulo operator but it works with floating point numbers.
  60043. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60044. * With t = 5 and length = 2.5, the result would be 0.0.
  60045. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60046. * @param value the value
  60047. * @param length the length
  60048. * @returns the looped value
  60049. */
  60050. static Repeat(value: number, length: number): number;
  60051. /**
  60052. * Normalize the value between 0.0 and 1.0 using min and max values
  60053. * @param value value to normalize
  60054. * @param min max to normalize between
  60055. * @param max min to normalize between
  60056. * @returns the normalized value
  60057. */
  60058. static Normalize(value: number, min: number, max: number): number;
  60059. /**
  60060. * Denormalize the value from 0.0 and 1.0 using min and max values
  60061. * @param normalized value to denormalize
  60062. * @param min max to denormalize between
  60063. * @param max min to denormalize between
  60064. * @returns the denormalized value
  60065. */
  60066. static Denormalize(normalized: number, min: number, max: number): number;
  60067. /**
  60068. * Calculates the shortest difference between two given angles given in degrees.
  60069. * @param current current angle in degrees
  60070. * @param target target angle in degrees
  60071. * @returns the delta
  60072. */
  60073. static DeltaAngle(current: number, target: number): number;
  60074. /**
  60075. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60076. * @param tx value
  60077. * @param length length
  60078. * @returns The returned value will move back and forth between 0 and length
  60079. */
  60080. static PingPong(tx: number, length: number): number;
  60081. /**
  60082. * Interpolates between min and max with smoothing at the limits.
  60083. *
  60084. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60085. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60086. * @param from from
  60087. * @param to to
  60088. * @param tx value
  60089. * @returns the smooth stepped value
  60090. */
  60091. static SmoothStep(from: number, to: number, tx: number): number;
  60092. /**
  60093. * Moves a value current towards target.
  60094. *
  60095. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60096. * Negative values of maxDelta pushes the value away from target.
  60097. * @param current current value
  60098. * @param target target value
  60099. * @param maxDelta max distance to move
  60100. * @returns resulting value
  60101. */
  60102. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60103. /**
  60104. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60105. *
  60106. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60107. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60108. * @param current current value
  60109. * @param target target value
  60110. * @param maxDelta max distance to move
  60111. * @returns resulting angle
  60112. */
  60113. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60114. /**
  60115. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60116. * @param start start value
  60117. * @param end target value
  60118. * @param amount amount to lerp between
  60119. * @returns the lerped value
  60120. */
  60121. static Lerp(start: number, end: number, amount: number): number;
  60122. /**
  60123. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60124. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60125. * @param start start value
  60126. * @param end target value
  60127. * @param amount amount to lerp between
  60128. * @returns the lerped value
  60129. */
  60130. static LerpAngle(start: number, end: number, amount: number): number;
  60131. /**
  60132. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60133. * @param a start value
  60134. * @param b target value
  60135. * @param value value between a and b
  60136. * @returns the inverseLerp value
  60137. */
  60138. static InverseLerp(a: number, b: number, value: number): number;
  60139. /**
  60140. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60141. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60142. * @param value1 spline value
  60143. * @param tangent1 spline value
  60144. * @param value2 spline value
  60145. * @param tangent2 spline value
  60146. * @param amount input value
  60147. * @returns hermite result
  60148. */
  60149. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60150. /**
  60151. * Returns a random float number between and min and max values
  60152. * @param min min value of random
  60153. * @param max max value of random
  60154. * @returns random value
  60155. */
  60156. static RandomRange(min: number, max: number): number;
  60157. /**
  60158. * This function returns percentage of a number in a given range.
  60159. *
  60160. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60161. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60162. * @param number to convert to percentage
  60163. * @param min min range
  60164. * @param max max range
  60165. * @returns the percentage
  60166. */
  60167. static RangeToPercent(number: number, min: number, max: number): number;
  60168. /**
  60169. * This function returns number that corresponds to the percentage in a given range.
  60170. *
  60171. * PercentToRange(0.34,0,100) will return 34.
  60172. * @param percent to convert to number
  60173. * @param min min range
  60174. * @param max max range
  60175. * @returns the number
  60176. */
  60177. static PercentToRange(percent: number, min: number, max: number): number;
  60178. /**
  60179. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60180. * @param angle The angle to normalize in radian.
  60181. * @return The converted angle.
  60182. */
  60183. static NormalizeRadians(angle: number): number;
  60184. }
  60185. }
  60186. declare module BABYLON {
  60187. /**
  60188. * Constant used to convert a value to gamma space
  60189. * @ignorenaming
  60190. */
  60191. export const ToGammaSpace: number;
  60192. /**
  60193. * Constant used to convert a value to linear space
  60194. * @ignorenaming
  60195. */
  60196. export const ToLinearSpace = 2.2;
  60197. /**
  60198. * Constant used to define the minimal number value in Babylon.js
  60199. * @ignorenaming
  60200. */
  60201. let Epsilon: number;
  60202. /**
  60203. * Class used to hold a RBG color
  60204. */
  60205. export class Color3 {
  60206. /**
  60207. * Defines the red component (between 0 and 1, default is 0)
  60208. */
  60209. r: number;
  60210. /**
  60211. * Defines the green component (between 0 and 1, default is 0)
  60212. */
  60213. g: number;
  60214. /**
  60215. * Defines the blue component (between 0 and 1, default is 0)
  60216. */
  60217. b: number;
  60218. /**
  60219. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60220. * @param r defines the red component (between 0 and 1, default is 0)
  60221. * @param g defines the green component (between 0 and 1, default is 0)
  60222. * @param b defines the blue component (between 0 and 1, default is 0)
  60223. */
  60224. constructor(
  60225. /**
  60226. * Defines the red component (between 0 and 1, default is 0)
  60227. */
  60228. r?: number,
  60229. /**
  60230. * Defines the green component (between 0 and 1, default is 0)
  60231. */
  60232. g?: number,
  60233. /**
  60234. * Defines the blue component (between 0 and 1, default is 0)
  60235. */
  60236. b?: number);
  60237. /**
  60238. * Creates a string with the Color3 current values
  60239. * @returns the string representation of the Color3 object
  60240. */
  60241. toString(): string;
  60242. /**
  60243. * Returns the string "Color3"
  60244. * @returns "Color3"
  60245. */
  60246. getClassName(): string;
  60247. /**
  60248. * Compute the Color3 hash code
  60249. * @returns an unique number that can be used to hash Color3 objects
  60250. */
  60251. getHashCode(): number;
  60252. /**
  60253. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60254. * @param array defines the array where to store the r,g,b components
  60255. * @param index defines an optional index in the target array to define where to start storing values
  60256. * @returns the current Color3 object
  60257. */
  60258. toArray(array: FloatArray, index?: number): Color3;
  60259. /**
  60260. * Returns a new Color4 object from the current Color3 and the given alpha
  60261. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60262. * @returns a new Color4 object
  60263. */
  60264. toColor4(alpha?: number): Color4;
  60265. /**
  60266. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60267. * @returns the new array
  60268. */
  60269. asArray(): number[];
  60270. /**
  60271. * Returns the luminance value
  60272. * @returns a float value
  60273. */
  60274. toLuminance(): number;
  60275. /**
  60276. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60277. * @param otherColor defines the second operand
  60278. * @returns the new Color3 object
  60279. */
  60280. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60281. /**
  60282. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60283. * @param otherColor defines the second operand
  60284. * @param result defines the Color3 object where to store the result
  60285. * @returns the current Color3
  60286. */
  60287. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60288. /**
  60289. * Determines equality between Color3 objects
  60290. * @param otherColor defines the second operand
  60291. * @returns true if the rgb values are equal to the given ones
  60292. */
  60293. equals(otherColor: DeepImmutable<Color3>): boolean;
  60294. /**
  60295. * Determines equality between the current Color3 object and a set of r,b,g values
  60296. * @param r defines the red component to check
  60297. * @param g defines the green component to check
  60298. * @param b defines the blue component to check
  60299. * @returns true if the rgb values are equal to the given ones
  60300. */
  60301. equalsFloats(r: number, g: number, b: number): boolean;
  60302. /**
  60303. * Multiplies in place each rgb value by scale
  60304. * @param scale defines the scaling factor
  60305. * @returns the updated Color3
  60306. */
  60307. scale(scale: number): Color3;
  60308. /**
  60309. * Multiplies the rgb values by scale and stores the result into "result"
  60310. * @param scale defines the scaling factor
  60311. * @param result defines the Color3 object where to store the result
  60312. * @returns the unmodified current Color3
  60313. */
  60314. scaleToRef(scale: number, result: Color3): Color3;
  60315. /**
  60316. * Scale the current Color3 values by a factor and add the result to a given Color3
  60317. * @param scale defines the scale factor
  60318. * @param result defines color to store the result into
  60319. * @returns the unmodified current Color3
  60320. */
  60321. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60322. /**
  60323. * Clamps the rgb values by the min and max values and stores the result into "result"
  60324. * @param min defines minimum clamping value (default is 0)
  60325. * @param max defines maximum clamping value (default is 1)
  60326. * @param result defines color to store the result into
  60327. * @returns the original Color3
  60328. */
  60329. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60330. /**
  60331. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60332. * @param otherColor defines the second operand
  60333. * @returns the new Color3
  60334. */
  60335. add(otherColor: DeepImmutable<Color3>): Color3;
  60336. /**
  60337. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60338. * @param otherColor defines the second operand
  60339. * @param result defines Color3 object to store the result into
  60340. * @returns the unmodified current Color3
  60341. */
  60342. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60343. /**
  60344. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60345. * @param otherColor defines the second operand
  60346. * @returns the new Color3
  60347. */
  60348. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60349. /**
  60350. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60351. * @param otherColor defines the second operand
  60352. * @param result defines Color3 object to store the result into
  60353. * @returns the unmodified current Color3
  60354. */
  60355. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60356. /**
  60357. * Copy the current object
  60358. * @returns a new Color3 copied the current one
  60359. */
  60360. clone(): Color3;
  60361. /**
  60362. * Copies the rgb values from the source in the current Color3
  60363. * @param source defines the source Color3 object
  60364. * @returns the updated Color3 object
  60365. */
  60366. copyFrom(source: DeepImmutable<Color3>): Color3;
  60367. /**
  60368. * Updates the Color3 rgb values from the given floats
  60369. * @param r defines the red component to read from
  60370. * @param g defines the green component to read from
  60371. * @param b defines the blue component to read from
  60372. * @returns the current Color3 object
  60373. */
  60374. copyFromFloats(r: number, g: number, b: number): Color3;
  60375. /**
  60376. * Updates the Color3 rgb values from the given floats
  60377. * @param r defines the red component to read from
  60378. * @param g defines the green component to read from
  60379. * @param b defines the blue component to read from
  60380. * @returns the current Color3 object
  60381. */
  60382. set(r: number, g: number, b: number): Color3;
  60383. /**
  60384. * Compute the Color3 hexadecimal code as a string
  60385. * @returns a string containing the hexadecimal representation of the Color3 object
  60386. */
  60387. toHexString(): string;
  60388. /**
  60389. * Computes a new Color3 converted from the current one to linear space
  60390. * @returns a new Color3 object
  60391. */
  60392. toLinearSpace(): Color3;
  60393. /**
  60394. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60395. * @param convertedColor defines the Color3 object where to store the linear space version
  60396. * @returns the unmodified Color3
  60397. */
  60398. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60399. /**
  60400. * Computes a new Color3 converted from the current one to gamma space
  60401. * @returns a new Color3 object
  60402. */
  60403. toGammaSpace(): Color3;
  60404. /**
  60405. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60406. * @param convertedColor defines the Color3 object where to store the gamma space version
  60407. * @returns the unmodified Color3
  60408. */
  60409. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60410. private static _BlackReadOnly;
  60411. /**
  60412. * Creates a new Color3 from the string containing valid hexadecimal values
  60413. * @param hex defines a string containing valid hexadecimal values
  60414. * @returns a new Color3 object
  60415. */
  60416. static FromHexString(hex: string): Color3;
  60417. /**
  60418. * Creates a new Color3 from the starting index of the given array
  60419. * @param array defines the source array
  60420. * @param offset defines an offset in the source array
  60421. * @returns a new Color3 object
  60422. */
  60423. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60424. /**
  60425. * Creates a new Color3 from integer values (< 256)
  60426. * @param r defines the red component to read from (value between 0 and 255)
  60427. * @param g defines the green component to read from (value between 0 and 255)
  60428. * @param b defines the blue component to read from (value between 0 and 255)
  60429. * @returns a new Color3 object
  60430. */
  60431. static FromInts(r: number, g: number, b: number): Color3;
  60432. /**
  60433. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60434. * @param start defines the start Color3 value
  60435. * @param end defines the end Color3 value
  60436. * @param amount defines the gradient value between start and end
  60437. * @returns a new Color3 object
  60438. */
  60439. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60440. /**
  60441. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60442. * @param left defines the start value
  60443. * @param right defines the end value
  60444. * @param amount defines the gradient factor
  60445. * @param result defines the Color3 object where to store the result
  60446. */
  60447. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60448. /**
  60449. * Returns a Color3 value containing a red color
  60450. * @returns a new Color3 object
  60451. */
  60452. static Red(): Color3;
  60453. /**
  60454. * Returns a Color3 value containing a green color
  60455. * @returns a new Color3 object
  60456. */
  60457. static Green(): Color3;
  60458. /**
  60459. * Returns a Color3 value containing a blue color
  60460. * @returns a new Color3 object
  60461. */
  60462. static Blue(): Color3;
  60463. /**
  60464. * Returns a Color3 value containing a black color
  60465. * @returns a new Color3 object
  60466. */
  60467. static Black(): Color3;
  60468. /**
  60469. * Gets a Color3 value containing a black color that must not be updated
  60470. */
  60471. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60472. /**
  60473. * Returns a Color3 value containing a white color
  60474. * @returns a new Color3 object
  60475. */
  60476. static White(): Color3;
  60477. /**
  60478. * Returns a Color3 value containing a purple color
  60479. * @returns a new Color3 object
  60480. */
  60481. static Purple(): Color3;
  60482. /**
  60483. * Returns a Color3 value containing a magenta color
  60484. * @returns a new Color3 object
  60485. */
  60486. static Magenta(): Color3;
  60487. /**
  60488. * Returns a Color3 value containing a yellow color
  60489. * @returns a new Color3 object
  60490. */
  60491. static Yellow(): Color3;
  60492. /**
  60493. * Returns a Color3 value containing a gray color
  60494. * @returns a new Color3 object
  60495. */
  60496. static Gray(): Color3;
  60497. /**
  60498. * Returns a Color3 value containing a teal color
  60499. * @returns a new Color3 object
  60500. */
  60501. static Teal(): Color3;
  60502. /**
  60503. * Returns a Color3 value containing a random color
  60504. * @returns a new Color3 object
  60505. */
  60506. static Random(): Color3;
  60507. }
  60508. /**
  60509. * Class used to hold a RBGA color
  60510. */
  60511. export class Color4 {
  60512. /**
  60513. * Defines the red component (between 0 and 1, default is 0)
  60514. */
  60515. r: number;
  60516. /**
  60517. * Defines the green component (between 0 and 1, default is 0)
  60518. */
  60519. g: number;
  60520. /**
  60521. * Defines the blue component (between 0 and 1, default is 0)
  60522. */
  60523. b: number;
  60524. /**
  60525. * Defines the alpha component (between 0 and 1, default is 1)
  60526. */
  60527. a: number;
  60528. /**
  60529. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60530. * @param r defines the red component (between 0 and 1, default is 0)
  60531. * @param g defines the green component (between 0 and 1, default is 0)
  60532. * @param b defines the blue component (between 0 and 1, default is 0)
  60533. * @param a defines the alpha component (between 0 and 1, default is 1)
  60534. */
  60535. constructor(
  60536. /**
  60537. * Defines the red component (between 0 and 1, default is 0)
  60538. */
  60539. r?: number,
  60540. /**
  60541. * Defines the green component (between 0 and 1, default is 0)
  60542. */
  60543. g?: number,
  60544. /**
  60545. * Defines the blue component (between 0 and 1, default is 0)
  60546. */
  60547. b?: number,
  60548. /**
  60549. * Defines the alpha component (between 0 and 1, default is 1)
  60550. */
  60551. a?: number);
  60552. /**
  60553. * Adds in place the given Color4 values to the current Color4 object
  60554. * @param right defines the second operand
  60555. * @returns the current updated Color4 object
  60556. */
  60557. addInPlace(right: DeepImmutable<Color4>): Color4;
  60558. /**
  60559. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60560. * @returns the new array
  60561. */
  60562. asArray(): number[];
  60563. /**
  60564. * Stores from the starting index in the given array the Color4 successive values
  60565. * @param array defines the array where to store the r,g,b components
  60566. * @param index defines an optional index in the target array to define where to start storing values
  60567. * @returns the current Color4 object
  60568. */
  60569. toArray(array: number[], index?: number): Color4;
  60570. /**
  60571. * Determines equality between Color4 objects
  60572. * @param otherColor defines the second operand
  60573. * @returns true if the rgba values are equal to the given ones
  60574. */
  60575. equals(otherColor: DeepImmutable<Color4>): boolean;
  60576. /**
  60577. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60578. * @param right defines the second operand
  60579. * @returns a new Color4 object
  60580. */
  60581. add(right: DeepImmutable<Color4>): Color4;
  60582. /**
  60583. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60584. * @param right defines the second operand
  60585. * @returns a new Color4 object
  60586. */
  60587. subtract(right: DeepImmutable<Color4>): Color4;
  60588. /**
  60589. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60590. * @param right defines the second operand
  60591. * @param result defines the Color4 object where to store the result
  60592. * @returns the current Color4 object
  60593. */
  60594. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60595. /**
  60596. * Creates a new Color4 with the current Color4 values multiplied by scale
  60597. * @param scale defines the scaling factor to apply
  60598. * @returns a new Color4 object
  60599. */
  60600. scale(scale: number): Color4;
  60601. /**
  60602. * Multiplies the current Color4 values by scale and stores the result in "result"
  60603. * @param scale defines the scaling factor to apply
  60604. * @param result defines the Color4 object where to store the result
  60605. * @returns the current unmodified Color4
  60606. */
  60607. scaleToRef(scale: number, result: Color4): Color4;
  60608. /**
  60609. * Scale the current Color4 values by a factor and add the result to a given Color4
  60610. * @param scale defines the scale factor
  60611. * @param result defines the Color4 object where to store the result
  60612. * @returns the unmodified current Color4
  60613. */
  60614. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60615. /**
  60616. * Clamps the rgb values by the min and max values and stores the result into "result"
  60617. * @param min defines minimum clamping value (default is 0)
  60618. * @param max defines maximum clamping value (default is 1)
  60619. * @param result defines color to store the result into.
  60620. * @returns the cuurent Color4
  60621. */
  60622. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60623. /**
  60624. * Multipy an Color4 value by another and return a new Color4 object
  60625. * @param color defines the Color4 value to multiply by
  60626. * @returns a new Color4 object
  60627. */
  60628. multiply(color: Color4): Color4;
  60629. /**
  60630. * Multipy a Color4 value by another and push the result in a reference value
  60631. * @param color defines the Color4 value to multiply by
  60632. * @param result defines the Color4 to fill the result in
  60633. * @returns the result Color4
  60634. */
  60635. multiplyToRef(color: Color4, result: Color4): Color4;
  60636. /**
  60637. * Creates a string with the Color4 current values
  60638. * @returns the string representation of the Color4 object
  60639. */
  60640. toString(): string;
  60641. /**
  60642. * Returns the string "Color4"
  60643. * @returns "Color4"
  60644. */
  60645. getClassName(): string;
  60646. /**
  60647. * Compute the Color4 hash code
  60648. * @returns an unique number that can be used to hash Color4 objects
  60649. */
  60650. getHashCode(): number;
  60651. /**
  60652. * Creates a new Color4 copied from the current one
  60653. * @returns a new Color4 object
  60654. */
  60655. clone(): Color4;
  60656. /**
  60657. * Copies the given Color4 values into the current one
  60658. * @param source defines the source Color4 object
  60659. * @returns the current updated Color4 object
  60660. */
  60661. copyFrom(source: Color4): Color4;
  60662. /**
  60663. * Copies the given float values into the current one
  60664. * @param r defines the red component to read from
  60665. * @param g defines the green component to read from
  60666. * @param b defines the blue component to read from
  60667. * @param a defines the alpha component to read from
  60668. * @returns the current updated Color4 object
  60669. */
  60670. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60671. /**
  60672. * Copies the given float values into the current one
  60673. * @param r defines the red component to read from
  60674. * @param g defines the green component to read from
  60675. * @param b defines the blue component to read from
  60676. * @param a defines the alpha component to read from
  60677. * @returns the current updated Color4 object
  60678. */
  60679. set(r: number, g: number, b: number, a: number): Color4;
  60680. /**
  60681. * Compute the Color4 hexadecimal code as a string
  60682. * @returns a string containing the hexadecimal representation of the Color4 object
  60683. */
  60684. toHexString(): string;
  60685. /**
  60686. * Computes a new Color4 converted from the current one to linear space
  60687. * @returns a new Color4 object
  60688. */
  60689. toLinearSpace(): Color4;
  60690. /**
  60691. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60692. * @param convertedColor defines the Color4 object where to store the linear space version
  60693. * @returns the unmodified Color4
  60694. */
  60695. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60696. /**
  60697. * Computes a new Color4 converted from the current one to gamma space
  60698. * @returns a new Color4 object
  60699. */
  60700. toGammaSpace(): Color4;
  60701. /**
  60702. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60703. * @param convertedColor defines the Color4 object where to store the gamma space version
  60704. * @returns the unmodified Color4
  60705. */
  60706. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60707. /**
  60708. * Creates a new Color4 from the string containing valid hexadecimal values
  60709. * @param hex defines a string containing valid hexadecimal values
  60710. * @returns a new Color4 object
  60711. */
  60712. static FromHexString(hex: string): Color4;
  60713. /**
  60714. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60715. * @param left defines the start value
  60716. * @param right defines the end value
  60717. * @param amount defines the gradient factor
  60718. * @returns a new Color4 object
  60719. */
  60720. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60721. /**
  60722. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60723. * @param left defines the start value
  60724. * @param right defines the end value
  60725. * @param amount defines the gradient factor
  60726. * @param result defines the Color4 object where to store data
  60727. */
  60728. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60729. /**
  60730. * Creates a new Color4 from a Color3 and an alpha value
  60731. * @param color3 defines the source Color3 to read from
  60732. * @param alpha defines the alpha component (1.0 by default)
  60733. * @returns a new Color4 object
  60734. */
  60735. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60736. /**
  60737. * Creates a new Color4 from the starting index element of the given array
  60738. * @param array defines the source array to read from
  60739. * @param offset defines the offset in the source array
  60740. * @returns a new Color4 object
  60741. */
  60742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60743. /**
  60744. * Creates a new Color3 from integer values (< 256)
  60745. * @param r defines the red component to read from (value between 0 and 255)
  60746. * @param g defines the green component to read from (value between 0 and 255)
  60747. * @param b defines the blue component to read from (value between 0 and 255)
  60748. * @param a defines the alpha component to read from (value between 0 and 255)
  60749. * @returns a new Color3 object
  60750. */
  60751. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60752. /**
  60753. * Check the content of a given array and convert it to an array containing RGBA data
  60754. * If the original array was already containing count * 4 values then it is returned directly
  60755. * @param colors defines the array to check
  60756. * @param count defines the number of RGBA data to expect
  60757. * @returns an array containing count * 4 values (RGBA)
  60758. */
  60759. static CheckColors4(colors: number[], count: number): number[];
  60760. }
  60761. /**
  60762. * Class representing a vector containing 2 coordinates
  60763. */
  60764. export class Vector2 {
  60765. /** defines the first coordinate */
  60766. x: number;
  60767. /** defines the second coordinate */
  60768. y: number;
  60769. /**
  60770. * Creates a new Vector2 from the given x and y coordinates
  60771. * @param x defines the first coordinate
  60772. * @param y defines the second coordinate
  60773. */
  60774. constructor(
  60775. /** defines the first coordinate */
  60776. x?: number,
  60777. /** defines the second coordinate */
  60778. y?: number);
  60779. /**
  60780. * Gets a string with the Vector2 coordinates
  60781. * @returns a string with the Vector2 coordinates
  60782. */
  60783. toString(): string;
  60784. /**
  60785. * Gets class name
  60786. * @returns the string "Vector2"
  60787. */
  60788. getClassName(): string;
  60789. /**
  60790. * Gets current vector hash code
  60791. * @returns the Vector2 hash code as a number
  60792. */
  60793. getHashCode(): number;
  60794. /**
  60795. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60796. * @param array defines the source array
  60797. * @param index defines the offset in source array
  60798. * @returns the current Vector2
  60799. */
  60800. toArray(array: FloatArray, index?: number): Vector2;
  60801. /**
  60802. * Copy the current vector to an array
  60803. * @returns a new array with 2 elements: the Vector2 coordinates.
  60804. */
  60805. asArray(): number[];
  60806. /**
  60807. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60808. * @param source defines the source Vector2
  60809. * @returns the current updated Vector2
  60810. */
  60811. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60812. /**
  60813. * Sets the Vector2 coordinates with the given floats
  60814. * @param x defines the first coordinate
  60815. * @param y defines the second coordinate
  60816. * @returns the current updated Vector2
  60817. */
  60818. copyFromFloats(x: number, y: number): Vector2;
  60819. /**
  60820. * Sets the Vector2 coordinates with the given floats
  60821. * @param x defines the first coordinate
  60822. * @param y defines the second coordinate
  60823. * @returns the current updated Vector2
  60824. */
  60825. set(x: number, y: number): Vector2;
  60826. /**
  60827. * Add another vector with the current one
  60828. * @param otherVector defines the other vector
  60829. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60830. */
  60831. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60832. /**
  60833. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60834. * @param otherVector defines the other vector
  60835. * @param result defines the target vector
  60836. * @returns the unmodified current Vector2
  60837. */
  60838. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60839. /**
  60840. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60841. * @param otherVector defines the other vector
  60842. * @returns the current updated Vector2
  60843. */
  60844. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60845. /**
  60846. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60847. * @param otherVector defines the other vector
  60848. * @returns a new Vector2
  60849. */
  60850. addVector3(otherVector: Vector3): Vector2;
  60851. /**
  60852. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60853. * @param otherVector defines the other vector
  60854. * @returns a new Vector2
  60855. */
  60856. subtract(otherVector: Vector2): Vector2;
  60857. /**
  60858. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60859. * @param otherVector defines the other vector
  60860. * @param result defines the target vector
  60861. * @returns the unmodified current Vector2
  60862. */
  60863. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60864. /**
  60865. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60866. * @param otherVector defines the other vector
  60867. * @returns the current updated Vector2
  60868. */
  60869. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60870. /**
  60871. * Multiplies in place the current Vector2 coordinates by the given ones
  60872. * @param otherVector defines the other vector
  60873. * @returns the current updated Vector2
  60874. */
  60875. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60876. /**
  60877. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60878. * @param otherVector defines the other vector
  60879. * @returns a new Vector2
  60880. */
  60881. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60882. /**
  60883. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60884. * @param otherVector defines the other vector
  60885. * @param result defines the target vector
  60886. * @returns the unmodified current Vector2
  60887. */
  60888. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60889. /**
  60890. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60891. * @param x defines the first coordinate
  60892. * @param y defines the second coordinate
  60893. * @returns a new Vector2
  60894. */
  60895. multiplyByFloats(x: number, y: number): Vector2;
  60896. /**
  60897. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60898. * @param otherVector defines the other vector
  60899. * @returns a new Vector2
  60900. */
  60901. divide(otherVector: Vector2): Vector2;
  60902. /**
  60903. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60904. * @param otherVector defines the other vector
  60905. * @param result defines the target vector
  60906. * @returns the unmodified current Vector2
  60907. */
  60908. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60909. /**
  60910. * Divides the current Vector2 coordinates by the given ones
  60911. * @param otherVector defines the other vector
  60912. * @returns the current updated Vector2
  60913. */
  60914. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60915. /**
  60916. * Gets a new Vector2 with current Vector2 negated coordinates
  60917. * @returns a new Vector2
  60918. */
  60919. negate(): Vector2;
  60920. /**
  60921. * Multiply the Vector2 coordinates by scale
  60922. * @param scale defines the scaling factor
  60923. * @returns the current updated Vector2
  60924. */
  60925. scaleInPlace(scale: number): Vector2;
  60926. /**
  60927. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60928. * @param scale defines the scaling factor
  60929. * @returns a new Vector2
  60930. */
  60931. scale(scale: number): Vector2;
  60932. /**
  60933. * Scale the current Vector2 values by a factor to a given Vector2
  60934. * @param scale defines the scale factor
  60935. * @param result defines the Vector2 object where to store the result
  60936. * @returns the unmodified current Vector2
  60937. */
  60938. scaleToRef(scale: number, result: Vector2): Vector2;
  60939. /**
  60940. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60941. * @param scale defines the scale factor
  60942. * @param result defines the Vector2 object where to store the result
  60943. * @returns the unmodified current Vector2
  60944. */
  60945. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60946. /**
  60947. * Gets a boolean if two vectors are equals
  60948. * @param otherVector defines the other vector
  60949. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60950. */
  60951. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60952. /**
  60953. * Gets a boolean if two vectors are equals (using an epsilon value)
  60954. * @param otherVector defines the other vector
  60955. * @param epsilon defines the minimal distance to consider equality
  60956. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60957. */
  60958. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60959. /**
  60960. * Gets a new Vector2 from current Vector2 floored values
  60961. * @returns a new Vector2
  60962. */
  60963. floor(): Vector2;
  60964. /**
  60965. * Gets a new Vector2 from current Vector2 floored values
  60966. * @returns a new Vector2
  60967. */
  60968. fract(): Vector2;
  60969. /**
  60970. * Gets the length of the vector
  60971. * @returns the vector length (float)
  60972. */
  60973. length(): number;
  60974. /**
  60975. * Gets the vector squared length
  60976. * @returns the vector squared length (float)
  60977. */
  60978. lengthSquared(): number;
  60979. /**
  60980. * Normalize the vector
  60981. * @returns the current updated Vector2
  60982. */
  60983. normalize(): Vector2;
  60984. /**
  60985. * Gets a new Vector2 copied from the Vector2
  60986. * @returns a new Vector2
  60987. */
  60988. clone(): Vector2;
  60989. /**
  60990. * Gets a new Vector2(0, 0)
  60991. * @returns a new Vector2
  60992. */
  60993. static Zero(): Vector2;
  60994. /**
  60995. * Gets a new Vector2(1, 1)
  60996. * @returns a new Vector2
  60997. */
  60998. static One(): Vector2;
  60999. /**
  61000. * Gets a new Vector2 set from the given index element of the given array
  61001. * @param array defines the data source
  61002. * @param offset defines the offset in the data source
  61003. * @returns a new Vector2
  61004. */
  61005. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  61006. /**
  61007. * Sets "result" from the given index element of the given array
  61008. * @param array defines the data source
  61009. * @param offset defines the offset in the data source
  61010. * @param result defines the target vector
  61011. */
  61012. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  61013. /**
  61014. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  61015. * @param value1 defines 1st point of control
  61016. * @param value2 defines 2nd point of control
  61017. * @param value3 defines 3rd point of control
  61018. * @param value4 defines 4th point of control
  61019. * @param amount defines the interpolation factor
  61020. * @returns a new Vector2
  61021. */
  61022. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  61023. /**
  61024. * 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".
  61025. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61026. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61027. * @param value defines the value to clamp
  61028. * @param min defines the lower limit
  61029. * @param max defines the upper limit
  61030. * @returns a new Vector2
  61031. */
  61032. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61033. /**
  61034. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61035. * @param value1 defines the 1st control point
  61036. * @param tangent1 defines the outgoing tangent
  61037. * @param value2 defines the 2nd control point
  61038. * @param tangent2 defines the incoming tangent
  61039. * @param amount defines the interpolation factor
  61040. * @returns a new Vector2
  61041. */
  61042. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61043. /**
  61044. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61045. * @param start defines the start vector
  61046. * @param end defines the end vector
  61047. * @param amount defines the interpolation factor
  61048. * @returns a new Vector2
  61049. */
  61050. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61051. /**
  61052. * Gets the dot product of the vector "left" and the vector "right"
  61053. * @param left defines first vector
  61054. * @param right defines second vector
  61055. * @returns the dot product (float)
  61056. */
  61057. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61058. /**
  61059. * Returns a new Vector2 equal to the normalized given vector
  61060. * @param vector defines the vector to normalize
  61061. * @returns a new Vector2
  61062. */
  61063. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61064. /**
  61065. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61066. * @param left defines 1st vector
  61067. * @param right defines 2nd vector
  61068. * @returns a new Vector2
  61069. */
  61070. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61071. /**
  61072. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61073. * @param left defines 1st vector
  61074. * @param right defines 2nd vector
  61075. * @returns a new Vector2
  61076. */
  61077. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61078. /**
  61079. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61080. * @param vector defines the vector to transform
  61081. * @param transformation defines the matrix to apply
  61082. * @returns a new Vector2
  61083. */
  61084. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61085. /**
  61086. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61087. * @param vector defines the vector to transform
  61088. * @param transformation defines the matrix to apply
  61089. * @param result defines the target vector
  61090. */
  61091. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61092. /**
  61093. * Determines if a given vector is included in a triangle
  61094. * @param p defines the vector to test
  61095. * @param p0 defines 1st triangle point
  61096. * @param p1 defines 2nd triangle point
  61097. * @param p2 defines 3rd triangle point
  61098. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61099. */
  61100. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61101. /**
  61102. * Gets the distance between the vectors "value1" and "value2"
  61103. * @param value1 defines first vector
  61104. * @param value2 defines second vector
  61105. * @returns the distance between vectors
  61106. */
  61107. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61108. /**
  61109. * Returns the squared distance between the vectors "value1" and "value2"
  61110. * @param value1 defines first vector
  61111. * @param value2 defines second vector
  61112. * @returns the squared distance between vectors
  61113. */
  61114. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61115. /**
  61116. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61117. * @param value1 defines first vector
  61118. * @param value2 defines second vector
  61119. * @returns a new Vector2
  61120. */
  61121. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61122. /**
  61123. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61124. * @param p defines the middle point
  61125. * @param segA defines one point of the segment
  61126. * @param segB defines the other point of the segment
  61127. * @returns the shortest distance
  61128. */
  61129. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61130. }
  61131. /**
  61132. * Classed used to store (x,y,z) vector representation
  61133. * A Vector3 is the main object used in 3D geometry
  61134. * It can represent etiher the coordinates of a point the space, either a direction
  61135. * Reminder: js uses a left handed forward facing system
  61136. */
  61137. export class Vector3 {
  61138. /**
  61139. * Defines the first coordinates (on X axis)
  61140. */
  61141. x: number;
  61142. /**
  61143. * Defines the second coordinates (on Y axis)
  61144. */
  61145. y: number;
  61146. /**
  61147. * Defines the third coordinates (on Z axis)
  61148. */
  61149. z: number;
  61150. private static _UpReadOnly;
  61151. /**
  61152. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61153. * @param x defines the first coordinates (on X axis)
  61154. * @param y defines the second coordinates (on Y axis)
  61155. * @param z defines the third coordinates (on Z axis)
  61156. */
  61157. constructor(
  61158. /**
  61159. * Defines the first coordinates (on X axis)
  61160. */
  61161. x?: number,
  61162. /**
  61163. * Defines the second coordinates (on Y axis)
  61164. */
  61165. y?: number,
  61166. /**
  61167. * Defines the third coordinates (on Z axis)
  61168. */
  61169. z?: number);
  61170. /**
  61171. * Creates a string representation of the Vector3
  61172. * @returns a string with the Vector3 coordinates.
  61173. */
  61174. toString(): string;
  61175. /**
  61176. * Gets the class name
  61177. * @returns the string "Vector3"
  61178. */
  61179. getClassName(): string;
  61180. /**
  61181. * Creates the Vector3 hash code
  61182. * @returns a number which tends to be unique between Vector3 instances
  61183. */
  61184. getHashCode(): number;
  61185. /**
  61186. * Creates an array containing three elements : the coordinates of the Vector3
  61187. * @returns a new array of numbers
  61188. */
  61189. asArray(): number[];
  61190. /**
  61191. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61192. * @param array defines the destination array
  61193. * @param index defines the offset in the destination array
  61194. * @returns the current Vector3
  61195. */
  61196. toArray(array: FloatArray, index?: number): Vector3;
  61197. /**
  61198. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61199. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61200. */
  61201. toQuaternion(): Quaternion;
  61202. /**
  61203. * Adds the given vector to the current Vector3
  61204. * @param otherVector defines the second operand
  61205. * @returns the current updated Vector3
  61206. */
  61207. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61208. /**
  61209. * Adds the given coordinates to the current Vector3
  61210. * @param x defines the x coordinate of the operand
  61211. * @param y defines the y coordinate of the operand
  61212. * @param z defines the z coordinate of the operand
  61213. * @returns the current updated Vector3
  61214. */
  61215. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61216. /**
  61217. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61218. * @param otherVector defines the second operand
  61219. * @returns the resulting Vector3
  61220. */
  61221. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61222. /**
  61223. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61224. * @param otherVector defines the second operand
  61225. * @param result defines the Vector3 object where to store the result
  61226. * @returns the current Vector3
  61227. */
  61228. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61229. /**
  61230. * Subtract the given vector from the current Vector3
  61231. * @param otherVector defines the second operand
  61232. * @returns the current updated Vector3
  61233. */
  61234. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61235. /**
  61236. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61237. * @param otherVector defines the second operand
  61238. * @returns the resulting Vector3
  61239. */
  61240. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61241. /**
  61242. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61243. * @param otherVector defines the second operand
  61244. * @param result defines the Vector3 object where to store the result
  61245. * @returns the current Vector3
  61246. */
  61247. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61248. /**
  61249. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61250. * @param x defines the x coordinate of the operand
  61251. * @param y defines the y coordinate of the operand
  61252. * @param z defines the z coordinate of the operand
  61253. * @returns the resulting Vector3
  61254. */
  61255. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61256. /**
  61257. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61258. * @param x defines the x coordinate of the operand
  61259. * @param y defines the y coordinate of the operand
  61260. * @param z defines the z coordinate of the operand
  61261. * @param result defines the Vector3 object where to store the result
  61262. * @returns the current Vector3
  61263. */
  61264. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61265. /**
  61266. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61267. * @returns a new Vector3
  61268. */
  61269. negate(): Vector3;
  61270. /**
  61271. * Multiplies the Vector3 coordinates by the float "scale"
  61272. * @param scale defines the multiplier factor
  61273. * @returns the current updated Vector3
  61274. */
  61275. scaleInPlace(scale: number): Vector3;
  61276. /**
  61277. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61278. * @param scale defines the multiplier factor
  61279. * @returns a new Vector3
  61280. */
  61281. scale(scale: number): Vector3;
  61282. /**
  61283. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61284. * @param scale defines the multiplier factor
  61285. * @param result defines the Vector3 object where to store the result
  61286. * @returns the current Vector3
  61287. */
  61288. scaleToRef(scale: number, result: Vector3): Vector3;
  61289. /**
  61290. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61291. * @param scale defines the scale factor
  61292. * @param result defines the Vector3 object where to store the result
  61293. * @returns the unmodified current Vector3
  61294. */
  61295. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61296. /**
  61297. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61298. * @param otherVector defines the second operand
  61299. * @returns true if both vectors are equals
  61300. */
  61301. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61302. /**
  61303. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61304. * @param otherVector defines the second operand
  61305. * @param epsilon defines the minimal distance to define values as equals
  61306. * @returns true if both vectors are distant less than epsilon
  61307. */
  61308. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61309. /**
  61310. * Returns true if the current Vector3 coordinates equals the given floats
  61311. * @param x defines the x coordinate of the operand
  61312. * @param y defines the y coordinate of the operand
  61313. * @param z defines the z coordinate of the operand
  61314. * @returns true if both vectors are equals
  61315. */
  61316. equalsToFloats(x: number, y: number, z: number): boolean;
  61317. /**
  61318. * Multiplies the current Vector3 coordinates by the given ones
  61319. * @param otherVector defines the second operand
  61320. * @returns the current updated Vector3
  61321. */
  61322. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61323. /**
  61324. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61325. * @param otherVector defines the second operand
  61326. * @returns the new Vector3
  61327. */
  61328. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61329. /**
  61330. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61331. * @param otherVector defines the second operand
  61332. * @param result defines the Vector3 object where to store the result
  61333. * @returns the current Vector3
  61334. */
  61335. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61336. /**
  61337. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61338. * @param x defines the x coordinate of the operand
  61339. * @param y defines the y coordinate of the operand
  61340. * @param z defines the z coordinate of the operand
  61341. * @returns the new Vector3
  61342. */
  61343. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61344. /**
  61345. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61346. * @param otherVector defines the second operand
  61347. * @returns the new Vector3
  61348. */
  61349. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61350. /**
  61351. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61352. * @param otherVector defines the second operand
  61353. * @param result defines the Vector3 object where to store the result
  61354. * @returns the current Vector3
  61355. */
  61356. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61357. /**
  61358. * Divides the current Vector3 coordinates by the given ones.
  61359. * @param otherVector defines the second operand
  61360. * @returns the current updated Vector3
  61361. */
  61362. divideInPlace(otherVector: Vector3): Vector3;
  61363. /**
  61364. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61365. * @param other defines the second operand
  61366. * @returns the current updated Vector3
  61367. */
  61368. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61369. /**
  61370. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61371. * @param other defines the second operand
  61372. * @returns the current updated Vector3
  61373. */
  61374. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61375. /**
  61376. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61377. * @param x defines the x coordinate of the operand
  61378. * @param y defines the y coordinate of the operand
  61379. * @param z defines the z coordinate of the operand
  61380. * @returns the current updated Vector3
  61381. */
  61382. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61383. /**
  61384. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61385. * @param x defines the x coordinate of the operand
  61386. * @param y defines the y coordinate of the operand
  61387. * @param z defines the z coordinate of the operand
  61388. * @returns the current updated Vector3
  61389. */
  61390. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61391. /**
  61392. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61393. * Check if is non uniform within a certain amount of decimal places to account for this
  61394. * @param epsilon the amount the values can differ
  61395. * @returns if the the vector is non uniform to a certain number of decimal places
  61396. */
  61397. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61398. /**
  61399. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61400. */
  61401. readonly isNonUniform: boolean;
  61402. /**
  61403. * Gets a new Vector3 from current Vector3 floored values
  61404. * @returns a new Vector3
  61405. */
  61406. floor(): Vector3;
  61407. /**
  61408. * Gets a new Vector3 from current Vector3 floored values
  61409. * @returns a new Vector3
  61410. */
  61411. fract(): Vector3;
  61412. /**
  61413. * Gets the length of the Vector3
  61414. * @returns the length of the Vecto3
  61415. */
  61416. length(): number;
  61417. /**
  61418. * Gets the squared length of the Vector3
  61419. * @returns squared length of the Vector3
  61420. */
  61421. lengthSquared(): number;
  61422. /**
  61423. * Normalize the current Vector3.
  61424. * Please note that this is an in place operation.
  61425. * @returns the current updated Vector3
  61426. */
  61427. normalize(): Vector3;
  61428. /**
  61429. * Reorders the x y z properties of the vector in place
  61430. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61431. * @returns the current updated vector
  61432. */
  61433. reorderInPlace(order: string): this;
  61434. /**
  61435. * Rotates the vector around 0,0,0 by a quaternion
  61436. * @param quaternion the rotation quaternion
  61437. * @param result vector to store the result
  61438. * @returns the resulting vector
  61439. */
  61440. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61441. /**
  61442. * Rotates a vector around a given point
  61443. * @param quaternion the rotation quaternion
  61444. * @param point the point to rotate around
  61445. * @param result vector to store the result
  61446. * @returns the resulting vector
  61447. */
  61448. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61449. /**
  61450. * Normalize the current Vector3 with the given input length.
  61451. * Please note that this is an in place operation.
  61452. * @param len the length of the vector
  61453. * @returns the current updated Vector3
  61454. */
  61455. normalizeFromLength(len: number): Vector3;
  61456. /**
  61457. * Normalize the current Vector3 to a new vector
  61458. * @returns the new Vector3
  61459. */
  61460. normalizeToNew(): Vector3;
  61461. /**
  61462. * Normalize the current Vector3 to the reference
  61463. * @param reference define the Vector3 to update
  61464. * @returns the updated Vector3
  61465. */
  61466. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61467. /**
  61468. * Creates a new Vector3 copied from the current Vector3
  61469. * @returns the new Vector3
  61470. */
  61471. clone(): Vector3;
  61472. /**
  61473. * Copies the given vector coordinates to the current Vector3 ones
  61474. * @param source defines the source Vector3
  61475. * @returns the current updated Vector3
  61476. */
  61477. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61478. /**
  61479. * Copies the given floats to the current Vector3 coordinates
  61480. * @param x defines the x coordinate of the operand
  61481. * @param y defines the y coordinate of the operand
  61482. * @param z defines the z coordinate of the operand
  61483. * @returns the current updated Vector3
  61484. */
  61485. copyFromFloats(x: number, y: number, z: number): Vector3;
  61486. /**
  61487. * Copies the given floats to the current Vector3 coordinates
  61488. * @param x defines the x coordinate of the operand
  61489. * @param y defines the y coordinate of the operand
  61490. * @param z defines the z coordinate of the operand
  61491. * @returns the current updated Vector3
  61492. */
  61493. set(x: number, y: number, z: number): Vector3;
  61494. /**
  61495. * Copies the given float to the current Vector3 coordinates
  61496. * @param v defines the x, y and z coordinates of the operand
  61497. * @returns the current updated Vector3
  61498. */
  61499. setAll(v: number): Vector3;
  61500. /**
  61501. * Get the clip factor between two vectors
  61502. * @param vector0 defines the first operand
  61503. * @param vector1 defines the second operand
  61504. * @param axis defines the axis to use
  61505. * @param size defines the size along the axis
  61506. * @returns the clip factor
  61507. */
  61508. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61509. /**
  61510. * Get angle between two vectors
  61511. * @param vector0 angle between vector0 and vector1
  61512. * @param vector1 angle between vector0 and vector1
  61513. * @param normal direction of the normal
  61514. * @return the angle between vector0 and vector1
  61515. */
  61516. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61517. /**
  61518. * Returns a new Vector3 set from the index "offset" of the given array
  61519. * @param array defines the source array
  61520. * @param offset defines the offset in the source array
  61521. * @returns the new Vector3
  61522. */
  61523. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61524. /**
  61525. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61526. * This function is deprecated. Use FromArray instead
  61527. * @param array defines the source array
  61528. * @param offset defines the offset in the source array
  61529. * @returns the new Vector3
  61530. */
  61531. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61532. /**
  61533. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61534. * @param array defines the source array
  61535. * @param offset defines the offset in the source array
  61536. * @param result defines the Vector3 where to store the result
  61537. */
  61538. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61539. /**
  61540. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61541. * This function is deprecated. Use FromArrayToRef instead.
  61542. * @param array defines the source array
  61543. * @param offset defines the offset in the source array
  61544. * @param result defines the Vector3 where to store the result
  61545. */
  61546. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61547. /**
  61548. * Sets the given vector "result" with the given floats.
  61549. * @param x defines the x coordinate of the source
  61550. * @param y defines the y coordinate of the source
  61551. * @param z defines the z coordinate of the source
  61552. * @param result defines the Vector3 where to store the result
  61553. */
  61554. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61555. /**
  61556. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61557. * @returns a new empty Vector3
  61558. */
  61559. static Zero(): Vector3;
  61560. /**
  61561. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61562. * @returns a new unit Vector3
  61563. */
  61564. static One(): Vector3;
  61565. /**
  61566. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61567. * @returns a new up Vector3
  61568. */
  61569. static Up(): Vector3;
  61570. /**
  61571. * Gets a up Vector3 that must not be updated
  61572. */
  61573. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61574. /**
  61575. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61576. * @returns a new down Vector3
  61577. */
  61578. static Down(): Vector3;
  61579. /**
  61580. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61581. * @returns a new forward Vector3
  61582. */
  61583. static Forward(): Vector3;
  61584. /**
  61585. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61586. * @returns a new forward Vector3
  61587. */
  61588. static Backward(): Vector3;
  61589. /**
  61590. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61591. * @returns a new right Vector3
  61592. */
  61593. static Right(): Vector3;
  61594. /**
  61595. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61596. * @returns a new left Vector3
  61597. */
  61598. static Left(): Vector3;
  61599. /**
  61600. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61601. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61602. * @param vector defines the Vector3 to transform
  61603. * @param transformation defines the transformation matrix
  61604. * @returns the transformed Vector3
  61605. */
  61606. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61607. /**
  61608. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61609. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61610. * @param vector defines the Vector3 to transform
  61611. * @param transformation defines the transformation matrix
  61612. * @param result defines the Vector3 where to store the result
  61613. */
  61614. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61615. /**
  61616. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61617. * This method computes tranformed coordinates only, not transformed direction vectors
  61618. * @param x define the x coordinate of the source vector
  61619. * @param y define the y coordinate of the source vector
  61620. * @param z define the z coordinate of the source vector
  61621. * @param transformation defines the transformation matrix
  61622. * @param result defines the Vector3 where to store the result
  61623. */
  61624. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61625. /**
  61626. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61627. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61628. * @param vector defines the Vector3 to transform
  61629. * @param transformation defines the transformation matrix
  61630. * @returns the new Vector3
  61631. */
  61632. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61633. /**
  61634. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61635. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61636. * @param vector defines the Vector3 to transform
  61637. * @param transformation defines the transformation matrix
  61638. * @param result defines the Vector3 where to store the result
  61639. */
  61640. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61641. /**
  61642. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61643. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61644. * @param x define the x coordinate of the source vector
  61645. * @param y define the y coordinate of the source vector
  61646. * @param z define the z coordinate of the source vector
  61647. * @param transformation defines the transformation matrix
  61648. * @param result defines the Vector3 where to store the result
  61649. */
  61650. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61651. /**
  61652. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61653. * @param value1 defines the first control point
  61654. * @param value2 defines the second control point
  61655. * @param value3 defines the third control point
  61656. * @param value4 defines the fourth control point
  61657. * @param amount defines the amount on the spline to use
  61658. * @returns the new Vector3
  61659. */
  61660. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61661. /**
  61662. * 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"
  61663. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61664. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61665. * @param value defines the current value
  61666. * @param min defines the lower range value
  61667. * @param max defines the upper range value
  61668. * @returns the new Vector3
  61669. */
  61670. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61671. /**
  61672. * 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"
  61673. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61674. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61675. * @param value defines the current value
  61676. * @param min defines the lower range value
  61677. * @param max defines the upper range value
  61678. * @param result defines the Vector3 where to store the result
  61679. */
  61680. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61681. /**
  61682. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61683. * @param value1 defines the first control point
  61684. * @param tangent1 defines the first tangent vector
  61685. * @param value2 defines the second control point
  61686. * @param tangent2 defines the second tangent vector
  61687. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61688. * @returns the new Vector3
  61689. */
  61690. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61691. /**
  61692. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61693. * @param start defines the start value
  61694. * @param end defines the end value
  61695. * @param amount max defines amount between both (between 0 and 1)
  61696. * @returns the new Vector3
  61697. */
  61698. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61699. /**
  61700. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61701. * @param start defines the start value
  61702. * @param end defines the end value
  61703. * @param amount max defines amount between both (between 0 and 1)
  61704. * @param result defines the Vector3 where to store the result
  61705. */
  61706. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61707. /**
  61708. * Returns the dot product (float) between the vectors "left" and "right"
  61709. * @param left defines the left operand
  61710. * @param right defines the right operand
  61711. * @returns the dot product
  61712. */
  61713. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61714. /**
  61715. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61716. * The cross product is then orthogonal to both "left" and "right"
  61717. * @param left defines the left operand
  61718. * @param right defines the right operand
  61719. * @returns the cross product
  61720. */
  61721. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61722. /**
  61723. * Sets the given vector "result" with the cross product of "left" and "right"
  61724. * The cross product is then orthogonal to both "left" and "right"
  61725. * @param left defines the left operand
  61726. * @param right defines the right operand
  61727. * @param result defines the Vector3 where to store the result
  61728. */
  61729. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61730. /**
  61731. * Returns a new Vector3 as the normalization of the given vector
  61732. * @param vector defines the Vector3 to normalize
  61733. * @returns the new Vector3
  61734. */
  61735. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61736. /**
  61737. * Sets the given vector "result" with the normalization of the given first vector
  61738. * @param vector defines the Vector3 to normalize
  61739. * @param result defines the Vector3 where to store the result
  61740. */
  61741. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61742. /**
  61743. * Project a Vector3 onto screen space
  61744. * @param vector defines the Vector3 to project
  61745. * @param world defines the world matrix to use
  61746. * @param transform defines the transform (view x projection) matrix to use
  61747. * @param viewport defines the screen viewport to use
  61748. * @returns the new Vector3
  61749. */
  61750. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61751. /** @hidden */
  61752. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61753. /**
  61754. * Unproject from screen space to object space
  61755. * @param source defines the screen space Vector3 to use
  61756. * @param viewportWidth defines the current width of the viewport
  61757. * @param viewportHeight defines the current height of the viewport
  61758. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61759. * @param transform defines the transform (view x projection) matrix to use
  61760. * @returns the new Vector3
  61761. */
  61762. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61763. /**
  61764. * Unproject from screen space to object space
  61765. * @param source defines the screen space Vector3 to use
  61766. * @param viewportWidth defines the current width of the viewport
  61767. * @param viewportHeight defines the current height of the viewport
  61768. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61769. * @param view defines the view matrix to use
  61770. * @param projection defines the projection matrix to use
  61771. * @returns the new Vector3
  61772. */
  61773. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61774. /**
  61775. * Unproject from screen space to object space
  61776. * @param source defines the screen space Vector3 to use
  61777. * @param viewportWidth defines the current width of the viewport
  61778. * @param viewportHeight defines the current height of the viewport
  61779. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61780. * @param view defines the view matrix to use
  61781. * @param projection defines the projection matrix to use
  61782. * @param result defines the Vector3 where to store the result
  61783. */
  61784. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61785. /**
  61786. * Unproject from screen space to object space
  61787. * @param sourceX defines the screen space x coordinate to use
  61788. * @param sourceY defines the screen space y coordinate to use
  61789. * @param sourceZ defines the screen space z coordinate to use
  61790. * @param viewportWidth defines the current width of the viewport
  61791. * @param viewportHeight defines the current height of the viewport
  61792. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61793. * @param view defines the view matrix to use
  61794. * @param projection defines the projection matrix to use
  61795. * @param result defines the Vector3 where to store the result
  61796. */
  61797. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61798. /**
  61799. * Gets the minimal coordinate values between two Vector3
  61800. * @param left defines the first operand
  61801. * @param right defines the second operand
  61802. * @returns the new Vector3
  61803. */
  61804. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61805. /**
  61806. * Gets the maximal coordinate values between two Vector3
  61807. * @param left defines the first operand
  61808. * @param right defines the second operand
  61809. * @returns the new Vector3
  61810. */
  61811. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61812. /**
  61813. * Returns the distance between the vectors "value1" and "value2"
  61814. * @param value1 defines the first operand
  61815. * @param value2 defines the second operand
  61816. * @returns the distance
  61817. */
  61818. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61819. /**
  61820. * Returns the squared distance between the vectors "value1" and "value2"
  61821. * @param value1 defines the first operand
  61822. * @param value2 defines the second operand
  61823. * @returns the squared distance
  61824. */
  61825. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61826. /**
  61827. * Returns a new Vector3 located at the center between "value1" and "value2"
  61828. * @param value1 defines the first operand
  61829. * @param value2 defines the second operand
  61830. * @returns the new Vector3
  61831. */
  61832. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61833. /**
  61834. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61835. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61836. * to something in order to rotate it from its local system to the given target system
  61837. * Note: axis1, axis2 and axis3 are normalized during this operation
  61838. * @param axis1 defines the first axis
  61839. * @param axis2 defines the second axis
  61840. * @param axis3 defines the third axis
  61841. * @returns a new Vector3
  61842. */
  61843. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61844. /**
  61845. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61846. * @param axis1 defines the first axis
  61847. * @param axis2 defines the second axis
  61848. * @param axis3 defines the third axis
  61849. * @param ref defines the Vector3 where to store the result
  61850. */
  61851. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61852. }
  61853. /**
  61854. * Vector4 class created for EulerAngle class conversion to Quaternion
  61855. */
  61856. export class Vector4 {
  61857. /** x value of the vector */
  61858. x: number;
  61859. /** y value of the vector */
  61860. y: number;
  61861. /** z value of the vector */
  61862. z: number;
  61863. /** w value of the vector */
  61864. w: number;
  61865. /**
  61866. * Creates a Vector4 object from the given floats.
  61867. * @param x x value of the vector
  61868. * @param y y value of the vector
  61869. * @param z z value of the vector
  61870. * @param w w value of the vector
  61871. */
  61872. constructor(
  61873. /** x value of the vector */
  61874. x: number,
  61875. /** y value of the vector */
  61876. y: number,
  61877. /** z value of the vector */
  61878. z: number,
  61879. /** w value of the vector */
  61880. w: number);
  61881. /**
  61882. * Returns the string with the Vector4 coordinates.
  61883. * @returns a string containing all the vector values
  61884. */
  61885. toString(): string;
  61886. /**
  61887. * Returns the string "Vector4".
  61888. * @returns "Vector4"
  61889. */
  61890. getClassName(): string;
  61891. /**
  61892. * Returns the Vector4 hash code.
  61893. * @returns a unique hash code
  61894. */
  61895. getHashCode(): number;
  61896. /**
  61897. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61898. * @returns the resulting array
  61899. */
  61900. asArray(): number[];
  61901. /**
  61902. * Populates the given array from the given index with the Vector4 coordinates.
  61903. * @param array array to populate
  61904. * @param index index of the array to start at (default: 0)
  61905. * @returns the Vector4.
  61906. */
  61907. toArray(array: FloatArray, index?: number): Vector4;
  61908. /**
  61909. * Adds the given vector to the current Vector4.
  61910. * @param otherVector the vector to add
  61911. * @returns the updated Vector4.
  61912. */
  61913. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61914. /**
  61915. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61916. * @param otherVector the vector to add
  61917. * @returns the resulting vector
  61918. */
  61919. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61920. /**
  61921. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61922. * @param otherVector the vector to add
  61923. * @param result the vector to store the result
  61924. * @returns the current Vector4.
  61925. */
  61926. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61927. /**
  61928. * Subtract in place the given vector from the current Vector4.
  61929. * @param otherVector the vector to subtract
  61930. * @returns the updated Vector4.
  61931. */
  61932. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61933. /**
  61934. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61935. * @param otherVector the vector to add
  61936. * @returns the new vector with the result
  61937. */
  61938. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61939. /**
  61940. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61941. * @param otherVector the vector to subtract
  61942. * @param result the vector to store the result
  61943. * @returns the current Vector4.
  61944. */
  61945. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61946. /**
  61947. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61948. */
  61949. /**
  61950. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61951. * @param x value to subtract
  61952. * @param y value to subtract
  61953. * @param z value to subtract
  61954. * @param w value to subtract
  61955. * @returns new vector containing the result
  61956. */
  61957. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61958. /**
  61959. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61960. * @param x value to subtract
  61961. * @param y value to subtract
  61962. * @param z value to subtract
  61963. * @param w value to subtract
  61964. * @param result the vector to store the result in
  61965. * @returns the current Vector4.
  61966. */
  61967. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61968. /**
  61969. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61970. * @returns a new vector with the negated values
  61971. */
  61972. negate(): Vector4;
  61973. /**
  61974. * Multiplies the current Vector4 coordinates by scale (float).
  61975. * @param scale the number to scale with
  61976. * @returns the updated Vector4.
  61977. */
  61978. scaleInPlace(scale: number): Vector4;
  61979. /**
  61980. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61981. * @param scale the number to scale with
  61982. * @returns a new vector with the result
  61983. */
  61984. scale(scale: number): Vector4;
  61985. /**
  61986. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61987. * @param scale the number to scale with
  61988. * @param result a vector to store the result in
  61989. * @returns the current Vector4.
  61990. */
  61991. scaleToRef(scale: number, result: Vector4): Vector4;
  61992. /**
  61993. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61994. * @param scale defines the scale factor
  61995. * @param result defines the Vector4 object where to store the result
  61996. * @returns the unmodified current Vector4
  61997. */
  61998. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61999. /**
  62000. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  62001. * @param otherVector the vector to compare against
  62002. * @returns true if they are equal
  62003. */
  62004. equals(otherVector: DeepImmutable<Vector4>): boolean;
  62005. /**
  62006. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  62007. * @param otherVector vector to compare against
  62008. * @param epsilon (Default: very small number)
  62009. * @returns true if they are equal
  62010. */
  62011. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  62012. /**
  62013. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  62014. * @param x x value to compare against
  62015. * @param y y value to compare against
  62016. * @param z z value to compare against
  62017. * @param w w value to compare against
  62018. * @returns true if equal
  62019. */
  62020. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  62021. /**
  62022. * Multiplies in place the current Vector4 by the given one.
  62023. * @param otherVector vector to multiple with
  62024. * @returns the updated Vector4.
  62025. */
  62026. multiplyInPlace(otherVector: Vector4): Vector4;
  62027. /**
  62028. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62029. * @param otherVector vector to multiple with
  62030. * @returns resulting new vector
  62031. */
  62032. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62033. /**
  62034. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62035. * @param otherVector vector to multiple with
  62036. * @param result vector to store the result
  62037. * @returns the current Vector4.
  62038. */
  62039. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62040. /**
  62041. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62042. * @param x x value multiply with
  62043. * @param y y value multiply with
  62044. * @param z z value multiply with
  62045. * @param w w value multiply with
  62046. * @returns resulting new vector
  62047. */
  62048. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62049. /**
  62050. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62051. * @param otherVector vector to devide with
  62052. * @returns resulting new vector
  62053. */
  62054. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62055. /**
  62056. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62057. * @param otherVector vector to devide with
  62058. * @param result vector to store the result
  62059. * @returns the current Vector4.
  62060. */
  62061. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62062. /**
  62063. * Divides the current Vector3 coordinates by the given ones.
  62064. * @param otherVector vector to devide with
  62065. * @returns the updated Vector3.
  62066. */
  62067. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62068. /**
  62069. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62070. * @param other defines the second operand
  62071. * @returns the current updated Vector4
  62072. */
  62073. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62074. /**
  62075. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62076. * @param other defines the second operand
  62077. * @returns the current updated Vector4
  62078. */
  62079. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62080. /**
  62081. * Gets a new Vector4 from current Vector4 floored values
  62082. * @returns a new Vector4
  62083. */
  62084. floor(): Vector4;
  62085. /**
  62086. * Gets a new Vector4 from current Vector3 floored values
  62087. * @returns a new Vector4
  62088. */
  62089. fract(): Vector4;
  62090. /**
  62091. * Returns the Vector4 length (float).
  62092. * @returns the length
  62093. */
  62094. length(): number;
  62095. /**
  62096. * Returns the Vector4 squared length (float).
  62097. * @returns the length squared
  62098. */
  62099. lengthSquared(): number;
  62100. /**
  62101. * Normalizes in place the Vector4.
  62102. * @returns the updated Vector4.
  62103. */
  62104. normalize(): Vector4;
  62105. /**
  62106. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62107. * @returns this converted to a new vector3
  62108. */
  62109. toVector3(): Vector3;
  62110. /**
  62111. * Returns a new Vector4 copied from the current one.
  62112. * @returns the new cloned vector
  62113. */
  62114. clone(): Vector4;
  62115. /**
  62116. * Updates the current Vector4 with the given one coordinates.
  62117. * @param source the source vector to copy from
  62118. * @returns the updated Vector4.
  62119. */
  62120. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62121. /**
  62122. * Updates the current Vector4 coordinates with the given floats.
  62123. * @param x float to copy from
  62124. * @param y float to copy from
  62125. * @param z float to copy from
  62126. * @param w float to copy from
  62127. * @returns the updated Vector4.
  62128. */
  62129. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62130. /**
  62131. * Updates the current Vector4 coordinates with the given floats.
  62132. * @param x float to set from
  62133. * @param y float to set from
  62134. * @param z float to set from
  62135. * @param w float to set from
  62136. * @returns the updated Vector4.
  62137. */
  62138. set(x: number, y: number, z: number, w: number): Vector4;
  62139. /**
  62140. * Copies the given float to the current Vector3 coordinates
  62141. * @param v defines the x, y, z and w coordinates of the operand
  62142. * @returns the current updated Vector3
  62143. */
  62144. setAll(v: number): Vector4;
  62145. /**
  62146. * Returns a new Vector4 set from the starting index of the given array.
  62147. * @param array the array to pull values from
  62148. * @param offset the offset into the array to start at
  62149. * @returns the new vector
  62150. */
  62151. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62152. /**
  62153. * Updates the given vector "result" from the starting index of the given array.
  62154. * @param array the array to pull values from
  62155. * @param offset the offset into the array to start at
  62156. * @param result the vector to store the result in
  62157. */
  62158. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62159. /**
  62160. * Updates the given vector "result" from the starting index of the given Float32Array.
  62161. * @param array the array to pull values from
  62162. * @param offset the offset into the array to start at
  62163. * @param result the vector to store the result in
  62164. */
  62165. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62166. /**
  62167. * Updates the given vector "result" coordinates from the given floats.
  62168. * @param x float to set from
  62169. * @param y float to set from
  62170. * @param z float to set from
  62171. * @param w float to set from
  62172. * @param result the vector to the floats in
  62173. */
  62174. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62175. /**
  62176. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62177. * @returns the new vector
  62178. */
  62179. static Zero(): Vector4;
  62180. /**
  62181. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62182. * @returns the new vector
  62183. */
  62184. static One(): Vector4;
  62185. /**
  62186. * Returns a new normalized Vector4 from the given one.
  62187. * @param vector the vector to normalize
  62188. * @returns the vector
  62189. */
  62190. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62191. /**
  62192. * Updates the given vector "result" from the normalization of the given one.
  62193. * @param vector the vector to normalize
  62194. * @param result the vector to store the result in
  62195. */
  62196. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62197. /**
  62198. * Returns a vector with the minimum values from the left and right vectors
  62199. * @param left left vector to minimize
  62200. * @param right right vector to minimize
  62201. * @returns a new vector with the minimum of the left and right vector values
  62202. */
  62203. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62204. /**
  62205. * Returns a vector with the maximum values from the left and right vectors
  62206. * @param left left vector to maximize
  62207. * @param right right vector to maximize
  62208. * @returns a new vector with the maximum of the left and right vector values
  62209. */
  62210. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62211. /**
  62212. * Returns the distance (float) between the vectors "value1" and "value2".
  62213. * @param value1 value to calulate the distance between
  62214. * @param value2 value to calulate the distance between
  62215. * @return the distance between the two vectors
  62216. */
  62217. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62218. /**
  62219. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62220. * @param value1 value to calulate the distance between
  62221. * @param value2 value to calulate the distance between
  62222. * @return the distance between the two vectors squared
  62223. */
  62224. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62225. /**
  62226. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62227. * @param value1 value to calulate the center between
  62228. * @param value2 value to calulate the center between
  62229. * @return the center between the two vectors
  62230. */
  62231. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62232. /**
  62233. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62234. * This methods computes transformed normalized direction vectors only.
  62235. * @param vector the vector to transform
  62236. * @param transformation the transformation matrix to apply
  62237. * @returns the new vector
  62238. */
  62239. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62240. /**
  62241. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62242. * This methods computes transformed normalized direction vectors only.
  62243. * @param vector the vector to transform
  62244. * @param transformation the transformation matrix to apply
  62245. * @param result the vector to store the result in
  62246. */
  62247. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62248. /**
  62249. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62250. * This methods computes transformed normalized direction vectors only.
  62251. * @param x value to transform
  62252. * @param y value to transform
  62253. * @param z value to transform
  62254. * @param w value to transform
  62255. * @param transformation the transformation matrix to apply
  62256. * @param result the vector to store the results in
  62257. */
  62258. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62259. /**
  62260. * Creates a new Vector4 from a Vector3
  62261. * @param source defines the source data
  62262. * @param w defines the 4th component (default is 0)
  62263. * @returns a new Vector4
  62264. */
  62265. static FromVector3(source: Vector3, w?: number): Vector4;
  62266. }
  62267. /**
  62268. * Interface for the size containing width and height
  62269. */
  62270. export interface ISize {
  62271. /**
  62272. * Width
  62273. */
  62274. width: number;
  62275. /**
  62276. * Heighht
  62277. */
  62278. height: number;
  62279. }
  62280. /**
  62281. * Size containing widht and height
  62282. */
  62283. export class Size implements ISize {
  62284. /**
  62285. * Width
  62286. */
  62287. width: number;
  62288. /**
  62289. * Height
  62290. */
  62291. height: number;
  62292. /**
  62293. * Creates a Size object from the given width and height (floats).
  62294. * @param width width of the new size
  62295. * @param height height of the new size
  62296. */
  62297. constructor(width: number, height: number);
  62298. /**
  62299. * Returns a string with the Size width and height
  62300. * @returns a string with the Size width and height
  62301. */
  62302. toString(): string;
  62303. /**
  62304. * "Size"
  62305. * @returns the string "Size"
  62306. */
  62307. getClassName(): string;
  62308. /**
  62309. * Returns the Size hash code.
  62310. * @returns a hash code for a unique width and height
  62311. */
  62312. getHashCode(): number;
  62313. /**
  62314. * Updates the current size from the given one.
  62315. * @param src the given size
  62316. */
  62317. copyFrom(src: Size): void;
  62318. /**
  62319. * Updates in place the current Size from the given floats.
  62320. * @param width width of the new size
  62321. * @param height height of the new size
  62322. * @returns the updated Size.
  62323. */
  62324. copyFromFloats(width: number, height: number): Size;
  62325. /**
  62326. * Updates in place the current Size from the given floats.
  62327. * @param width width to set
  62328. * @param height height to set
  62329. * @returns the updated Size.
  62330. */
  62331. set(width: number, height: number): Size;
  62332. /**
  62333. * Multiplies the width and height by numbers
  62334. * @param w factor to multiple the width by
  62335. * @param h factor to multiple the height by
  62336. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62337. */
  62338. multiplyByFloats(w: number, h: number): Size;
  62339. /**
  62340. * Clones the size
  62341. * @returns a new Size copied from the given one.
  62342. */
  62343. clone(): Size;
  62344. /**
  62345. * True if the current Size and the given one width and height are strictly equal.
  62346. * @param other the other size to compare against
  62347. * @returns True if the current Size and the given one width and height are strictly equal.
  62348. */
  62349. equals(other: Size): boolean;
  62350. /**
  62351. * The surface of the Size : width * height (float).
  62352. */
  62353. readonly surface: number;
  62354. /**
  62355. * Create a new size of zero
  62356. * @returns a new Size set to (0.0, 0.0)
  62357. */
  62358. static Zero(): Size;
  62359. /**
  62360. * Sums the width and height of two sizes
  62361. * @param otherSize size to add to this size
  62362. * @returns a new Size set as the addition result of the current Size and the given one.
  62363. */
  62364. add(otherSize: Size): Size;
  62365. /**
  62366. * Subtracts the width and height of two
  62367. * @param otherSize size to subtract to this size
  62368. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62369. */
  62370. subtract(otherSize: Size): Size;
  62371. /**
  62372. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62373. * @param start starting size to lerp between
  62374. * @param end end size to lerp between
  62375. * @param amount amount to lerp between the start and end values
  62376. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62377. */
  62378. static Lerp(start: Size, end: Size, amount: number): Size;
  62379. }
  62380. /**
  62381. * Class used to store quaternion data
  62382. * @see https://en.wikipedia.org/wiki/Quaternion
  62383. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62384. */
  62385. export class Quaternion {
  62386. /** defines the first component (0 by default) */
  62387. x: number;
  62388. /** defines the second component (0 by default) */
  62389. y: number;
  62390. /** defines the third component (0 by default) */
  62391. z: number;
  62392. /** defines the fourth component (1.0 by default) */
  62393. w: number;
  62394. /**
  62395. * Creates a new Quaternion from the given floats
  62396. * @param x defines the first component (0 by default)
  62397. * @param y defines the second component (0 by default)
  62398. * @param z defines the third component (0 by default)
  62399. * @param w defines the fourth component (1.0 by default)
  62400. */
  62401. constructor(
  62402. /** defines the first component (0 by default) */
  62403. x?: number,
  62404. /** defines the second component (0 by default) */
  62405. y?: number,
  62406. /** defines the third component (0 by default) */
  62407. z?: number,
  62408. /** defines the fourth component (1.0 by default) */
  62409. w?: number);
  62410. /**
  62411. * Gets a string representation for the current quaternion
  62412. * @returns a string with the Quaternion coordinates
  62413. */
  62414. toString(): string;
  62415. /**
  62416. * Gets the class name of the quaternion
  62417. * @returns the string "Quaternion"
  62418. */
  62419. getClassName(): string;
  62420. /**
  62421. * Gets a hash code for this quaternion
  62422. * @returns the quaternion hash code
  62423. */
  62424. getHashCode(): number;
  62425. /**
  62426. * Copy the quaternion to an array
  62427. * @returns a new array populated with 4 elements from the quaternion coordinates
  62428. */
  62429. asArray(): number[];
  62430. /**
  62431. * Check if two quaternions are equals
  62432. * @param otherQuaternion defines the second operand
  62433. * @return true if the current quaternion and the given one coordinates are strictly equals
  62434. */
  62435. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62436. /**
  62437. * Clone the current quaternion
  62438. * @returns a new quaternion copied from the current one
  62439. */
  62440. clone(): Quaternion;
  62441. /**
  62442. * Copy a quaternion to the current one
  62443. * @param other defines the other quaternion
  62444. * @returns the updated current quaternion
  62445. */
  62446. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62447. /**
  62448. * Updates the current quaternion with the given float coordinates
  62449. * @param x defines the x coordinate
  62450. * @param y defines the y coordinate
  62451. * @param z defines the z coordinate
  62452. * @param w defines the w coordinate
  62453. * @returns the updated current quaternion
  62454. */
  62455. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62456. /**
  62457. * Updates the current quaternion from the given float coordinates
  62458. * @param x defines the x coordinate
  62459. * @param y defines the y coordinate
  62460. * @param z defines the z coordinate
  62461. * @param w defines the w coordinate
  62462. * @returns the updated current quaternion
  62463. */
  62464. set(x: number, y: number, z: number, w: number): Quaternion;
  62465. /**
  62466. * Adds two quaternions
  62467. * @param other defines the second operand
  62468. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62469. */
  62470. add(other: DeepImmutable<Quaternion>): Quaternion;
  62471. /**
  62472. * Add a quaternion to the current one
  62473. * @param other defines the quaternion to add
  62474. * @returns the current quaternion
  62475. */
  62476. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62477. /**
  62478. * Subtract two quaternions
  62479. * @param other defines the second operand
  62480. * @returns a new quaternion as the subtraction result of the given one from the current one
  62481. */
  62482. subtract(other: Quaternion): Quaternion;
  62483. /**
  62484. * Multiplies the current quaternion by a scale factor
  62485. * @param value defines the scale factor
  62486. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62487. */
  62488. scale(value: number): Quaternion;
  62489. /**
  62490. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62491. * @param scale defines the scale factor
  62492. * @param result defines the Quaternion object where to store the result
  62493. * @returns the unmodified current quaternion
  62494. */
  62495. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62496. /**
  62497. * Multiplies in place the current quaternion by a scale factor
  62498. * @param value defines the scale factor
  62499. * @returns the current modified quaternion
  62500. */
  62501. scaleInPlace(value: number): Quaternion;
  62502. /**
  62503. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62504. * @param scale defines the scale factor
  62505. * @param result defines the Quaternion object where to store the result
  62506. * @returns the unmodified current quaternion
  62507. */
  62508. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62509. /**
  62510. * Multiplies two quaternions
  62511. * @param q1 defines the second operand
  62512. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62513. */
  62514. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62515. /**
  62516. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62517. * @param q1 defines the second operand
  62518. * @param result defines the target quaternion
  62519. * @returns the current quaternion
  62520. */
  62521. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62522. /**
  62523. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62524. * @param q1 defines the second operand
  62525. * @returns the currentupdated quaternion
  62526. */
  62527. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62528. /**
  62529. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62530. * @param ref defines the target quaternion
  62531. * @returns the current quaternion
  62532. */
  62533. conjugateToRef(ref: Quaternion): Quaternion;
  62534. /**
  62535. * Conjugates in place (1-q) the current quaternion
  62536. * @returns the current updated quaternion
  62537. */
  62538. conjugateInPlace(): Quaternion;
  62539. /**
  62540. * Conjugates in place (1-q) the current quaternion
  62541. * @returns a new quaternion
  62542. */
  62543. conjugate(): Quaternion;
  62544. /**
  62545. * Gets length of current quaternion
  62546. * @returns the quaternion length (float)
  62547. */
  62548. length(): number;
  62549. /**
  62550. * Normalize in place the current quaternion
  62551. * @returns the current updated quaternion
  62552. */
  62553. normalize(): Quaternion;
  62554. /**
  62555. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62556. * @param order is a reserved parameter and is ignore for now
  62557. * @returns a new Vector3 containing the Euler angles
  62558. */
  62559. toEulerAngles(order?: string): Vector3;
  62560. /**
  62561. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62562. * @param result defines the vector which will be filled with the Euler angles
  62563. * @param order is a reserved parameter and is ignore for now
  62564. * @returns the current unchanged quaternion
  62565. */
  62566. toEulerAnglesToRef(result: Vector3): Quaternion;
  62567. /**
  62568. * Updates the given rotation matrix with the current quaternion values
  62569. * @param result defines the target matrix
  62570. * @returns the current unchanged quaternion
  62571. */
  62572. toRotationMatrix(result: Matrix): Quaternion;
  62573. /**
  62574. * Updates the current quaternion from the given rotation matrix values
  62575. * @param matrix defines the source matrix
  62576. * @returns the current updated quaternion
  62577. */
  62578. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62579. /**
  62580. * Creates a new quaternion from a rotation matrix
  62581. * @param matrix defines the source matrix
  62582. * @returns a new quaternion created from the given rotation matrix values
  62583. */
  62584. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62585. /**
  62586. * Updates the given quaternion with the given rotation matrix values
  62587. * @param matrix defines the source matrix
  62588. * @param result defines the target quaternion
  62589. */
  62590. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62591. /**
  62592. * Returns the dot product (float) between the quaternions "left" and "right"
  62593. * @param left defines the left operand
  62594. * @param right defines the right operand
  62595. * @returns the dot product
  62596. */
  62597. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62598. /**
  62599. * Checks if the two quaternions are close to each other
  62600. * @param quat0 defines the first quaternion to check
  62601. * @param quat1 defines the second quaternion to check
  62602. * @returns true if the two quaternions are close to each other
  62603. */
  62604. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62605. /**
  62606. * Creates an empty quaternion
  62607. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62608. */
  62609. static Zero(): Quaternion;
  62610. /**
  62611. * Inverse a given quaternion
  62612. * @param q defines the source quaternion
  62613. * @returns a new quaternion as the inverted current quaternion
  62614. */
  62615. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62616. /**
  62617. * Inverse a given quaternion
  62618. * @param q defines the source quaternion
  62619. * @param result the quaternion the result will be stored in
  62620. * @returns the result quaternion
  62621. */
  62622. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62623. /**
  62624. * Creates an identity quaternion
  62625. * @returns the identity quaternion
  62626. */
  62627. static Identity(): Quaternion;
  62628. /**
  62629. * Gets a boolean indicating if the given quaternion is identity
  62630. * @param quaternion defines the quaternion to check
  62631. * @returns true if the quaternion is identity
  62632. */
  62633. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62634. /**
  62635. * Creates a quaternion from a rotation around an axis
  62636. * @param axis defines the axis to use
  62637. * @param angle defines the angle to use
  62638. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62639. */
  62640. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62641. /**
  62642. * Creates a rotation around an axis and stores it into the given quaternion
  62643. * @param axis defines the axis to use
  62644. * @param angle defines the angle to use
  62645. * @param result defines the target quaternion
  62646. * @returns the target quaternion
  62647. */
  62648. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62649. /**
  62650. * Creates a new quaternion from data stored into an array
  62651. * @param array defines the data source
  62652. * @param offset defines the offset in the source array where the data starts
  62653. * @returns a new quaternion
  62654. */
  62655. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62656. /**
  62657. * Create a quaternion from Euler rotation angles
  62658. * @param x Pitch
  62659. * @param y Yaw
  62660. * @param z Roll
  62661. * @returns the new Quaternion
  62662. */
  62663. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62664. /**
  62665. * Updates a quaternion from Euler rotation angles
  62666. * @param x Pitch
  62667. * @param y Yaw
  62668. * @param z Roll
  62669. * @param result the quaternion to store the result
  62670. * @returns the updated quaternion
  62671. */
  62672. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62673. /**
  62674. * Create a quaternion from Euler rotation vector
  62675. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62676. * @returns the new Quaternion
  62677. */
  62678. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62679. /**
  62680. * Updates a quaternion from Euler rotation vector
  62681. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62682. * @param result the quaternion to store the result
  62683. * @returns the updated quaternion
  62684. */
  62685. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62686. /**
  62687. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62688. * @param yaw defines the rotation around Y axis
  62689. * @param pitch defines the rotation around X axis
  62690. * @param roll defines the rotation around Z axis
  62691. * @returns the new quaternion
  62692. */
  62693. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62694. /**
  62695. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62696. * @param yaw defines the rotation around Y axis
  62697. * @param pitch defines the rotation around X axis
  62698. * @param roll defines the rotation around Z axis
  62699. * @param result defines the target quaternion
  62700. */
  62701. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62702. /**
  62703. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62704. * @param alpha defines the rotation around first axis
  62705. * @param beta defines the rotation around second axis
  62706. * @param gamma defines the rotation around third axis
  62707. * @returns the new quaternion
  62708. */
  62709. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62710. /**
  62711. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62712. * @param alpha defines the rotation around first axis
  62713. * @param beta defines the rotation around second axis
  62714. * @param gamma defines the rotation around third axis
  62715. * @param result defines the target quaternion
  62716. */
  62717. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62718. /**
  62719. * 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)
  62720. * @param axis1 defines the first axis
  62721. * @param axis2 defines the second axis
  62722. * @param axis3 defines the third axis
  62723. * @returns the new quaternion
  62724. */
  62725. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62726. /**
  62727. * 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
  62728. * @param axis1 defines the first axis
  62729. * @param axis2 defines the second axis
  62730. * @param axis3 defines the third axis
  62731. * @param ref defines the target quaternion
  62732. */
  62733. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62734. /**
  62735. * Interpolates between two quaternions
  62736. * @param left defines first quaternion
  62737. * @param right defines second quaternion
  62738. * @param amount defines the gradient to use
  62739. * @returns the new interpolated quaternion
  62740. */
  62741. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62742. /**
  62743. * Interpolates between two quaternions and stores it into a target quaternion
  62744. * @param left defines first quaternion
  62745. * @param right defines second quaternion
  62746. * @param amount defines the gradient to use
  62747. * @param result defines the target quaternion
  62748. */
  62749. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62750. /**
  62751. * Interpolate between two quaternions using Hermite interpolation
  62752. * @param value1 defines first quaternion
  62753. * @param tangent1 defines the incoming tangent
  62754. * @param value2 defines second quaternion
  62755. * @param tangent2 defines the outgoing tangent
  62756. * @param amount defines the target quaternion
  62757. * @returns the new interpolated quaternion
  62758. */
  62759. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62760. }
  62761. /**
  62762. * Class used to store matrix data (4x4)
  62763. */
  62764. export class Matrix {
  62765. private static _updateFlagSeed;
  62766. private static _identityReadOnly;
  62767. private _isIdentity;
  62768. private _isIdentityDirty;
  62769. private _isIdentity3x2;
  62770. private _isIdentity3x2Dirty;
  62771. /**
  62772. * Gets the update flag of the matrix which is an unique number for the matrix.
  62773. * It will be incremented every time the matrix data change.
  62774. * You can use it to speed the comparison between two versions of the same matrix.
  62775. */
  62776. updateFlag: number;
  62777. private readonly _m;
  62778. /**
  62779. * Gets the internal data of the matrix
  62780. */
  62781. readonly m: DeepImmutable<Float32Array>;
  62782. /** @hidden */
  62783. _markAsUpdated(): void;
  62784. /** @hidden */
  62785. private _updateIdentityStatus;
  62786. /**
  62787. * Creates an empty matrix (filled with zeros)
  62788. */
  62789. constructor();
  62790. /**
  62791. * Check if the current matrix is identity
  62792. * @returns true is the matrix is the identity matrix
  62793. */
  62794. isIdentity(): boolean;
  62795. /**
  62796. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62797. * @returns true is the matrix is the identity matrix
  62798. */
  62799. isIdentityAs3x2(): boolean;
  62800. /**
  62801. * Gets the determinant of the matrix
  62802. * @returns the matrix determinant
  62803. */
  62804. determinant(): number;
  62805. /**
  62806. * Returns the matrix as a Float32Array
  62807. * @returns the matrix underlying array
  62808. */
  62809. toArray(): DeepImmutable<Float32Array>;
  62810. /**
  62811. * Returns the matrix as a Float32Array
  62812. * @returns the matrix underlying array.
  62813. */
  62814. asArray(): DeepImmutable<Float32Array>;
  62815. /**
  62816. * Inverts the current matrix in place
  62817. * @returns the current inverted matrix
  62818. */
  62819. invert(): Matrix;
  62820. /**
  62821. * Sets all the matrix elements to zero
  62822. * @returns the current matrix
  62823. */
  62824. reset(): Matrix;
  62825. /**
  62826. * Adds the current matrix with a second one
  62827. * @param other defines the matrix to add
  62828. * @returns a new matrix as the addition of the current matrix and the given one
  62829. */
  62830. add(other: DeepImmutable<Matrix>): Matrix;
  62831. /**
  62832. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62833. * @param other defines the matrix to add
  62834. * @param result defines the target matrix
  62835. * @returns the current matrix
  62836. */
  62837. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62838. /**
  62839. * Adds in place the given matrix to the current matrix
  62840. * @param other defines the second operand
  62841. * @returns the current updated matrix
  62842. */
  62843. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62844. /**
  62845. * Sets the given matrix to the current inverted Matrix
  62846. * @param other defines the target matrix
  62847. * @returns the unmodified current matrix
  62848. */
  62849. invertToRef(other: Matrix): Matrix;
  62850. /**
  62851. * add a value at the specified position in the current Matrix
  62852. * @param index the index of the value within the matrix. between 0 and 15.
  62853. * @param value the value to be added
  62854. * @returns the current updated matrix
  62855. */
  62856. addAtIndex(index: number, value: number): Matrix;
  62857. /**
  62858. * mutiply the specified position in the current Matrix by a value
  62859. * @param index the index of the value within the matrix. between 0 and 15.
  62860. * @param value the value to be added
  62861. * @returns the current updated matrix
  62862. */
  62863. multiplyAtIndex(index: number, value: number): Matrix;
  62864. /**
  62865. * Inserts the translation vector (using 3 floats) in the current matrix
  62866. * @param x defines the 1st component of the translation
  62867. * @param y defines the 2nd component of the translation
  62868. * @param z defines the 3rd component of the translation
  62869. * @returns the current updated matrix
  62870. */
  62871. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62872. /**
  62873. * Adds the translation vector (using 3 floats) in the current matrix
  62874. * @param x defines the 1st component of the translation
  62875. * @param y defines the 2nd component of the translation
  62876. * @param z defines the 3rd component of the translation
  62877. * @returns the current updated matrix
  62878. */
  62879. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62880. /**
  62881. * Inserts the translation vector in the current matrix
  62882. * @param vector3 defines the translation to insert
  62883. * @returns the current updated matrix
  62884. */
  62885. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62886. /**
  62887. * Gets the translation value of the current matrix
  62888. * @returns a new Vector3 as the extracted translation from the matrix
  62889. */
  62890. getTranslation(): Vector3;
  62891. /**
  62892. * Fill a Vector3 with the extracted translation from the matrix
  62893. * @param result defines the Vector3 where to store the translation
  62894. * @returns the current matrix
  62895. */
  62896. getTranslationToRef(result: Vector3): Matrix;
  62897. /**
  62898. * Remove rotation and scaling part from the matrix
  62899. * @returns the updated matrix
  62900. */
  62901. removeRotationAndScaling(): Matrix;
  62902. /**
  62903. * Multiply two matrices
  62904. * @param other defines the second operand
  62905. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62906. */
  62907. multiply(other: DeepImmutable<Matrix>): Matrix;
  62908. /**
  62909. * Copy the current matrix from the given one
  62910. * @param other defines the source matrix
  62911. * @returns the current updated matrix
  62912. */
  62913. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62914. /**
  62915. * Populates the given array from the starting index with the current matrix values
  62916. * @param array defines the target array
  62917. * @param offset defines the offset in the target array where to start storing values
  62918. * @returns the current matrix
  62919. */
  62920. copyToArray(array: Float32Array, offset?: number): Matrix;
  62921. /**
  62922. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62923. * @param other defines the second operand
  62924. * @param result defines the matrix where to store the multiplication
  62925. * @returns the current matrix
  62926. */
  62927. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62928. /**
  62929. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62930. * @param other defines the second operand
  62931. * @param result defines the array where to store the multiplication
  62932. * @param offset defines the offset in the target array where to start storing values
  62933. * @returns the current matrix
  62934. */
  62935. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62936. /**
  62937. * Check equality between this matrix and a second one
  62938. * @param value defines the second matrix to compare
  62939. * @returns true is the current matrix and the given one values are strictly equal
  62940. */
  62941. equals(value: DeepImmutable<Matrix>): boolean;
  62942. /**
  62943. * Clone the current matrix
  62944. * @returns a new matrix from the current matrix
  62945. */
  62946. clone(): Matrix;
  62947. /**
  62948. * Returns the name of the current matrix class
  62949. * @returns the string "Matrix"
  62950. */
  62951. getClassName(): string;
  62952. /**
  62953. * Gets the hash code of the current matrix
  62954. * @returns the hash code
  62955. */
  62956. getHashCode(): number;
  62957. /**
  62958. * Decomposes the current Matrix into a translation, rotation and scaling components
  62959. * @param scale defines the scale vector3 given as a reference to update
  62960. * @param rotation defines the rotation quaternion given as a reference to update
  62961. * @param translation defines the translation vector3 given as a reference to update
  62962. * @returns true if operation was successful
  62963. */
  62964. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62965. /**
  62966. * Gets specific row of the matrix
  62967. * @param index defines the number of the row to get
  62968. * @returns the index-th row of the current matrix as a new Vector4
  62969. */
  62970. getRow(index: number): Nullable<Vector4>;
  62971. /**
  62972. * Sets the index-th row of the current matrix to the vector4 values
  62973. * @param index defines the number of the row to set
  62974. * @param row defines the target vector4
  62975. * @returns the updated current matrix
  62976. */
  62977. setRow(index: number, row: Vector4): Matrix;
  62978. /**
  62979. * Compute the transpose of the matrix
  62980. * @returns the new transposed matrix
  62981. */
  62982. transpose(): Matrix;
  62983. /**
  62984. * Compute the transpose of the matrix and store it in a given matrix
  62985. * @param result defines the target matrix
  62986. * @returns the current matrix
  62987. */
  62988. transposeToRef(result: Matrix): Matrix;
  62989. /**
  62990. * Sets the index-th row of the current matrix with the given 4 x float values
  62991. * @param index defines the row index
  62992. * @param x defines the x component to set
  62993. * @param y defines the y component to set
  62994. * @param z defines the z component to set
  62995. * @param w defines the w component to set
  62996. * @returns the updated current matrix
  62997. */
  62998. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62999. /**
  63000. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  63001. * @param scale defines the scale factor
  63002. * @returns a new matrix
  63003. */
  63004. scale(scale: number): Matrix;
  63005. /**
  63006. * Scale the current matrix values by a factor to a given result matrix
  63007. * @param scale defines the scale factor
  63008. * @param result defines the matrix to store the result
  63009. * @returns the current matrix
  63010. */
  63011. scaleToRef(scale: number, result: Matrix): Matrix;
  63012. /**
  63013. * Scale the current matrix values by a factor and add the result to a given matrix
  63014. * @param scale defines the scale factor
  63015. * @param result defines the Matrix to store the result
  63016. * @returns the current matrix
  63017. */
  63018. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  63019. /**
  63020. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  63021. * @param ref matrix to store the result
  63022. */
  63023. toNormalMatrix(ref: Matrix): void;
  63024. /**
  63025. * Gets only rotation part of the current matrix
  63026. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63027. */
  63028. getRotationMatrix(): Matrix;
  63029. /**
  63030. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63031. * @param result defines the target matrix to store data to
  63032. * @returns the current matrix
  63033. */
  63034. getRotationMatrixToRef(result: Matrix): Matrix;
  63035. /**
  63036. * Toggles model matrix from being right handed to left handed in place and vice versa
  63037. */
  63038. toggleModelMatrixHandInPlace(): void;
  63039. /**
  63040. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63041. */
  63042. toggleProjectionMatrixHandInPlace(): void;
  63043. /**
  63044. * Creates a matrix from an array
  63045. * @param array defines the source array
  63046. * @param offset defines an offset in the source array
  63047. * @returns a new Matrix set from the starting index of the given array
  63048. */
  63049. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63050. /**
  63051. * Copy the content of an array into a given matrix
  63052. * @param array defines the source array
  63053. * @param offset defines an offset in the source array
  63054. * @param result defines the target matrix
  63055. */
  63056. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63057. /**
  63058. * Stores an array into a matrix after having multiplied each component by a given factor
  63059. * @param array defines the source array
  63060. * @param offset defines the offset in the source array
  63061. * @param scale defines the scaling factor
  63062. * @param result defines the target matrix
  63063. */
  63064. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63065. /**
  63066. * Gets an identity matrix that must not be updated
  63067. */
  63068. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63069. /**
  63070. * Stores a list of values (16) inside a given matrix
  63071. * @param initialM11 defines 1st value of 1st row
  63072. * @param initialM12 defines 2nd value of 1st row
  63073. * @param initialM13 defines 3rd value of 1st row
  63074. * @param initialM14 defines 4th value of 1st row
  63075. * @param initialM21 defines 1st value of 2nd row
  63076. * @param initialM22 defines 2nd value of 2nd row
  63077. * @param initialM23 defines 3rd value of 2nd row
  63078. * @param initialM24 defines 4th value of 2nd row
  63079. * @param initialM31 defines 1st value of 3rd row
  63080. * @param initialM32 defines 2nd value of 3rd row
  63081. * @param initialM33 defines 3rd value of 3rd row
  63082. * @param initialM34 defines 4th value of 3rd row
  63083. * @param initialM41 defines 1st value of 4th row
  63084. * @param initialM42 defines 2nd value of 4th row
  63085. * @param initialM43 defines 3rd value of 4th row
  63086. * @param initialM44 defines 4th value of 4th row
  63087. * @param result defines the target matrix
  63088. */
  63089. 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;
  63090. /**
  63091. * Creates new matrix from a list of values (16)
  63092. * @param initialM11 defines 1st value of 1st row
  63093. * @param initialM12 defines 2nd value of 1st row
  63094. * @param initialM13 defines 3rd value of 1st row
  63095. * @param initialM14 defines 4th value of 1st row
  63096. * @param initialM21 defines 1st value of 2nd row
  63097. * @param initialM22 defines 2nd value of 2nd row
  63098. * @param initialM23 defines 3rd value of 2nd row
  63099. * @param initialM24 defines 4th value of 2nd row
  63100. * @param initialM31 defines 1st value of 3rd row
  63101. * @param initialM32 defines 2nd value of 3rd row
  63102. * @param initialM33 defines 3rd value of 3rd row
  63103. * @param initialM34 defines 4th value of 3rd row
  63104. * @param initialM41 defines 1st value of 4th row
  63105. * @param initialM42 defines 2nd value of 4th row
  63106. * @param initialM43 defines 3rd value of 4th row
  63107. * @param initialM44 defines 4th value of 4th row
  63108. * @returns the new matrix
  63109. */
  63110. 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;
  63111. /**
  63112. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63113. * @param scale defines the scale vector3
  63114. * @param rotation defines the rotation quaternion
  63115. * @param translation defines the translation vector3
  63116. * @returns a new matrix
  63117. */
  63118. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63119. /**
  63120. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63121. * @param scale defines the scale vector3
  63122. * @param rotation defines the rotation quaternion
  63123. * @param translation defines the translation vector3
  63124. * @param result defines the target matrix
  63125. */
  63126. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63127. /**
  63128. * Creates a new identity matrix
  63129. * @returns a new identity matrix
  63130. */
  63131. static Identity(): Matrix;
  63132. /**
  63133. * Creates a new identity matrix and stores the result in a given matrix
  63134. * @param result defines the target matrix
  63135. */
  63136. static IdentityToRef(result: Matrix): void;
  63137. /**
  63138. * Creates a new zero matrix
  63139. * @returns a new zero matrix
  63140. */
  63141. static Zero(): Matrix;
  63142. /**
  63143. * Creates a new rotation matrix for "angle" radians around the X axis
  63144. * @param angle defines the angle (in radians) to use
  63145. * @return the new matrix
  63146. */
  63147. static RotationX(angle: number): Matrix;
  63148. /**
  63149. * Creates a new matrix as the invert of a given matrix
  63150. * @param source defines the source matrix
  63151. * @returns the new matrix
  63152. */
  63153. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63154. /**
  63155. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63156. * @param angle defines the angle (in radians) to use
  63157. * @param result defines the target matrix
  63158. */
  63159. static RotationXToRef(angle: number, result: Matrix): void;
  63160. /**
  63161. * Creates a new rotation matrix for "angle" radians around the Y axis
  63162. * @param angle defines the angle (in radians) to use
  63163. * @return the new matrix
  63164. */
  63165. static RotationY(angle: number): Matrix;
  63166. /**
  63167. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63168. * @param angle defines the angle (in radians) to use
  63169. * @param result defines the target matrix
  63170. */
  63171. static RotationYToRef(angle: number, result: Matrix): void;
  63172. /**
  63173. * Creates a new rotation matrix for "angle" radians around the Z axis
  63174. * @param angle defines the angle (in radians) to use
  63175. * @return the new matrix
  63176. */
  63177. static RotationZ(angle: number): Matrix;
  63178. /**
  63179. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63180. * @param angle defines the angle (in radians) to use
  63181. * @param result defines the target matrix
  63182. */
  63183. static RotationZToRef(angle: number, result: Matrix): void;
  63184. /**
  63185. * Creates a new rotation matrix for "angle" radians around the given axis
  63186. * @param axis defines the axis to use
  63187. * @param angle defines the angle (in radians) to use
  63188. * @return the new matrix
  63189. */
  63190. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63191. /**
  63192. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63193. * @param axis defines the axis to use
  63194. * @param angle defines the angle (in radians) to use
  63195. * @param result defines the target matrix
  63196. */
  63197. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63198. /**
  63199. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63200. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63201. * @param from defines the vector to align
  63202. * @param to defines the vector to align to
  63203. * @param result defines the target matrix
  63204. */
  63205. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63206. /**
  63207. * Creates a rotation matrix
  63208. * @param yaw defines the yaw angle in radians (Y axis)
  63209. * @param pitch defines the pitch angle in radians (X axis)
  63210. * @param roll defines the roll angle in radians (X axis)
  63211. * @returns the new rotation matrix
  63212. */
  63213. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63214. /**
  63215. * Creates a rotation matrix and stores it in a given matrix
  63216. * @param yaw defines the yaw angle in radians (Y axis)
  63217. * @param pitch defines the pitch angle in radians (X axis)
  63218. * @param roll defines the roll angle in radians (X axis)
  63219. * @param result defines the target matrix
  63220. */
  63221. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63222. /**
  63223. * Creates a scaling matrix
  63224. * @param x defines the scale factor on X axis
  63225. * @param y defines the scale factor on Y axis
  63226. * @param z defines the scale factor on Z axis
  63227. * @returns the new matrix
  63228. */
  63229. static Scaling(x: number, y: number, z: number): Matrix;
  63230. /**
  63231. * Creates a scaling matrix and stores it in a given matrix
  63232. * @param x defines the scale factor on X axis
  63233. * @param y defines the scale factor on Y axis
  63234. * @param z defines the scale factor on Z axis
  63235. * @param result defines the target matrix
  63236. */
  63237. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63238. /**
  63239. * Creates a translation matrix
  63240. * @param x defines the translation on X axis
  63241. * @param y defines the translation on Y axis
  63242. * @param z defines the translationon Z axis
  63243. * @returns the new matrix
  63244. */
  63245. static Translation(x: number, y: number, z: number): Matrix;
  63246. /**
  63247. * Creates a translation matrix and stores it in a given matrix
  63248. * @param x defines the translation on X axis
  63249. * @param y defines the translation on Y axis
  63250. * @param z defines the translationon Z axis
  63251. * @param result defines the target matrix
  63252. */
  63253. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63254. /**
  63255. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63256. * @param startValue defines the start value
  63257. * @param endValue defines the end value
  63258. * @param gradient defines the gradient factor
  63259. * @returns the new matrix
  63260. */
  63261. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63262. /**
  63263. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63264. * @param startValue defines the start value
  63265. * @param endValue defines the end value
  63266. * @param gradient defines the gradient factor
  63267. * @param result defines the Matrix object where to store data
  63268. */
  63269. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63270. /**
  63271. * Builds a new matrix whose values are computed by:
  63272. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63273. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63274. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63275. * @param startValue defines the first matrix
  63276. * @param endValue defines the second matrix
  63277. * @param gradient defines the gradient between the two matrices
  63278. * @returns the new matrix
  63279. */
  63280. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63281. /**
  63282. * Update a matrix to values which are computed by:
  63283. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63284. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63285. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63286. * @param startValue defines the first matrix
  63287. * @param endValue defines the second matrix
  63288. * @param gradient defines the gradient between the two matrices
  63289. * @param result defines the target matrix
  63290. */
  63291. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63292. /**
  63293. * 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"
  63294. * This function works in left handed mode
  63295. * @param eye defines the final position of the entity
  63296. * @param target defines where the entity should look at
  63297. * @param up defines the up vector for the entity
  63298. * @returns the new matrix
  63299. */
  63300. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63301. /**
  63302. * 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".
  63303. * This function works in left handed mode
  63304. * @param eye defines the final position of the entity
  63305. * @param target defines where the entity should look at
  63306. * @param up defines the up vector for the entity
  63307. * @param result defines the target matrix
  63308. */
  63309. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63310. /**
  63311. * 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"
  63312. * This function works in right handed mode
  63313. * @param eye defines the final position of the entity
  63314. * @param target defines where the entity should look at
  63315. * @param up defines the up vector for the entity
  63316. * @returns the new matrix
  63317. */
  63318. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63319. /**
  63320. * 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".
  63321. * This function works in right handed mode
  63322. * @param eye defines the final position of the entity
  63323. * @param target defines where the entity should look at
  63324. * @param up defines the up vector for the entity
  63325. * @param result defines the target matrix
  63326. */
  63327. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63328. /**
  63329. * Create a left-handed orthographic projection matrix
  63330. * @param width defines the viewport width
  63331. * @param height defines the viewport height
  63332. * @param znear defines the near clip plane
  63333. * @param zfar defines the far clip plane
  63334. * @returns a new matrix as a left-handed orthographic projection matrix
  63335. */
  63336. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63337. /**
  63338. * Store a left-handed orthographic projection to a given matrix
  63339. * @param width defines the viewport width
  63340. * @param height defines the viewport height
  63341. * @param znear defines the near clip plane
  63342. * @param zfar defines the far clip plane
  63343. * @param result defines the target matrix
  63344. */
  63345. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63346. /**
  63347. * Create a left-handed orthographic projection matrix
  63348. * @param left defines the viewport left coordinate
  63349. * @param right defines the viewport right coordinate
  63350. * @param bottom defines the viewport bottom coordinate
  63351. * @param top defines the viewport top coordinate
  63352. * @param znear defines the near clip plane
  63353. * @param zfar defines the far clip plane
  63354. * @returns a new matrix as a left-handed orthographic projection matrix
  63355. */
  63356. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63357. /**
  63358. * Stores a left-handed orthographic projection into a given matrix
  63359. * @param left defines the viewport left coordinate
  63360. * @param right defines the viewport right coordinate
  63361. * @param bottom defines the viewport bottom coordinate
  63362. * @param top defines the viewport top coordinate
  63363. * @param znear defines the near clip plane
  63364. * @param zfar defines the far clip plane
  63365. * @param result defines the target matrix
  63366. */
  63367. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63368. /**
  63369. * Creates a right-handed orthographic projection matrix
  63370. * @param left defines the viewport left coordinate
  63371. * @param right defines the viewport right coordinate
  63372. * @param bottom defines the viewport bottom coordinate
  63373. * @param top defines the viewport top coordinate
  63374. * @param znear defines the near clip plane
  63375. * @param zfar defines the far clip plane
  63376. * @returns a new matrix as a right-handed orthographic projection matrix
  63377. */
  63378. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63379. /**
  63380. * Stores a right-handed orthographic projection into a given matrix
  63381. * @param left defines the viewport left coordinate
  63382. * @param right defines the viewport right coordinate
  63383. * @param bottom defines the viewport bottom coordinate
  63384. * @param top defines the viewport top coordinate
  63385. * @param znear defines the near clip plane
  63386. * @param zfar defines the far clip plane
  63387. * @param result defines the target matrix
  63388. */
  63389. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63390. /**
  63391. * Creates a left-handed perspective projection matrix
  63392. * @param width defines the viewport width
  63393. * @param height defines the viewport height
  63394. * @param znear defines the near clip plane
  63395. * @param zfar defines the far clip plane
  63396. * @returns a new matrix as a left-handed perspective projection matrix
  63397. */
  63398. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63399. /**
  63400. * Creates a left-handed perspective projection matrix
  63401. * @param fov defines the horizontal field of view
  63402. * @param aspect defines the aspect ratio
  63403. * @param znear defines the near clip plane
  63404. * @param zfar defines the far clip plane
  63405. * @returns a new matrix as a left-handed perspective projection matrix
  63406. */
  63407. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63408. /**
  63409. * Stores a left-handed perspective projection into a given matrix
  63410. * @param fov defines the horizontal field of view
  63411. * @param aspect defines the aspect ratio
  63412. * @param znear defines the near clip plane
  63413. * @param zfar defines the far clip plane
  63414. * @param result defines the target matrix
  63415. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63416. */
  63417. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63418. /**
  63419. * Creates a right-handed perspective projection matrix
  63420. * @param fov defines the horizontal field of view
  63421. * @param aspect defines the aspect ratio
  63422. * @param znear defines the near clip plane
  63423. * @param zfar defines the far clip plane
  63424. * @returns a new matrix as a right-handed perspective projection matrix
  63425. */
  63426. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63427. /**
  63428. * Stores a right-handed perspective projection into a given matrix
  63429. * @param fov defines the horizontal field of view
  63430. * @param aspect defines the aspect ratio
  63431. * @param znear defines the near clip plane
  63432. * @param zfar defines the far clip plane
  63433. * @param result defines the target matrix
  63434. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63435. */
  63436. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63437. /**
  63438. * Stores a perspective projection for WebVR info a given matrix
  63439. * @param fov defines the field of view
  63440. * @param znear defines the near clip plane
  63441. * @param zfar defines the far clip plane
  63442. * @param result defines the target matrix
  63443. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63444. */
  63445. static PerspectiveFovWebVRToRef(fov: {
  63446. upDegrees: number;
  63447. downDegrees: number;
  63448. leftDegrees: number;
  63449. rightDegrees: number;
  63450. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63451. /**
  63452. * Computes a complete transformation matrix
  63453. * @param viewport defines the viewport to use
  63454. * @param world defines the world matrix
  63455. * @param view defines the view matrix
  63456. * @param projection defines the projection matrix
  63457. * @param zmin defines the near clip plane
  63458. * @param zmax defines the far clip plane
  63459. * @returns the transformation matrix
  63460. */
  63461. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63462. /**
  63463. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63464. * @param matrix defines the matrix to use
  63465. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63466. */
  63467. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63468. /**
  63469. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63470. * @param matrix defines the matrix to use
  63471. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63472. */
  63473. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63474. /**
  63475. * Compute the transpose of a given matrix
  63476. * @param matrix defines the matrix to transpose
  63477. * @returns the new matrix
  63478. */
  63479. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63480. /**
  63481. * Compute the transpose of a matrix and store it in a target matrix
  63482. * @param matrix defines the matrix to transpose
  63483. * @param result defines the target matrix
  63484. */
  63485. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63486. /**
  63487. * Computes a reflection matrix from a plane
  63488. * @param plane defines the reflection plane
  63489. * @returns a new matrix
  63490. */
  63491. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63492. /**
  63493. * Computes a reflection matrix from a plane
  63494. * @param plane defines the reflection plane
  63495. * @param result defines the target matrix
  63496. */
  63497. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63498. /**
  63499. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63500. * @param xaxis defines the value of the 1st axis
  63501. * @param yaxis defines the value of the 2nd axis
  63502. * @param zaxis defines the value of the 3rd axis
  63503. * @param result defines the target matrix
  63504. */
  63505. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63506. /**
  63507. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63508. * @param quat defines the quaternion to use
  63509. * @param result defines the target matrix
  63510. */
  63511. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63512. }
  63513. /**
  63514. * Represens a plane by the equation ax + by + cz + d = 0
  63515. */
  63516. export class Plane {
  63517. /**
  63518. * Normal of the plane (a,b,c)
  63519. */
  63520. normal: Vector3;
  63521. /**
  63522. * d component of the plane
  63523. */
  63524. d: number;
  63525. /**
  63526. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63527. * @param a a component of the plane
  63528. * @param b b component of the plane
  63529. * @param c c component of the plane
  63530. * @param d d component of the plane
  63531. */
  63532. constructor(a: number, b: number, c: number, d: number);
  63533. /**
  63534. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63535. */
  63536. asArray(): number[];
  63537. /**
  63538. * @returns a new plane copied from the current Plane.
  63539. */
  63540. clone(): Plane;
  63541. /**
  63542. * @returns the string "Plane".
  63543. */
  63544. getClassName(): string;
  63545. /**
  63546. * @returns the Plane hash code.
  63547. */
  63548. getHashCode(): number;
  63549. /**
  63550. * Normalize the current Plane in place.
  63551. * @returns the updated Plane.
  63552. */
  63553. normalize(): Plane;
  63554. /**
  63555. * Applies a transformation the plane and returns the result
  63556. * @param transformation the transformation matrix to be applied to the plane
  63557. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63558. */
  63559. transform(transformation: DeepImmutable<Matrix>): Plane;
  63560. /**
  63561. * Calcualtte the dot product between the point and the plane normal
  63562. * @param point point to calculate the dot product with
  63563. * @returns the dot product (float) of the point coordinates and the plane normal.
  63564. */
  63565. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63566. /**
  63567. * Updates the current Plane from the plane defined by the three given points.
  63568. * @param point1 one of the points used to contruct the plane
  63569. * @param point2 one of the points used to contruct the plane
  63570. * @param point3 one of the points used to contruct the plane
  63571. * @returns the updated Plane.
  63572. */
  63573. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63574. /**
  63575. * Checks if the plane is facing a given direction
  63576. * @param direction the direction to check if the plane is facing
  63577. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63578. * @returns True is the vector "direction" is the same side than the plane normal.
  63579. */
  63580. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63581. /**
  63582. * Calculates the distance to a point
  63583. * @param point point to calculate distance to
  63584. * @returns the signed distance (float) from the given point to the Plane.
  63585. */
  63586. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63587. /**
  63588. * Creates a plane from an array
  63589. * @param array the array to create a plane from
  63590. * @returns a new Plane from the given array.
  63591. */
  63592. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63593. /**
  63594. * Creates a plane from three points
  63595. * @param point1 point used to create the plane
  63596. * @param point2 point used to create the plane
  63597. * @param point3 point used to create the plane
  63598. * @returns a new Plane defined by the three given points.
  63599. */
  63600. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63601. /**
  63602. * Creates a plane from an origin point and a normal
  63603. * @param origin origin of the plane to be constructed
  63604. * @param normal normal of the plane to be constructed
  63605. * @returns a new Plane the normal vector to this plane at the given origin point.
  63606. * Note : the vector "normal" is updated because normalized.
  63607. */
  63608. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63609. /**
  63610. * Calculates the distance from a plane and a point
  63611. * @param origin origin of the plane to be constructed
  63612. * @param normal normal of the plane to be constructed
  63613. * @param point point to calculate distance to
  63614. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63615. */
  63616. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63617. }
  63618. /**
  63619. * Class used to represent a viewport on screen
  63620. */
  63621. export class Viewport {
  63622. /** viewport left coordinate */
  63623. x: number;
  63624. /** viewport top coordinate */
  63625. y: number;
  63626. /**viewport width */
  63627. width: number;
  63628. /** viewport height */
  63629. height: number;
  63630. /**
  63631. * Creates a Viewport object located at (x, y) and sized (width, height)
  63632. * @param x defines viewport left coordinate
  63633. * @param y defines viewport top coordinate
  63634. * @param width defines the viewport width
  63635. * @param height defines the viewport height
  63636. */
  63637. constructor(
  63638. /** viewport left coordinate */
  63639. x: number,
  63640. /** viewport top coordinate */
  63641. y: number,
  63642. /**viewport width */
  63643. width: number,
  63644. /** viewport height */
  63645. height: number);
  63646. /**
  63647. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63648. * @param renderWidth defines the rendering width
  63649. * @param renderHeight defines the rendering height
  63650. * @returns a new Viewport
  63651. */
  63652. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63653. /**
  63654. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63655. * @param renderWidth defines the rendering width
  63656. * @param renderHeight defines the rendering height
  63657. * @param ref defines the target viewport
  63658. * @returns the current viewport
  63659. */
  63660. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63661. /**
  63662. * Returns a new Viewport copied from the current one
  63663. * @returns a new Viewport
  63664. */
  63665. clone(): Viewport;
  63666. }
  63667. /**
  63668. * Reprasents a camera frustum
  63669. */
  63670. export class Frustum {
  63671. /**
  63672. * Gets the planes representing the frustum
  63673. * @param transform matrix to be applied to the returned planes
  63674. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63675. */
  63676. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63677. /**
  63678. * Gets the near frustum plane transformed by the transform matrix
  63679. * @param transform transformation matrix to be applied to the resulting frustum plane
  63680. * @param frustumPlane the resuling frustum plane
  63681. */
  63682. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63683. /**
  63684. * Gets the far frustum plane transformed by the transform matrix
  63685. * @param transform transformation matrix to be applied to the resulting frustum plane
  63686. * @param frustumPlane the resuling frustum plane
  63687. */
  63688. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63689. /**
  63690. * Gets the left frustum plane transformed by the transform matrix
  63691. * @param transform transformation matrix to be applied to the resulting frustum plane
  63692. * @param frustumPlane the resuling frustum plane
  63693. */
  63694. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63695. /**
  63696. * Gets the right frustum plane transformed by the transform matrix
  63697. * @param transform transformation matrix to be applied to the resulting frustum plane
  63698. * @param frustumPlane the resuling frustum plane
  63699. */
  63700. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63701. /**
  63702. * Gets the top frustum plane transformed by the transform matrix
  63703. * @param transform transformation matrix to be applied to the resulting frustum plane
  63704. * @param frustumPlane the resuling frustum plane
  63705. */
  63706. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63707. /**
  63708. * Gets the bottom frustum plane transformed by the transform matrix
  63709. * @param transform transformation matrix to be applied to the resulting frustum plane
  63710. * @param frustumPlane the resuling frustum plane
  63711. */
  63712. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63713. /**
  63714. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63715. * @param transform transformation matrix to be applied to the resulting frustum planes
  63716. * @param frustumPlanes the resuling frustum planes
  63717. */
  63718. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63719. }
  63720. /** Defines supported spaces */
  63721. export enum Space {
  63722. /** Local (object) space */
  63723. LOCAL = 0,
  63724. /** World space */
  63725. WORLD = 1,
  63726. /** Bone space */
  63727. BONE = 2
  63728. }
  63729. /** Defines the 3 main axes */
  63730. export class Axis {
  63731. /** X axis */
  63732. static X: Vector3;
  63733. /** Y axis */
  63734. static Y: Vector3;
  63735. /** Z axis */
  63736. static Z: Vector3;
  63737. }
  63738. /** Class used to represent a Bezier curve */
  63739. export class BezierCurve {
  63740. /**
  63741. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63742. * @param t defines the time
  63743. * @param x1 defines the left coordinate on X axis
  63744. * @param y1 defines the left coordinate on Y axis
  63745. * @param x2 defines the right coordinate on X axis
  63746. * @param y2 defines the right coordinate on Y axis
  63747. * @returns the interpolated value
  63748. */
  63749. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63750. }
  63751. /**
  63752. * Defines potential orientation for back face culling
  63753. */
  63754. export enum Orientation {
  63755. /**
  63756. * Clockwise
  63757. */
  63758. CW = 0,
  63759. /** Counter clockwise */
  63760. CCW = 1
  63761. }
  63762. /**
  63763. * Defines angle representation
  63764. */
  63765. export class Angle {
  63766. private _radians;
  63767. /**
  63768. * Creates an Angle object of "radians" radians (float).
  63769. * @param radians the angle in radians
  63770. */
  63771. constructor(radians: number);
  63772. /**
  63773. * Get value in degrees
  63774. * @returns the Angle value in degrees (float)
  63775. */
  63776. degrees(): number;
  63777. /**
  63778. * Get value in radians
  63779. * @returns the Angle value in radians (float)
  63780. */
  63781. radians(): number;
  63782. /**
  63783. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63784. * @param a defines first vector
  63785. * @param b defines second vector
  63786. * @returns a new Angle
  63787. */
  63788. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63789. /**
  63790. * Gets a new Angle object from the given float in radians
  63791. * @param radians defines the angle value in radians
  63792. * @returns a new Angle
  63793. */
  63794. static FromRadians(radians: number): Angle;
  63795. /**
  63796. * Gets a new Angle object from the given float in degrees
  63797. * @param degrees defines the angle value in degrees
  63798. * @returns a new Angle
  63799. */
  63800. static FromDegrees(degrees: number): Angle;
  63801. }
  63802. /**
  63803. * This represents an arc in a 2d space.
  63804. */
  63805. export class Arc2 {
  63806. /** Defines the start point of the arc */
  63807. startPoint: Vector2;
  63808. /** Defines the mid point of the arc */
  63809. midPoint: Vector2;
  63810. /** Defines the end point of the arc */
  63811. endPoint: Vector2;
  63812. /**
  63813. * Defines the center point of the arc.
  63814. */
  63815. centerPoint: Vector2;
  63816. /**
  63817. * Defines the radius of the arc.
  63818. */
  63819. radius: number;
  63820. /**
  63821. * Defines the angle of the arc (from mid point to end point).
  63822. */
  63823. angle: Angle;
  63824. /**
  63825. * Defines the start angle of the arc (from start point to middle point).
  63826. */
  63827. startAngle: Angle;
  63828. /**
  63829. * Defines the orientation of the arc (clock wise/counter clock wise).
  63830. */
  63831. orientation: Orientation;
  63832. /**
  63833. * Creates an Arc object from the three given points : start, middle and end.
  63834. * @param startPoint Defines the start point of the arc
  63835. * @param midPoint Defines the midlle point of the arc
  63836. * @param endPoint Defines the end point of the arc
  63837. */
  63838. constructor(
  63839. /** Defines the start point of the arc */
  63840. startPoint: Vector2,
  63841. /** Defines the mid point of the arc */
  63842. midPoint: Vector2,
  63843. /** Defines the end point of the arc */
  63844. endPoint: Vector2);
  63845. }
  63846. /**
  63847. * Represents a 2D path made up of multiple 2D points
  63848. */
  63849. export class Path2 {
  63850. private _points;
  63851. private _length;
  63852. /**
  63853. * If the path start and end point are the same
  63854. */
  63855. closed: boolean;
  63856. /**
  63857. * Creates a Path2 object from the starting 2D coordinates x and y.
  63858. * @param x the starting points x value
  63859. * @param y the starting points y value
  63860. */
  63861. constructor(x: number, y: number);
  63862. /**
  63863. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63864. * @param x the added points x value
  63865. * @param y the added points y value
  63866. * @returns the updated Path2.
  63867. */
  63868. addLineTo(x: number, y: number): Path2;
  63869. /**
  63870. * 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.
  63871. * @param midX middle point x value
  63872. * @param midY middle point y value
  63873. * @param endX end point x value
  63874. * @param endY end point y value
  63875. * @param numberOfSegments (default: 36)
  63876. * @returns the updated Path2.
  63877. */
  63878. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63879. /**
  63880. * Closes the Path2.
  63881. * @returns the Path2.
  63882. */
  63883. close(): Path2;
  63884. /**
  63885. * Gets the sum of the distance between each sequential point in the path
  63886. * @returns the Path2 total length (float).
  63887. */
  63888. length(): number;
  63889. /**
  63890. * Gets the points which construct the path
  63891. * @returns the Path2 internal array of points.
  63892. */
  63893. getPoints(): Vector2[];
  63894. /**
  63895. * Retreives the point at the distance aways from the starting point
  63896. * @param normalizedLengthPosition the length along the path to retreive the point from
  63897. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63898. */
  63899. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63900. /**
  63901. * Creates a new path starting from an x and y position
  63902. * @param x starting x value
  63903. * @param y starting y value
  63904. * @returns a new Path2 starting at the coordinates (x, y).
  63905. */
  63906. static StartingAt(x: number, y: number): Path2;
  63907. }
  63908. /**
  63909. * Represents a 3D path made up of multiple 3D points
  63910. */
  63911. export class Path3D {
  63912. /**
  63913. * an array of Vector3, the curve axis of the Path3D
  63914. */
  63915. path: Vector3[];
  63916. private _curve;
  63917. private _distances;
  63918. private _tangents;
  63919. private _normals;
  63920. private _binormals;
  63921. private _raw;
  63922. /**
  63923. * new Path3D(path, normal, raw)
  63924. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63925. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63926. * @param path an array of Vector3, the curve axis of the Path3D
  63927. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63928. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63929. */
  63930. constructor(
  63931. /**
  63932. * an array of Vector3, the curve axis of the Path3D
  63933. */
  63934. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63935. /**
  63936. * Returns the Path3D array of successive Vector3 designing its curve.
  63937. * @returns the Path3D array of successive Vector3 designing its curve.
  63938. */
  63939. getCurve(): Vector3[];
  63940. /**
  63941. * Returns an array populated with tangent vectors on each Path3D curve point.
  63942. * @returns an array populated with tangent vectors on each Path3D curve point.
  63943. */
  63944. getTangents(): Vector3[];
  63945. /**
  63946. * Returns an array populated with normal vectors on each Path3D curve point.
  63947. * @returns an array populated with normal vectors on each Path3D curve point.
  63948. */
  63949. getNormals(): Vector3[];
  63950. /**
  63951. * Returns an array populated with binormal vectors on each Path3D curve point.
  63952. * @returns an array populated with binormal vectors on each Path3D curve point.
  63953. */
  63954. getBinormals(): Vector3[];
  63955. /**
  63956. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63957. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63958. */
  63959. getDistances(): number[];
  63960. /**
  63961. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63962. * @param path path which all values are copied into the curves points
  63963. * @param firstNormal which should be projected onto the curve
  63964. * @returns the same object updated.
  63965. */
  63966. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63967. private _compute;
  63968. private _getFirstNonNullVector;
  63969. private _getLastNonNullVector;
  63970. private _normalVector;
  63971. }
  63972. /**
  63973. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63974. * A Curve3 is designed from a series of successive Vector3.
  63975. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63976. */
  63977. export class Curve3 {
  63978. private _points;
  63979. private _length;
  63980. /**
  63981. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63982. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63983. * @param v1 (Vector3) the control point
  63984. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63985. * @param nbPoints (integer) the wanted number of points in the curve
  63986. * @returns the created Curve3
  63987. */
  63988. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63989. /**
  63990. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63991. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63992. * @param v1 (Vector3) the first control point
  63993. * @param v2 (Vector3) the second control point
  63994. * @param v3 (Vector3) the end point of the Cubic Bezier
  63995. * @param nbPoints (integer) the wanted number of points in the curve
  63996. * @returns the created Curve3
  63997. */
  63998. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63999. /**
  64000. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  64001. * @param p1 (Vector3) the origin point of the Hermite Spline
  64002. * @param t1 (Vector3) the tangent vector at the origin point
  64003. * @param p2 (Vector3) the end point of the Hermite Spline
  64004. * @param t2 (Vector3) the tangent vector at the end point
  64005. * @param nbPoints (integer) the wanted number of points in the curve
  64006. * @returns the created Curve3
  64007. */
  64008. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64009. /**
  64010. * Returns a Curve3 object along a CatmullRom Spline curve :
  64011. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  64012. * @param nbPoints (integer) the wanted number of points between each curve control points
  64013. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  64014. * @returns the created Curve3
  64015. */
  64016. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  64017. /**
  64018. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64019. * A Curve3 is designed from a series of successive Vector3.
  64020. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  64021. * @param points points which make up the curve
  64022. */
  64023. constructor(points: Vector3[]);
  64024. /**
  64025. * @returns the Curve3 stored array of successive Vector3
  64026. */
  64027. getPoints(): Vector3[];
  64028. /**
  64029. * @returns the computed length (float) of the curve.
  64030. */
  64031. length(): number;
  64032. /**
  64033. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64034. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64035. * curveA and curveB keep unchanged.
  64036. * @param curve the curve to continue from this curve
  64037. * @returns the newly constructed curve
  64038. */
  64039. continue(curve: DeepImmutable<Curve3>): Curve3;
  64040. private _computeLength;
  64041. }
  64042. /**
  64043. * Contains position and normal vectors for a vertex
  64044. */
  64045. export class PositionNormalVertex {
  64046. /** the position of the vertex (defaut: 0,0,0) */
  64047. position: Vector3;
  64048. /** the normal of the vertex (defaut: 0,1,0) */
  64049. normal: Vector3;
  64050. /**
  64051. * Creates a PositionNormalVertex
  64052. * @param position the position of the vertex (defaut: 0,0,0)
  64053. * @param normal the normal of the vertex (defaut: 0,1,0)
  64054. */
  64055. constructor(
  64056. /** the position of the vertex (defaut: 0,0,0) */
  64057. position?: Vector3,
  64058. /** the normal of the vertex (defaut: 0,1,0) */
  64059. normal?: Vector3);
  64060. /**
  64061. * Clones the PositionNormalVertex
  64062. * @returns the cloned PositionNormalVertex
  64063. */
  64064. clone(): PositionNormalVertex;
  64065. }
  64066. /**
  64067. * Contains position, normal and uv vectors for a vertex
  64068. */
  64069. export class PositionNormalTextureVertex {
  64070. /** the position of the vertex (defaut: 0,0,0) */
  64071. position: Vector3;
  64072. /** the normal of the vertex (defaut: 0,1,0) */
  64073. normal: Vector3;
  64074. /** the uv of the vertex (default: 0,0) */
  64075. uv: Vector2;
  64076. /**
  64077. * Creates a PositionNormalTextureVertex
  64078. * @param position the position of the vertex (defaut: 0,0,0)
  64079. * @param normal the normal of the vertex (defaut: 0,1,0)
  64080. * @param uv the uv of the vertex (default: 0,0)
  64081. */
  64082. constructor(
  64083. /** the position of the vertex (defaut: 0,0,0) */
  64084. position?: Vector3,
  64085. /** the normal of the vertex (defaut: 0,1,0) */
  64086. normal?: Vector3,
  64087. /** the uv of the vertex (default: 0,0) */
  64088. uv?: Vector2);
  64089. /**
  64090. * Clones the PositionNormalTextureVertex
  64091. * @returns the cloned PositionNormalTextureVertex
  64092. */
  64093. clone(): PositionNormalTextureVertex;
  64094. }
  64095. /**
  64096. * @hidden
  64097. */
  64098. export class Tmp {
  64099. static Color3: Color3[];
  64100. static Color4: Color4[];
  64101. static Vector2: Vector2[];
  64102. static Vector3: Vector3[];
  64103. static Vector4: Vector4[];
  64104. static Quaternion: Quaternion[];
  64105. static Matrix: Matrix[];
  64106. }
  64107. }
  64108. declare module BABYLON {
  64109. /**
  64110. * Class used to enable access to offline support
  64111. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64112. */
  64113. export interface IOfflineProvider {
  64114. /**
  64115. * Gets a boolean indicating if scene must be saved in the database
  64116. */
  64117. enableSceneOffline: boolean;
  64118. /**
  64119. * Gets a boolean indicating if textures must be saved in the database
  64120. */
  64121. enableTexturesOffline: boolean;
  64122. /**
  64123. * Open the offline support and make it available
  64124. * @param successCallback defines the callback to call on success
  64125. * @param errorCallback defines the callback to call on error
  64126. */
  64127. open(successCallback: () => void, errorCallback: () => void): void;
  64128. /**
  64129. * Loads an image from the offline support
  64130. * @param url defines the url to load from
  64131. * @param image defines the target DOM image
  64132. */
  64133. loadImage(url: string, image: HTMLImageElement): void;
  64134. /**
  64135. * Loads a file from offline support
  64136. * @param url defines the URL to load from
  64137. * @param sceneLoaded defines a callback to call on success
  64138. * @param progressCallBack defines a callback to call when progress changed
  64139. * @param errorCallback defines a callback to call on error
  64140. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64141. */
  64142. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64143. }
  64144. }
  64145. declare module BABYLON {
  64146. /**
  64147. * A class serves as a medium between the observable and its observers
  64148. */
  64149. export class EventState {
  64150. /**
  64151. * Create a new EventState
  64152. * @param mask defines the mask associated with this state
  64153. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64154. * @param target defines the original target of the state
  64155. * @param currentTarget defines the current target of the state
  64156. */
  64157. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64158. /**
  64159. * Initialize the current event state
  64160. * @param mask defines the mask associated with this state
  64161. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64162. * @param target defines the original target of the state
  64163. * @param currentTarget defines the current target of the state
  64164. * @returns the current event state
  64165. */
  64166. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64167. /**
  64168. * An Observer can set this property to true to prevent subsequent observers of being notified
  64169. */
  64170. skipNextObservers: boolean;
  64171. /**
  64172. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64173. */
  64174. mask: number;
  64175. /**
  64176. * The object that originally notified the event
  64177. */
  64178. target?: any;
  64179. /**
  64180. * The current object in the bubbling phase
  64181. */
  64182. currentTarget?: any;
  64183. /**
  64184. * This will be populated with the return value of the last function that was executed.
  64185. * If it is the first function in the callback chain it will be the event data.
  64186. */
  64187. lastReturnValue?: any;
  64188. }
  64189. /**
  64190. * Represent an Observer registered to a given Observable object.
  64191. */
  64192. export class Observer<T> {
  64193. /**
  64194. * Defines the callback to call when the observer is notified
  64195. */
  64196. callback: (eventData: T, eventState: EventState) => void;
  64197. /**
  64198. * Defines the mask of the observer (used to filter notifications)
  64199. */
  64200. mask: number;
  64201. /**
  64202. * Defines the current scope used to restore the JS context
  64203. */
  64204. scope: any;
  64205. /** @hidden */
  64206. _willBeUnregistered: boolean;
  64207. /**
  64208. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64209. */
  64210. unregisterOnNextCall: boolean;
  64211. /**
  64212. * Creates a new observer
  64213. * @param callback defines the callback to call when the observer is notified
  64214. * @param mask defines the mask of the observer (used to filter notifications)
  64215. * @param scope defines the current scope used to restore the JS context
  64216. */
  64217. constructor(
  64218. /**
  64219. * Defines the callback to call when the observer is notified
  64220. */
  64221. callback: (eventData: T, eventState: EventState) => void,
  64222. /**
  64223. * Defines the mask of the observer (used to filter notifications)
  64224. */
  64225. mask: number,
  64226. /**
  64227. * Defines the current scope used to restore the JS context
  64228. */
  64229. scope?: any);
  64230. }
  64231. /**
  64232. * Represent a list of observers registered to multiple Observables object.
  64233. */
  64234. export class MultiObserver<T> {
  64235. private _observers;
  64236. private _observables;
  64237. /**
  64238. * Release associated resources
  64239. */
  64240. dispose(): void;
  64241. /**
  64242. * Raise a callback when one of the observable will notify
  64243. * @param observables defines a list of observables to watch
  64244. * @param callback defines the callback to call on notification
  64245. * @param mask defines the mask used to filter notifications
  64246. * @param scope defines the current scope used to restore the JS context
  64247. * @returns the new MultiObserver
  64248. */
  64249. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64250. }
  64251. /**
  64252. * The Observable class is a simple implementation of the Observable pattern.
  64253. *
  64254. * 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.
  64255. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64256. * 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).
  64257. * 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.
  64258. */
  64259. export class Observable<T> {
  64260. private _observers;
  64261. private _eventState;
  64262. private _onObserverAdded;
  64263. /**
  64264. * Creates a new observable
  64265. * @param onObserverAdded defines a callback to call when a new observer is added
  64266. */
  64267. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64268. /**
  64269. * Create a new Observer with the specified callback
  64270. * @param callback the callback that will be executed for that Observer
  64271. * @param mask the mask used to filter observers
  64272. * @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.
  64273. * @param scope optional scope for the callback to be called from
  64274. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64275. * @returns the new observer created for the callback
  64276. */
  64277. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64278. /**
  64279. * Create a new Observer with the specified callback and unregisters after the next notification
  64280. * @param callback the callback that will be executed for that Observer
  64281. * @returns the new observer created for the callback
  64282. */
  64283. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64284. /**
  64285. * Remove an Observer from the Observable object
  64286. * @param observer the instance of the Observer to remove
  64287. * @returns false if it doesn't belong to this Observable
  64288. */
  64289. remove(observer: Nullable<Observer<T>>): boolean;
  64290. /**
  64291. * Remove a callback from the Observable object
  64292. * @param callback the callback to remove
  64293. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64294. * @returns false if it doesn't belong to this Observable
  64295. */
  64296. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64297. private _deferUnregister;
  64298. private _remove;
  64299. /**
  64300. * Moves the observable to the top of the observer list making it get called first when notified
  64301. * @param observer the observer to move
  64302. */
  64303. makeObserverTopPriority(observer: Observer<T>): void;
  64304. /**
  64305. * Moves the observable to the bottom of the observer list making it get called last when notified
  64306. * @param observer the observer to move
  64307. */
  64308. makeObserverBottomPriority(observer: Observer<T>): void;
  64309. /**
  64310. * Notify all Observers by calling their respective callback with the given data
  64311. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64312. * @param eventData defines the data to send to all observers
  64313. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64314. * @param target defines the original target of the state
  64315. * @param currentTarget defines the current target of the state
  64316. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64317. */
  64318. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64319. /**
  64320. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64321. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64322. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64323. * and it is crucial that all callbacks will be executed.
  64324. * The order of the callbacks is kept, callbacks are not executed parallel.
  64325. *
  64326. * @param eventData The data to be sent to each callback
  64327. * @param mask is used to filter observers defaults to -1
  64328. * @param target defines the callback target (see EventState)
  64329. * @param currentTarget defines he current object in the bubbling phase
  64330. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64331. */
  64332. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64333. /**
  64334. * Notify a specific observer
  64335. * @param observer defines the observer to notify
  64336. * @param eventData defines the data to be sent to each callback
  64337. * @param mask is used to filter observers defaults to -1
  64338. */
  64339. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64340. /**
  64341. * Gets a boolean indicating if the observable has at least one observer
  64342. * @returns true is the Observable has at least one Observer registered
  64343. */
  64344. hasObservers(): boolean;
  64345. /**
  64346. * Clear the list of observers
  64347. */
  64348. clear(): void;
  64349. /**
  64350. * Clone the current observable
  64351. * @returns a new observable
  64352. */
  64353. clone(): Observable<T>;
  64354. /**
  64355. * Does this observable handles observer registered with a given mask
  64356. * @param mask defines the mask to be tested
  64357. * @return whether or not one observer registered with the given mask is handeled
  64358. **/
  64359. hasSpecificMask(mask?: number): boolean;
  64360. }
  64361. }
  64362. declare module BABYLON {
  64363. /**
  64364. * Class used to help managing file picking and drag'n'drop
  64365. * File Storage
  64366. */
  64367. export class FilesInputStore {
  64368. /**
  64369. * List of files ready to be loaded
  64370. */
  64371. static FilesToLoad: {
  64372. [key: string]: File;
  64373. };
  64374. }
  64375. }
  64376. declare module BABYLON {
  64377. /** Defines the cross module used constants to avoid circular dependncies */
  64378. export class Constants {
  64379. /** Defines that alpha blending is disabled */
  64380. static readonly ALPHA_DISABLE: number;
  64381. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64382. static readonly ALPHA_ADD: number;
  64383. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64384. static readonly ALPHA_COMBINE: number;
  64385. /** Defines that alpha blending to DEST - SRC * DEST */
  64386. static readonly ALPHA_SUBTRACT: number;
  64387. /** Defines that alpha blending to SRC * DEST */
  64388. static readonly ALPHA_MULTIPLY: number;
  64389. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64390. static readonly ALPHA_MAXIMIZED: number;
  64391. /** Defines that alpha blending to SRC + DEST */
  64392. static readonly ALPHA_ONEONE: number;
  64393. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64394. static readonly ALPHA_PREMULTIPLIED: number;
  64395. /**
  64396. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64397. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64398. */
  64399. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64400. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64401. static readonly ALPHA_INTERPOLATE: number;
  64402. /**
  64403. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64404. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64405. */
  64406. static readonly ALPHA_SCREENMODE: number;
  64407. /** Defines that the ressource is not delayed*/
  64408. static readonly DELAYLOADSTATE_NONE: number;
  64409. /** Defines that the ressource was successfully delay loaded */
  64410. static readonly DELAYLOADSTATE_LOADED: number;
  64411. /** Defines that the ressource is currently delay loading */
  64412. static readonly DELAYLOADSTATE_LOADING: number;
  64413. /** Defines that the ressource is delayed and has not started loading */
  64414. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64415. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64416. static readonly NEVER: number;
  64417. /** 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 */
  64418. static readonly ALWAYS: number;
  64419. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64420. static readonly LESS: number;
  64421. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64422. static readonly EQUAL: number;
  64423. /** 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 */
  64424. static readonly LEQUAL: number;
  64425. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64426. static readonly GREATER: number;
  64427. /** 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 */
  64428. static readonly GEQUAL: number;
  64429. /** 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 */
  64430. static readonly NOTEQUAL: number;
  64431. /** Passed to stencilOperation to specify that stencil value must be kept */
  64432. static readonly KEEP: number;
  64433. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64434. static readonly REPLACE: number;
  64435. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64436. static readonly INCR: number;
  64437. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64438. static readonly DECR: number;
  64439. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64440. static readonly INVERT: number;
  64441. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64442. static readonly INCR_WRAP: number;
  64443. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64444. static readonly DECR_WRAP: number;
  64445. /** Texture is not repeating outside of 0..1 UVs */
  64446. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64447. /** Texture is repeating outside of 0..1 UVs */
  64448. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64449. /** Texture is repeating and mirrored */
  64450. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64451. /** ALPHA */
  64452. static readonly TEXTUREFORMAT_ALPHA: number;
  64453. /** LUMINANCE */
  64454. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64455. /** LUMINANCE_ALPHA */
  64456. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64457. /** RGB */
  64458. static readonly TEXTUREFORMAT_RGB: number;
  64459. /** RGBA */
  64460. static readonly TEXTUREFORMAT_RGBA: number;
  64461. /** RED */
  64462. static readonly TEXTUREFORMAT_RED: number;
  64463. /** RED (2nd reference) */
  64464. static readonly TEXTUREFORMAT_R: number;
  64465. /** RG */
  64466. static readonly TEXTUREFORMAT_RG: number;
  64467. /** RED_INTEGER */
  64468. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64469. /** RED_INTEGER (2nd reference) */
  64470. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64471. /** RG_INTEGER */
  64472. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64473. /** RGB_INTEGER */
  64474. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64475. /** RGBA_INTEGER */
  64476. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64477. /** UNSIGNED_BYTE */
  64478. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64479. /** UNSIGNED_BYTE (2nd reference) */
  64480. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64481. /** FLOAT */
  64482. static readonly TEXTURETYPE_FLOAT: number;
  64483. /** HALF_FLOAT */
  64484. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64485. /** BYTE */
  64486. static readonly TEXTURETYPE_BYTE: number;
  64487. /** SHORT */
  64488. static readonly TEXTURETYPE_SHORT: number;
  64489. /** UNSIGNED_SHORT */
  64490. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64491. /** INT */
  64492. static readonly TEXTURETYPE_INT: number;
  64493. /** UNSIGNED_INT */
  64494. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64495. /** UNSIGNED_SHORT_4_4_4_4 */
  64496. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64497. /** UNSIGNED_SHORT_5_5_5_1 */
  64498. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64499. /** UNSIGNED_SHORT_5_6_5 */
  64500. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64501. /** UNSIGNED_INT_2_10_10_10_REV */
  64502. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64503. /** UNSIGNED_INT_24_8 */
  64504. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64505. /** UNSIGNED_INT_10F_11F_11F_REV */
  64506. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64507. /** UNSIGNED_INT_5_9_9_9_REV */
  64508. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64509. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64510. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64511. /** nearest is mag = nearest and min = nearest and mip = linear */
  64512. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64513. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64514. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64515. /** Trilinear is mag = linear and min = linear and mip = linear */
  64516. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64517. /** nearest is mag = nearest and min = nearest and mip = linear */
  64518. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64519. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64520. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64521. /** Trilinear is mag = linear and min = linear and mip = linear */
  64522. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64523. /** mag = nearest and min = nearest and mip = nearest */
  64524. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64525. /** mag = nearest and min = linear and mip = nearest */
  64526. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64527. /** mag = nearest and min = linear and mip = linear */
  64528. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64529. /** mag = nearest and min = linear and mip = none */
  64530. static readonly TEXTURE_NEAREST_LINEAR: number;
  64531. /** mag = nearest and min = nearest and mip = none */
  64532. static readonly TEXTURE_NEAREST_NEAREST: number;
  64533. /** mag = linear and min = nearest and mip = nearest */
  64534. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64535. /** mag = linear and min = nearest and mip = linear */
  64536. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64537. /** mag = linear and min = linear and mip = none */
  64538. static readonly TEXTURE_LINEAR_LINEAR: number;
  64539. /** mag = linear and min = nearest and mip = none */
  64540. static readonly TEXTURE_LINEAR_NEAREST: number;
  64541. /** Explicit coordinates mode */
  64542. static readonly TEXTURE_EXPLICIT_MODE: number;
  64543. /** Spherical coordinates mode */
  64544. static readonly TEXTURE_SPHERICAL_MODE: number;
  64545. /** Planar coordinates mode */
  64546. static readonly TEXTURE_PLANAR_MODE: number;
  64547. /** Cubic coordinates mode */
  64548. static readonly TEXTURE_CUBIC_MODE: number;
  64549. /** Projection coordinates mode */
  64550. static readonly TEXTURE_PROJECTION_MODE: number;
  64551. /** Skybox coordinates mode */
  64552. static readonly TEXTURE_SKYBOX_MODE: number;
  64553. /** Inverse Cubic coordinates mode */
  64554. static readonly TEXTURE_INVCUBIC_MODE: number;
  64555. /** Equirectangular coordinates mode */
  64556. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64557. /** Equirectangular Fixed coordinates mode */
  64558. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64559. /** Equirectangular Fixed Mirrored coordinates mode */
  64560. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64561. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64562. static readonly SCALEMODE_FLOOR: number;
  64563. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64564. static readonly SCALEMODE_NEAREST: number;
  64565. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64566. static readonly SCALEMODE_CEILING: number;
  64567. /**
  64568. * The dirty texture flag value
  64569. */
  64570. static readonly MATERIAL_TextureDirtyFlag: number;
  64571. /**
  64572. * The dirty light flag value
  64573. */
  64574. static readonly MATERIAL_LightDirtyFlag: number;
  64575. /**
  64576. * The dirty fresnel flag value
  64577. */
  64578. static readonly MATERIAL_FresnelDirtyFlag: number;
  64579. /**
  64580. * The dirty attribute flag value
  64581. */
  64582. static readonly MATERIAL_AttributesDirtyFlag: number;
  64583. /**
  64584. * The dirty misc flag value
  64585. */
  64586. static readonly MATERIAL_MiscDirtyFlag: number;
  64587. /**
  64588. * The all dirty flag value
  64589. */
  64590. static readonly MATERIAL_AllDirtyFlag: number;
  64591. /**
  64592. * Returns the triangle fill mode
  64593. */
  64594. static readonly MATERIAL_TriangleFillMode: number;
  64595. /**
  64596. * Returns the wireframe mode
  64597. */
  64598. static readonly MATERIAL_WireFrameFillMode: number;
  64599. /**
  64600. * Returns the point fill mode
  64601. */
  64602. static readonly MATERIAL_PointFillMode: number;
  64603. /**
  64604. * Returns the point list draw mode
  64605. */
  64606. static readonly MATERIAL_PointListDrawMode: number;
  64607. /**
  64608. * Returns the line list draw mode
  64609. */
  64610. static readonly MATERIAL_LineListDrawMode: number;
  64611. /**
  64612. * Returns the line loop draw mode
  64613. */
  64614. static readonly MATERIAL_LineLoopDrawMode: number;
  64615. /**
  64616. * Returns the line strip draw mode
  64617. */
  64618. static readonly MATERIAL_LineStripDrawMode: number;
  64619. /**
  64620. * Returns the triangle strip draw mode
  64621. */
  64622. static readonly MATERIAL_TriangleStripDrawMode: number;
  64623. /**
  64624. * Returns the triangle fan draw mode
  64625. */
  64626. static readonly MATERIAL_TriangleFanDrawMode: number;
  64627. /**
  64628. * Stores the clock-wise side orientation
  64629. */
  64630. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64631. /**
  64632. * Stores the counter clock-wise side orientation
  64633. */
  64634. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64635. /**
  64636. * Nothing
  64637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64638. */
  64639. static readonly ACTION_NothingTrigger: number;
  64640. /**
  64641. * On pick
  64642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64643. */
  64644. static readonly ACTION_OnPickTrigger: number;
  64645. /**
  64646. * On left pick
  64647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64648. */
  64649. static readonly ACTION_OnLeftPickTrigger: number;
  64650. /**
  64651. * On right pick
  64652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64653. */
  64654. static readonly ACTION_OnRightPickTrigger: number;
  64655. /**
  64656. * On center pick
  64657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64658. */
  64659. static readonly ACTION_OnCenterPickTrigger: number;
  64660. /**
  64661. * On pick down
  64662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64663. */
  64664. static readonly ACTION_OnPickDownTrigger: number;
  64665. /**
  64666. * On double pick
  64667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64668. */
  64669. static readonly ACTION_OnDoublePickTrigger: number;
  64670. /**
  64671. * On pick up
  64672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64673. */
  64674. static readonly ACTION_OnPickUpTrigger: number;
  64675. /**
  64676. * On pick out.
  64677. * This trigger will only be raised if you also declared a OnPickDown
  64678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64679. */
  64680. static readonly ACTION_OnPickOutTrigger: number;
  64681. /**
  64682. * On long press
  64683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64684. */
  64685. static readonly ACTION_OnLongPressTrigger: number;
  64686. /**
  64687. * On pointer over
  64688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64689. */
  64690. static readonly ACTION_OnPointerOverTrigger: number;
  64691. /**
  64692. * On pointer out
  64693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64694. */
  64695. static readonly ACTION_OnPointerOutTrigger: number;
  64696. /**
  64697. * On every frame
  64698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64699. */
  64700. static readonly ACTION_OnEveryFrameTrigger: number;
  64701. /**
  64702. * On intersection enter
  64703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64704. */
  64705. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64706. /**
  64707. * On intersection exit
  64708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64709. */
  64710. static readonly ACTION_OnIntersectionExitTrigger: number;
  64711. /**
  64712. * On key down
  64713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64714. */
  64715. static readonly ACTION_OnKeyDownTrigger: number;
  64716. /**
  64717. * On key up
  64718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64719. */
  64720. static readonly ACTION_OnKeyUpTrigger: number;
  64721. /**
  64722. * Billboard mode will only apply to Y axis
  64723. */
  64724. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64725. /**
  64726. * Billboard mode will apply to all axes
  64727. */
  64728. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64729. /**
  64730. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64731. */
  64732. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64733. /**
  64734. * Gets or sets base Assets URL
  64735. */
  64736. static readonly PARTICLES_BaseAssetsUrl: string;
  64737. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64738. * Test order :
  64739. * Is the bounding sphere outside the frustum ?
  64740. * If not, are the bounding box vertices outside the frustum ?
  64741. * It not, then the cullable object is in the frustum.
  64742. */
  64743. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64744. /** Culling strategy : Bounding Sphere Only.
  64745. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64746. * It's also less accurate than the standard because some not visible objects can still be selected.
  64747. * Test : is the bounding sphere outside the frustum ?
  64748. * If not, then the cullable object is in the frustum.
  64749. */
  64750. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64751. /** Culling strategy : Optimistic Inclusion.
  64752. * This in an inclusion test first, then the standard exclusion test.
  64753. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64754. * 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.
  64755. * Anyway, it's as accurate as the standard strategy.
  64756. * Test :
  64757. * Is the cullable object bounding sphere center in the frustum ?
  64758. * If not, apply the default culling strategy.
  64759. */
  64760. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64761. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64762. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64763. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64764. * 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.
  64765. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64766. * Test :
  64767. * Is the cullable object bounding sphere center in the frustum ?
  64768. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64769. */
  64770. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64771. /**
  64772. * No logging while loading
  64773. */
  64774. static readonly SCENELOADER_NO_LOGGING: number;
  64775. /**
  64776. * Minimal logging while loading
  64777. */
  64778. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64779. /**
  64780. * Summary logging while loading
  64781. */
  64782. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64783. /**
  64784. * Detailled logging while loading
  64785. */
  64786. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64787. }
  64788. }
  64789. declare module BABYLON {
  64790. /**
  64791. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64792. * Babylon.js
  64793. */
  64794. export class DomManagement {
  64795. /**
  64796. * Checks if the window object exists
  64797. * @returns true if the window object exists
  64798. */
  64799. static IsWindowObjectExist(): boolean;
  64800. /**
  64801. * Extracts text content from a DOM element hierarchy
  64802. * @param element defines the root element
  64803. * @returns a string
  64804. */
  64805. static GetDOMTextContent(element: HTMLElement): string;
  64806. }
  64807. }
  64808. declare module BABYLON {
  64809. /**
  64810. * Logger used througouht the application to allow configuration of
  64811. * the log level required for the messages.
  64812. */
  64813. export class Logger {
  64814. /**
  64815. * No log
  64816. */
  64817. static readonly NoneLogLevel: number;
  64818. /**
  64819. * Only message logs
  64820. */
  64821. static readonly MessageLogLevel: number;
  64822. /**
  64823. * Only warning logs
  64824. */
  64825. static readonly WarningLogLevel: number;
  64826. /**
  64827. * Only error logs
  64828. */
  64829. static readonly ErrorLogLevel: number;
  64830. /**
  64831. * All logs
  64832. */
  64833. static readonly AllLogLevel: number;
  64834. private static _LogCache;
  64835. /**
  64836. * Gets a value indicating the number of loading errors
  64837. * @ignorenaming
  64838. */
  64839. static errorsCount: number;
  64840. /**
  64841. * Callback called when a new log is added
  64842. */
  64843. static OnNewCacheEntry: (entry: string) => void;
  64844. private static _AddLogEntry;
  64845. private static _FormatMessage;
  64846. private static _LogDisabled;
  64847. private static _LogEnabled;
  64848. private static _WarnDisabled;
  64849. private static _WarnEnabled;
  64850. private static _ErrorDisabled;
  64851. private static _ErrorEnabled;
  64852. /**
  64853. * Log a message to the console
  64854. */
  64855. static Log: (message: string) => void;
  64856. /**
  64857. * Write a warning message to the console
  64858. */
  64859. static Warn: (message: string) => void;
  64860. /**
  64861. * Write an error message to the console
  64862. */
  64863. static Error: (message: string) => void;
  64864. /**
  64865. * Gets current log cache (list of logs)
  64866. */
  64867. static readonly LogCache: string;
  64868. /**
  64869. * Clears the log cache
  64870. */
  64871. static ClearLogCache(): void;
  64872. /**
  64873. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64874. */
  64875. static LogLevels: number;
  64876. }
  64877. }
  64878. declare module BABYLON {
  64879. /** @hidden */
  64880. export class _TypeStore {
  64881. /** @hidden */
  64882. static RegisteredTypes: {
  64883. [key: string]: Object;
  64884. };
  64885. /** @hidden */
  64886. static GetClass(fqdn: string): any;
  64887. }
  64888. }
  64889. declare module BABYLON {
  64890. /**
  64891. * Class containing a set of static utilities functions for deep copy.
  64892. */
  64893. export class DeepCopier {
  64894. /**
  64895. * Tries to copy an object by duplicating every property
  64896. * @param source defines the source object
  64897. * @param destination defines the target object
  64898. * @param doNotCopyList defines a list of properties to avoid
  64899. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64900. */
  64901. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64902. }
  64903. }
  64904. declare module BABYLON {
  64905. /**
  64906. * Class containing a set of static utilities functions for precision date
  64907. */
  64908. export class PrecisionDate {
  64909. /**
  64910. * Gets either window.performance.now() if supported or Date.now() else
  64911. */
  64912. static readonly Now: number;
  64913. }
  64914. }
  64915. declare module BABYLON {
  64916. /** @hidden */
  64917. export class _DevTools {
  64918. static WarnImport(name: string): string;
  64919. }
  64920. }
  64921. declare module BABYLON {
  64922. /**
  64923. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64924. */
  64925. export class WebRequest {
  64926. private _xhr;
  64927. /**
  64928. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64929. * i.e. when loading files, where the server/service expects an Authorization header
  64930. */
  64931. static CustomRequestHeaders: {
  64932. [key: string]: string;
  64933. };
  64934. /**
  64935. * Add callback functions in this array to update all the requests before they get sent to the network
  64936. */
  64937. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64938. private _injectCustomRequestHeaders;
  64939. /**
  64940. * Gets or sets a function to be called when loading progress changes
  64941. */
  64942. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64943. /**
  64944. * Returns client's state
  64945. */
  64946. readonly readyState: number;
  64947. /**
  64948. * Returns client's status
  64949. */
  64950. readonly status: number;
  64951. /**
  64952. * Returns client's status as a text
  64953. */
  64954. readonly statusText: string;
  64955. /**
  64956. * Returns client's response
  64957. */
  64958. readonly response: any;
  64959. /**
  64960. * Returns client's response url
  64961. */
  64962. readonly responseURL: string;
  64963. /**
  64964. * Returns client's response as text
  64965. */
  64966. readonly responseText: string;
  64967. /**
  64968. * Gets or sets the expected response type
  64969. */
  64970. responseType: XMLHttpRequestResponseType;
  64971. /** @hidden */
  64972. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64973. /** @hidden */
  64974. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64975. /**
  64976. * Cancels any network activity
  64977. */
  64978. abort(): void;
  64979. /**
  64980. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64981. * @param body defines an optional request body
  64982. */
  64983. send(body?: Document | BodyInit | null): void;
  64984. /**
  64985. * Sets the request method, request URL
  64986. * @param method defines the method to use (GET, POST, etc..)
  64987. * @param url defines the url to connect with
  64988. */
  64989. open(method: string, url: string): void;
  64990. }
  64991. }
  64992. declare module BABYLON {
  64993. /**
  64994. * Class used to evalaute queries containing `and` and `or` operators
  64995. */
  64996. export class AndOrNotEvaluator {
  64997. /**
  64998. * Evaluate a query
  64999. * @param query defines the query to evaluate
  65000. * @param evaluateCallback defines the callback used to filter result
  65001. * @returns true if the query matches
  65002. */
  65003. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  65004. private static _HandleParenthesisContent;
  65005. private static _SimplifyNegation;
  65006. }
  65007. }
  65008. declare module BABYLON {
  65009. /**
  65010. * Class used to store custom tags
  65011. */
  65012. export class Tags {
  65013. /**
  65014. * Adds support for tags on the given object
  65015. * @param obj defines the object to use
  65016. */
  65017. static EnableFor(obj: any): void;
  65018. /**
  65019. * Removes tags support
  65020. * @param obj defines the object to use
  65021. */
  65022. static DisableFor(obj: any): void;
  65023. /**
  65024. * Gets a boolean indicating if the given object has tags
  65025. * @param obj defines the object to use
  65026. * @returns a boolean
  65027. */
  65028. static HasTags(obj: any): boolean;
  65029. /**
  65030. * Gets the tags available on a given object
  65031. * @param obj defines the object to use
  65032. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65033. * @returns the tags
  65034. */
  65035. static GetTags(obj: any, asString?: boolean): any;
  65036. /**
  65037. * Adds tags to an object
  65038. * @param obj defines the object to use
  65039. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65040. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65041. */
  65042. static AddTagsTo(obj: any, tagsString: string): void;
  65043. /**
  65044. * @hidden
  65045. */
  65046. static _AddTagTo(obj: any, tag: string): void;
  65047. /**
  65048. * Removes specific tags from a specific object
  65049. * @param obj defines the object to use
  65050. * @param tagsString defines the tags to remove
  65051. */
  65052. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65053. /**
  65054. * @hidden
  65055. */
  65056. static _RemoveTagFrom(obj: any, tag: string): void;
  65057. /**
  65058. * Defines if tags hosted on an object match a given query
  65059. * @param obj defines the object to use
  65060. * @param tagsQuery defines the tag query
  65061. * @returns a boolean
  65062. */
  65063. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65064. }
  65065. }
  65066. declare module BABYLON {
  65067. /**
  65068. * Manages the defines for the Material
  65069. */
  65070. export class MaterialDefines {
  65071. private _keys;
  65072. private _isDirty;
  65073. /** @hidden */
  65074. _renderId: number;
  65075. /** @hidden */
  65076. _areLightsDirty: boolean;
  65077. /** @hidden */
  65078. _areAttributesDirty: boolean;
  65079. /** @hidden */
  65080. _areTexturesDirty: boolean;
  65081. /** @hidden */
  65082. _areFresnelDirty: boolean;
  65083. /** @hidden */
  65084. _areMiscDirty: boolean;
  65085. /** @hidden */
  65086. _areImageProcessingDirty: boolean;
  65087. /** @hidden */
  65088. _normals: boolean;
  65089. /** @hidden */
  65090. _uvs: boolean;
  65091. /** @hidden */
  65092. _needNormals: boolean;
  65093. /** @hidden */
  65094. _needUVs: boolean;
  65095. /**
  65096. * Specifies if the material needs to be re-calculated
  65097. */
  65098. readonly isDirty: boolean;
  65099. /**
  65100. * Marks the material to indicate that it has been re-calculated
  65101. */
  65102. markAsProcessed(): void;
  65103. /**
  65104. * Marks the material to indicate that it needs to be re-calculated
  65105. */
  65106. markAsUnprocessed(): void;
  65107. /**
  65108. * Marks the material to indicate all of its defines need to be re-calculated
  65109. */
  65110. markAllAsDirty(): void;
  65111. /**
  65112. * Marks the material to indicate that image processing needs to be re-calculated
  65113. */
  65114. markAsImageProcessingDirty(): void;
  65115. /**
  65116. * Marks the material to indicate the lights need to be re-calculated
  65117. */
  65118. markAsLightDirty(): void;
  65119. /**
  65120. * Marks the attribute state as changed
  65121. */
  65122. markAsAttributesDirty(): void;
  65123. /**
  65124. * Marks the texture state as changed
  65125. */
  65126. markAsTexturesDirty(): void;
  65127. /**
  65128. * Marks the fresnel state as changed
  65129. */
  65130. markAsFresnelDirty(): void;
  65131. /**
  65132. * Marks the misc state as changed
  65133. */
  65134. markAsMiscDirty(): void;
  65135. /**
  65136. * Rebuilds the material defines
  65137. */
  65138. rebuild(): void;
  65139. /**
  65140. * Specifies if two material defines are equal
  65141. * @param other - A material define instance to compare to
  65142. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65143. */
  65144. isEqual(other: MaterialDefines): boolean;
  65145. /**
  65146. * Clones this instance's defines to another instance
  65147. * @param other - material defines to clone values to
  65148. */
  65149. cloneTo(other: MaterialDefines): void;
  65150. /**
  65151. * Resets the material define values
  65152. */
  65153. reset(): void;
  65154. /**
  65155. * Converts the material define values to a string
  65156. * @returns - String of material define information
  65157. */
  65158. toString(): string;
  65159. }
  65160. }
  65161. declare module BABYLON {
  65162. /**
  65163. * Class used to store and describe the pipeline context associated with an effect
  65164. */
  65165. export interface IPipelineContext {
  65166. /**
  65167. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65168. */
  65169. isAsync: boolean;
  65170. /**
  65171. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65172. */
  65173. isReady: boolean;
  65174. /** @hidden */
  65175. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  65176. }
  65177. }
  65178. declare module BABYLON {
  65179. /**
  65180. * Class used to store gfx data (like WebGLBuffer)
  65181. */
  65182. export class DataBuffer {
  65183. /**
  65184. * Gets or sets the number of objects referencing this buffer
  65185. */
  65186. references: number;
  65187. /** Gets or sets the size of the underlying buffer */
  65188. capacity: number;
  65189. /**
  65190. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65191. */
  65192. is32Bits: boolean;
  65193. /**
  65194. * Gets the underlying buffer
  65195. */
  65196. readonly underlyingResource: any;
  65197. }
  65198. }
  65199. declare module BABYLON {
  65200. /**
  65201. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65202. */
  65203. export class PerformanceMonitor {
  65204. private _enabled;
  65205. private _rollingFrameTime;
  65206. private _lastFrameTimeMs;
  65207. /**
  65208. * constructor
  65209. * @param frameSampleSize The number of samples required to saturate the sliding window
  65210. */
  65211. constructor(frameSampleSize?: number);
  65212. /**
  65213. * Samples current frame
  65214. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65215. */
  65216. sampleFrame(timeMs?: number): void;
  65217. /**
  65218. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65219. */
  65220. readonly averageFrameTime: number;
  65221. /**
  65222. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65223. */
  65224. readonly averageFrameTimeVariance: number;
  65225. /**
  65226. * Returns the frame time of the most recent frame
  65227. */
  65228. readonly instantaneousFrameTime: number;
  65229. /**
  65230. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65231. */
  65232. readonly averageFPS: number;
  65233. /**
  65234. * Returns the average framerate in frames per second using the most recent frame time
  65235. */
  65236. readonly instantaneousFPS: number;
  65237. /**
  65238. * Returns true if enough samples have been taken to completely fill the sliding window
  65239. */
  65240. readonly isSaturated: boolean;
  65241. /**
  65242. * Enables contributions to the sliding window sample set
  65243. */
  65244. enable(): void;
  65245. /**
  65246. * Disables contributions to the sliding window sample set
  65247. * Samples will not be interpolated over the disabled period
  65248. */
  65249. disable(): void;
  65250. /**
  65251. * Returns true if sampling is enabled
  65252. */
  65253. readonly isEnabled: boolean;
  65254. /**
  65255. * Resets performance monitor
  65256. */
  65257. reset(): void;
  65258. }
  65259. /**
  65260. * RollingAverage
  65261. *
  65262. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65263. */
  65264. export class RollingAverage {
  65265. /**
  65266. * Current average
  65267. */
  65268. average: number;
  65269. /**
  65270. * Current variance
  65271. */
  65272. variance: number;
  65273. protected _samples: Array<number>;
  65274. protected _sampleCount: number;
  65275. protected _pos: number;
  65276. protected _m2: number;
  65277. /**
  65278. * constructor
  65279. * @param length The number of samples required to saturate the sliding window
  65280. */
  65281. constructor(length: number);
  65282. /**
  65283. * Adds a sample to the sample set
  65284. * @param v The sample value
  65285. */
  65286. add(v: number): void;
  65287. /**
  65288. * Returns previously added values or null if outside of history or outside the sliding window domain
  65289. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65290. * @return Value previously recorded with add() or null if outside of range
  65291. */
  65292. history(i: number): number;
  65293. /**
  65294. * Returns true if enough samples have been taken to completely fill the sliding window
  65295. * @return true if sample-set saturated
  65296. */
  65297. isSaturated(): boolean;
  65298. /**
  65299. * Resets the rolling average (equivalent to 0 samples taken so far)
  65300. */
  65301. reset(): void;
  65302. /**
  65303. * Wraps a value around the sample range boundaries
  65304. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65305. * @return Wrapped position in sample range
  65306. */
  65307. protected _wrapPosition(i: number): number;
  65308. }
  65309. }
  65310. declare module BABYLON {
  65311. /**
  65312. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65313. * The underlying implementation relies on an associative array to ensure the best performances.
  65314. * The value can be anything including 'null' but except 'undefined'
  65315. */
  65316. export class StringDictionary<T> {
  65317. /**
  65318. * This will clear this dictionary and copy the content from the 'source' one.
  65319. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65320. * @param source the dictionary to take the content from and copy to this dictionary
  65321. */
  65322. copyFrom(source: StringDictionary<T>): void;
  65323. /**
  65324. * Get a value based from its key
  65325. * @param key the given key to get the matching value from
  65326. * @return the value if found, otherwise undefined is returned
  65327. */
  65328. get(key: string): T | undefined;
  65329. /**
  65330. * Get a value from its key or add it if it doesn't exist.
  65331. * This method will ensure you that a given key/data will be present in the dictionary.
  65332. * @param key the given key to get the matching value from
  65333. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65334. * The factory will only be invoked if there's no data for the given key.
  65335. * @return the value corresponding to the key.
  65336. */
  65337. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65338. /**
  65339. * Get a value from its key if present in the dictionary otherwise add it
  65340. * @param key the key to get the value from
  65341. * @param val if there's no such key/value pair in the dictionary add it with this value
  65342. * @return the value corresponding to the key
  65343. */
  65344. getOrAdd(key: string, val: T): T;
  65345. /**
  65346. * Check if there's a given key in the dictionary
  65347. * @param key the key to check for
  65348. * @return true if the key is present, false otherwise
  65349. */
  65350. contains(key: string): boolean;
  65351. /**
  65352. * Add a new key and its corresponding value
  65353. * @param key the key to add
  65354. * @param value the value corresponding to the key
  65355. * @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
  65356. */
  65357. add(key: string, value: T): boolean;
  65358. /**
  65359. * Update a specific value associated to a key
  65360. * @param key defines the key to use
  65361. * @param value defines the value to store
  65362. * @returns true if the value was updated (or false if the key was not found)
  65363. */
  65364. set(key: string, value: T): boolean;
  65365. /**
  65366. * Get the element of the given key and remove it from the dictionary
  65367. * @param key defines the key to search
  65368. * @returns the value associated with the key or null if not found
  65369. */
  65370. getAndRemove(key: string): Nullable<T>;
  65371. /**
  65372. * Remove a key/value from the dictionary.
  65373. * @param key the key to remove
  65374. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65375. */
  65376. remove(key: string): boolean;
  65377. /**
  65378. * Clear the whole content of the dictionary
  65379. */
  65380. clear(): void;
  65381. /**
  65382. * Gets the current count
  65383. */
  65384. readonly count: number;
  65385. /**
  65386. * Execute a callback on each key/val of the dictionary.
  65387. * Note that you can remove any element in this dictionary in the callback implementation
  65388. * @param callback the callback to execute on a given key/value pair
  65389. */
  65390. forEach(callback: (key: string, val: T) => void): void;
  65391. /**
  65392. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65393. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65394. * Note that you can remove any element in this dictionary in the callback implementation
  65395. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65396. * @returns the first item
  65397. */
  65398. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65399. private _count;
  65400. private _data;
  65401. }
  65402. }
  65403. declare module BABYLON {
  65404. /**
  65405. * Helper class that provides a small promise polyfill
  65406. */
  65407. export class PromisePolyfill {
  65408. /**
  65409. * Static function used to check if the polyfill is required
  65410. * If this is the case then the function will inject the polyfill to window.Promise
  65411. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65412. */
  65413. static Apply(force?: boolean): void;
  65414. }
  65415. }
  65416. declare module BABYLON {
  65417. /**
  65418. * Class used to store data that will be store in GPU memory
  65419. */
  65420. export class Buffer {
  65421. private _engine;
  65422. private _buffer;
  65423. /** @hidden */
  65424. _data: Nullable<DataArray>;
  65425. private _updatable;
  65426. private _instanced;
  65427. /**
  65428. * Gets the byte stride.
  65429. */
  65430. readonly byteStride: number;
  65431. /**
  65432. * Constructor
  65433. * @param engine the engine
  65434. * @param data the data to use for this buffer
  65435. * @param updatable whether the data is updatable
  65436. * @param stride the stride (optional)
  65437. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65438. * @param instanced whether the buffer is instanced (optional)
  65439. * @param useBytes set to true if the stride in in bytes (optional)
  65440. */
  65441. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65442. /**
  65443. * Create a new VertexBuffer based on the current buffer
  65444. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65445. * @param offset defines offset in the buffer (0 by default)
  65446. * @param size defines the size in floats of attributes (position is 3 for instance)
  65447. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65448. * @param instanced defines if the vertex buffer contains indexed data
  65449. * @param useBytes defines if the offset and stride are in bytes
  65450. * @returns the new vertex buffer
  65451. */
  65452. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65453. /**
  65454. * Gets a boolean indicating if the Buffer is updatable?
  65455. * @returns true if the buffer is updatable
  65456. */
  65457. isUpdatable(): boolean;
  65458. /**
  65459. * Gets current buffer's data
  65460. * @returns a DataArray or null
  65461. */
  65462. getData(): Nullable<DataArray>;
  65463. /**
  65464. * Gets underlying native buffer
  65465. * @returns underlying native buffer
  65466. */
  65467. getBuffer(): Nullable<DataBuffer>;
  65468. /**
  65469. * Gets the stride in float32 units (i.e. byte stride / 4).
  65470. * May not be an integer if the byte stride is not divisible by 4.
  65471. * DEPRECATED. Use byteStride instead.
  65472. * @returns the stride in float32 units
  65473. */
  65474. getStrideSize(): number;
  65475. /**
  65476. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65477. * @param data defines the data to store
  65478. */
  65479. create(data?: Nullable<DataArray>): void;
  65480. /** @hidden */
  65481. _rebuild(): void;
  65482. /**
  65483. * Update current buffer data
  65484. * @param data defines the data to store
  65485. */
  65486. update(data: DataArray): void;
  65487. /**
  65488. * Updates the data directly.
  65489. * @param data the new data
  65490. * @param offset the new offset
  65491. * @param vertexCount the vertex count (optional)
  65492. * @param useBytes set to true if the offset is in bytes
  65493. */
  65494. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65495. /**
  65496. * Release all resources
  65497. */
  65498. dispose(): void;
  65499. }
  65500. /**
  65501. * Specialized buffer used to store vertex data
  65502. */
  65503. export class VertexBuffer {
  65504. /** @hidden */
  65505. _buffer: Buffer;
  65506. private _kind;
  65507. private _size;
  65508. private _ownsBuffer;
  65509. private _instanced;
  65510. private _instanceDivisor;
  65511. /**
  65512. * The byte type.
  65513. */
  65514. static readonly BYTE: number;
  65515. /**
  65516. * The unsigned byte type.
  65517. */
  65518. static readonly UNSIGNED_BYTE: number;
  65519. /**
  65520. * The short type.
  65521. */
  65522. static readonly SHORT: number;
  65523. /**
  65524. * The unsigned short type.
  65525. */
  65526. static readonly UNSIGNED_SHORT: number;
  65527. /**
  65528. * The integer type.
  65529. */
  65530. static readonly INT: number;
  65531. /**
  65532. * The unsigned integer type.
  65533. */
  65534. static readonly UNSIGNED_INT: number;
  65535. /**
  65536. * The float type.
  65537. */
  65538. static readonly FLOAT: number;
  65539. /**
  65540. * Gets or sets the instance divisor when in instanced mode
  65541. */
  65542. instanceDivisor: number;
  65543. /**
  65544. * Gets the byte stride.
  65545. */
  65546. readonly byteStride: number;
  65547. /**
  65548. * Gets the byte offset.
  65549. */
  65550. readonly byteOffset: number;
  65551. /**
  65552. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65553. */
  65554. readonly normalized: boolean;
  65555. /**
  65556. * Gets the data type of each component in the array.
  65557. */
  65558. readonly type: number;
  65559. /**
  65560. * Constructor
  65561. * @param engine the engine
  65562. * @param data the data to use for this vertex buffer
  65563. * @param kind the vertex buffer kind
  65564. * @param updatable whether the data is updatable
  65565. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65566. * @param stride the stride (optional)
  65567. * @param instanced whether the buffer is instanced (optional)
  65568. * @param offset the offset of the data (optional)
  65569. * @param size the number of components (optional)
  65570. * @param type the type of the component (optional)
  65571. * @param normalized whether the data contains normalized data (optional)
  65572. * @param useBytes set to true if stride and offset are in bytes (optional)
  65573. */
  65574. 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);
  65575. /** @hidden */
  65576. _rebuild(): void;
  65577. /**
  65578. * Returns the kind of the VertexBuffer (string)
  65579. * @returns a string
  65580. */
  65581. getKind(): string;
  65582. /**
  65583. * Gets a boolean indicating if the VertexBuffer is updatable?
  65584. * @returns true if the buffer is updatable
  65585. */
  65586. isUpdatable(): boolean;
  65587. /**
  65588. * Gets current buffer's data
  65589. * @returns a DataArray or null
  65590. */
  65591. getData(): Nullable<DataArray>;
  65592. /**
  65593. * Gets underlying native buffer
  65594. * @returns underlying native buffer
  65595. */
  65596. getBuffer(): Nullable<DataBuffer>;
  65597. /**
  65598. * Gets the stride in float32 units (i.e. byte stride / 4).
  65599. * May not be an integer if the byte stride is not divisible by 4.
  65600. * DEPRECATED. Use byteStride instead.
  65601. * @returns the stride in float32 units
  65602. */
  65603. getStrideSize(): number;
  65604. /**
  65605. * Returns the offset as a multiple of the type byte length.
  65606. * DEPRECATED. Use byteOffset instead.
  65607. * @returns the offset in bytes
  65608. */
  65609. getOffset(): number;
  65610. /**
  65611. * Returns the number of components per vertex attribute (integer)
  65612. * @returns the size in float
  65613. */
  65614. getSize(): number;
  65615. /**
  65616. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65617. * @returns true if this buffer is instanced
  65618. */
  65619. getIsInstanced(): boolean;
  65620. /**
  65621. * Returns the instancing divisor, zero for non-instanced (integer).
  65622. * @returns a number
  65623. */
  65624. getInstanceDivisor(): number;
  65625. /**
  65626. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65627. * @param data defines the data to store
  65628. */
  65629. create(data?: DataArray): void;
  65630. /**
  65631. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65632. * This function will create a new buffer if the current one is not updatable
  65633. * @param data defines the data to store
  65634. */
  65635. update(data: DataArray): void;
  65636. /**
  65637. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65638. * Returns the directly updated WebGLBuffer.
  65639. * @param data the new data
  65640. * @param offset the new offset
  65641. * @param useBytes set to true if the offset is in bytes
  65642. */
  65643. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65644. /**
  65645. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65646. */
  65647. dispose(): void;
  65648. /**
  65649. * Enumerates each value of this vertex buffer as numbers.
  65650. * @param count the number of values to enumerate
  65651. * @param callback the callback function called for each value
  65652. */
  65653. forEach(count: number, callback: (value: number, index: number) => void): void;
  65654. /**
  65655. * Positions
  65656. */
  65657. static readonly PositionKind: string;
  65658. /**
  65659. * Normals
  65660. */
  65661. static readonly NormalKind: string;
  65662. /**
  65663. * Tangents
  65664. */
  65665. static readonly TangentKind: string;
  65666. /**
  65667. * Texture coordinates
  65668. */
  65669. static readonly UVKind: string;
  65670. /**
  65671. * Texture coordinates 2
  65672. */
  65673. static readonly UV2Kind: string;
  65674. /**
  65675. * Texture coordinates 3
  65676. */
  65677. static readonly UV3Kind: string;
  65678. /**
  65679. * Texture coordinates 4
  65680. */
  65681. static readonly UV4Kind: string;
  65682. /**
  65683. * Texture coordinates 5
  65684. */
  65685. static readonly UV5Kind: string;
  65686. /**
  65687. * Texture coordinates 6
  65688. */
  65689. static readonly UV6Kind: string;
  65690. /**
  65691. * Colors
  65692. */
  65693. static readonly ColorKind: string;
  65694. /**
  65695. * Matrix indices (for bones)
  65696. */
  65697. static readonly MatricesIndicesKind: string;
  65698. /**
  65699. * Matrix weights (for bones)
  65700. */
  65701. static readonly MatricesWeightsKind: string;
  65702. /**
  65703. * Additional matrix indices (for bones)
  65704. */
  65705. static readonly MatricesIndicesExtraKind: string;
  65706. /**
  65707. * Additional matrix weights (for bones)
  65708. */
  65709. static readonly MatricesWeightsExtraKind: string;
  65710. /**
  65711. * Deduces the stride given a kind.
  65712. * @param kind The kind string to deduce
  65713. * @returns The deduced stride
  65714. */
  65715. static DeduceStride(kind: string): number;
  65716. /**
  65717. * Gets the byte length of the given type.
  65718. * @param type the type
  65719. * @returns the number of bytes
  65720. */
  65721. static GetTypeByteLength(type: number): number;
  65722. /**
  65723. * Enumerates each value of the given parameters as numbers.
  65724. * @param data the data to enumerate
  65725. * @param byteOffset the byte offset of the data
  65726. * @param byteStride the byte stride of the data
  65727. * @param componentCount the number of components per element
  65728. * @param componentType the type of the component
  65729. * @param count the total number of components
  65730. * @param normalized whether the data is normalized
  65731. * @param callback the callback function called for each value
  65732. */
  65733. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65734. private static _GetFloatValue;
  65735. }
  65736. }
  65737. declare module BABYLON {
  65738. /**
  65739. * Class representing spherical harmonics coefficients to the 3rd degree
  65740. */
  65741. export class SphericalHarmonics {
  65742. /**
  65743. * Defines whether or not the harmonics have been prescaled for rendering.
  65744. */
  65745. preScaled: boolean;
  65746. /**
  65747. * The l0,0 coefficients of the spherical harmonics
  65748. */
  65749. l00: Vector3;
  65750. /**
  65751. * The l1,-1 coefficients of the spherical harmonics
  65752. */
  65753. l1_1: Vector3;
  65754. /**
  65755. * The l1,0 coefficients of the spherical harmonics
  65756. */
  65757. l10: Vector3;
  65758. /**
  65759. * The l1,1 coefficients of the spherical harmonics
  65760. */
  65761. l11: Vector3;
  65762. /**
  65763. * The l2,-2 coefficients of the spherical harmonics
  65764. */
  65765. l2_2: Vector3;
  65766. /**
  65767. * The l2,-1 coefficients of the spherical harmonics
  65768. */
  65769. l2_1: Vector3;
  65770. /**
  65771. * The l2,0 coefficients of the spherical harmonics
  65772. */
  65773. l20: Vector3;
  65774. /**
  65775. * The l2,1 coefficients of the spherical harmonics
  65776. */
  65777. l21: Vector3;
  65778. /**
  65779. * The l2,2 coefficients of the spherical harmonics
  65780. */
  65781. l22: Vector3;
  65782. /**
  65783. * Adds a light to the spherical harmonics
  65784. * @param direction the direction of the light
  65785. * @param color the color of the light
  65786. * @param deltaSolidAngle the delta solid angle of the light
  65787. */
  65788. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65789. /**
  65790. * Scales the spherical harmonics by the given amount
  65791. * @param scale the amount to scale
  65792. */
  65793. scaleInPlace(scale: number): void;
  65794. /**
  65795. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65796. *
  65797. * ```
  65798. * E_lm = A_l * L_lm
  65799. * ```
  65800. *
  65801. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65802. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65803. * the scaling factors are given in equation 9.
  65804. */
  65805. convertIncidentRadianceToIrradiance(): void;
  65806. /**
  65807. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65808. *
  65809. * ```
  65810. * L = (1/pi) * E * rho
  65811. * ```
  65812. *
  65813. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65814. */
  65815. convertIrradianceToLambertianRadiance(): void;
  65816. /**
  65817. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65818. * required operations at run time.
  65819. *
  65820. * This is simply done by scaling back the SH with Ylm constants parameter.
  65821. * The trigonometric part being applied by the shader at run time.
  65822. */
  65823. preScaleForRendering(): void;
  65824. /**
  65825. * Constructs a spherical harmonics from an array.
  65826. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65827. * @returns the spherical harmonics
  65828. */
  65829. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65830. /**
  65831. * Gets the spherical harmonics from polynomial
  65832. * @param polynomial the spherical polynomial
  65833. * @returns the spherical harmonics
  65834. */
  65835. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65836. }
  65837. /**
  65838. * Class representing spherical polynomial coefficients to the 3rd degree
  65839. */
  65840. export class SphericalPolynomial {
  65841. private _harmonics;
  65842. /**
  65843. * The spherical harmonics used to create the polynomials.
  65844. */
  65845. readonly preScaledHarmonics: SphericalHarmonics;
  65846. /**
  65847. * The x coefficients of the spherical polynomial
  65848. */
  65849. x: Vector3;
  65850. /**
  65851. * The y coefficients of the spherical polynomial
  65852. */
  65853. y: Vector3;
  65854. /**
  65855. * The z coefficients of the spherical polynomial
  65856. */
  65857. z: Vector3;
  65858. /**
  65859. * The xx coefficients of the spherical polynomial
  65860. */
  65861. xx: Vector3;
  65862. /**
  65863. * The yy coefficients of the spherical polynomial
  65864. */
  65865. yy: Vector3;
  65866. /**
  65867. * The zz coefficients of the spherical polynomial
  65868. */
  65869. zz: Vector3;
  65870. /**
  65871. * The xy coefficients of the spherical polynomial
  65872. */
  65873. xy: Vector3;
  65874. /**
  65875. * The yz coefficients of the spherical polynomial
  65876. */
  65877. yz: Vector3;
  65878. /**
  65879. * The zx coefficients of the spherical polynomial
  65880. */
  65881. zx: Vector3;
  65882. /**
  65883. * Adds an ambient color to the spherical polynomial
  65884. * @param color the color to add
  65885. */
  65886. addAmbient(color: Color3): void;
  65887. /**
  65888. * Scales the spherical polynomial by the given amount
  65889. * @param scale the amount to scale
  65890. */
  65891. scaleInPlace(scale: number): void;
  65892. /**
  65893. * Gets the spherical polynomial from harmonics
  65894. * @param harmonics the spherical harmonics
  65895. * @returns the spherical polynomial
  65896. */
  65897. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65898. /**
  65899. * Constructs a spherical polynomial from an array.
  65900. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65901. * @returns the spherical polynomial
  65902. */
  65903. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65904. }
  65905. }
  65906. declare module BABYLON {
  65907. /**
  65908. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65909. */
  65910. export interface CubeMapInfo {
  65911. /**
  65912. * The pixel array for the front face.
  65913. * This is stored in format, left to right, up to down format.
  65914. */
  65915. front: Nullable<ArrayBufferView>;
  65916. /**
  65917. * The pixel array for the back face.
  65918. * This is stored in format, left to right, up to down format.
  65919. */
  65920. back: Nullable<ArrayBufferView>;
  65921. /**
  65922. * The pixel array for the left face.
  65923. * This is stored in format, left to right, up to down format.
  65924. */
  65925. left: Nullable<ArrayBufferView>;
  65926. /**
  65927. * The pixel array for the right face.
  65928. * This is stored in format, left to right, up to down format.
  65929. */
  65930. right: Nullable<ArrayBufferView>;
  65931. /**
  65932. * The pixel array for the up face.
  65933. * This is stored in format, left to right, up to down format.
  65934. */
  65935. up: Nullable<ArrayBufferView>;
  65936. /**
  65937. * The pixel array for the down face.
  65938. * This is stored in format, left to right, up to down format.
  65939. */
  65940. down: Nullable<ArrayBufferView>;
  65941. /**
  65942. * The size of the cubemap stored.
  65943. *
  65944. * Each faces will be size * size pixels.
  65945. */
  65946. size: number;
  65947. /**
  65948. * The format of the texture.
  65949. *
  65950. * RGBA, RGB.
  65951. */
  65952. format: number;
  65953. /**
  65954. * The type of the texture data.
  65955. *
  65956. * UNSIGNED_INT, FLOAT.
  65957. */
  65958. type: number;
  65959. /**
  65960. * Specifies whether the texture is in gamma space.
  65961. */
  65962. gammaSpace: boolean;
  65963. }
  65964. /**
  65965. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65966. */
  65967. export class PanoramaToCubeMapTools {
  65968. private static FACE_FRONT;
  65969. private static FACE_BACK;
  65970. private static FACE_RIGHT;
  65971. private static FACE_LEFT;
  65972. private static FACE_DOWN;
  65973. private static FACE_UP;
  65974. /**
  65975. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65976. *
  65977. * @param float32Array The source data.
  65978. * @param inputWidth The width of the input panorama.
  65979. * @param inputHeight The height of the input panorama.
  65980. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65981. * @return The cubemap data
  65982. */
  65983. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65984. private static CreateCubemapTexture;
  65985. private static CalcProjectionSpherical;
  65986. }
  65987. }
  65988. declare module BABYLON {
  65989. /**
  65990. * Helper class dealing with the extraction of spherical polynomial dataArray
  65991. * from a cube map.
  65992. */
  65993. export class CubeMapToSphericalPolynomialTools {
  65994. private static FileFaces;
  65995. /**
  65996. * Converts a texture to the according Spherical Polynomial data.
  65997. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65998. *
  65999. * @param texture The texture to extract the information from.
  66000. * @return The Spherical Polynomial data.
  66001. */
  66002. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  66003. /**
  66004. * Converts a cubemap to the according Spherical Polynomial data.
  66005. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66006. *
  66007. * @param cubeInfo The Cube map to extract the information from.
  66008. * @return The Spherical Polynomial data.
  66009. */
  66010. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  66011. }
  66012. }
  66013. declare module BABYLON {
  66014. /**
  66015. * The engine store class is responsible to hold all the instances of Engine and Scene created
  66016. * during the life time of the application.
  66017. */
  66018. export class EngineStore {
  66019. /** Gets the list of created engines */
  66020. static Instances: Engine[];
  66021. /** @hidden */
  66022. static _LastCreatedScene: Nullable<Scene>;
  66023. /**
  66024. * Gets the latest created engine
  66025. */
  66026. static readonly LastCreatedEngine: Nullable<Engine>;
  66027. /**
  66028. * Gets the latest created scene
  66029. */
  66030. static readonly LastCreatedScene: Nullable<Scene>;
  66031. }
  66032. }
  66033. declare module BABYLON {
  66034. /**
  66035. * Define options used to create a render target texture
  66036. */
  66037. export class RenderTargetCreationOptions {
  66038. /**
  66039. * Specifies is mipmaps must be generated
  66040. */
  66041. generateMipMaps?: boolean;
  66042. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66043. generateDepthBuffer?: boolean;
  66044. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66045. generateStencilBuffer?: boolean;
  66046. /** Defines texture type (int by default) */
  66047. type?: number;
  66048. /** Defines sampling mode (trilinear by default) */
  66049. samplingMode?: number;
  66050. /** Defines format (RGBA by default) */
  66051. format?: number;
  66052. }
  66053. }
  66054. declare module BABYLON {
  66055. /**
  66056. * @hidden
  66057. **/
  66058. export class _AlphaState {
  66059. private _isAlphaBlendDirty;
  66060. private _isBlendFunctionParametersDirty;
  66061. private _isBlendEquationParametersDirty;
  66062. private _isBlendConstantsDirty;
  66063. private _alphaBlend;
  66064. private _blendFunctionParameters;
  66065. private _blendEquationParameters;
  66066. private _blendConstants;
  66067. /**
  66068. * Initializes the state.
  66069. */
  66070. constructor();
  66071. readonly isDirty: boolean;
  66072. alphaBlend: boolean;
  66073. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66074. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66075. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66076. reset(): void;
  66077. apply(gl: WebGLRenderingContext): void;
  66078. }
  66079. }
  66080. declare module BABYLON {
  66081. /**
  66082. * @hidden
  66083. **/
  66084. export class _DepthCullingState {
  66085. private _isDepthTestDirty;
  66086. private _isDepthMaskDirty;
  66087. private _isDepthFuncDirty;
  66088. private _isCullFaceDirty;
  66089. private _isCullDirty;
  66090. private _isZOffsetDirty;
  66091. private _isFrontFaceDirty;
  66092. private _depthTest;
  66093. private _depthMask;
  66094. private _depthFunc;
  66095. private _cull;
  66096. private _cullFace;
  66097. private _zOffset;
  66098. private _frontFace;
  66099. /**
  66100. * Initializes the state.
  66101. */
  66102. constructor();
  66103. readonly isDirty: boolean;
  66104. zOffset: number;
  66105. cullFace: Nullable<number>;
  66106. cull: Nullable<boolean>;
  66107. depthFunc: Nullable<number>;
  66108. depthMask: boolean;
  66109. depthTest: boolean;
  66110. frontFace: Nullable<number>;
  66111. reset(): void;
  66112. apply(gl: WebGLRenderingContext): void;
  66113. }
  66114. }
  66115. declare module BABYLON {
  66116. /**
  66117. * @hidden
  66118. **/
  66119. export class _StencilState {
  66120. /** 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 */
  66121. static readonly ALWAYS: number;
  66122. /** Passed to stencilOperation to specify that stencil value must be kept */
  66123. static readonly KEEP: number;
  66124. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66125. static readonly REPLACE: number;
  66126. private _isStencilTestDirty;
  66127. private _isStencilMaskDirty;
  66128. private _isStencilFuncDirty;
  66129. private _isStencilOpDirty;
  66130. private _stencilTest;
  66131. private _stencilMask;
  66132. private _stencilFunc;
  66133. private _stencilFuncRef;
  66134. private _stencilFuncMask;
  66135. private _stencilOpStencilFail;
  66136. private _stencilOpDepthFail;
  66137. private _stencilOpStencilDepthPass;
  66138. readonly isDirty: boolean;
  66139. stencilFunc: number;
  66140. stencilFuncRef: number;
  66141. stencilFuncMask: number;
  66142. stencilOpStencilFail: number;
  66143. stencilOpDepthFail: number;
  66144. stencilOpStencilDepthPass: number;
  66145. stencilMask: number;
  66146. stencilTest: boolean;
  66147. constructor();
  66148. reset(): void;
  66149. apply(gl: WebGLRenderingContext): void;
  66150. }
  66151. }
  66152. declare module BABYLON {
  66153. /**
  66154. * @hidden
  66155. **/
  66156. export class _TimeToken {
  66157. _startTimeQuery: Nullable<WebGLQuery>;
  66158. _endTimeQuery: Nullable<WebGLQuery>;
  66159. _timeElapsedQuery: Nullable<WebGLQuery>;
  66160. _timeElapsedQueryEnded: boolean;
  66161. }
  66162. }
  66163. declare module BABYLON {
  66164. /**
  66165. * Class used to store data associated with WebGL texture data for the engine
  66166. * This class should not be used directly
  66167. */
  66168. export class InternalTexture {
  66169. /** hidden */
  66170. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66171. /**
  66172. * The source of the texture data is unknown
  66173. */
  66174. static DATASOURCE_UNKNOWN: number;
  66175. /**
  66176. * Texture data comes from an URL
  66177. */
  66178. static DATASOURCE_URL: number;
  66179. /**
  66180. * Texture data is only used for temporary storage
  66181. */
  66182. static DATASOURCE_TEMP: number;
  66183. /**
  66184. * Texture data comes from raw data (ArrayBuffer)
  66185. */
  66186. static DATASOURCE_RAW: number;
  66187. /**
  66188. * Texture content is dynamic (video or dynamic texture)
  66189. */
  66190. static DATASOURCE_DYNAMIC: number;
  66191. /**
  66192. * Texture content is generated by rendering to it
  66193. */
  66194. static DATASOURCE_RENDERTARGET: number;
  66195. /**
  66196. * Texture content is part of a multi render target process
  66197. */
  66198. static DATASOURCE_MULTIRENDERTARGET: number;
  66199. /**
  66200. * Texture data comes from a cube data file
  66201. */
  66202. static DATASOURCE_CUBE: number;
  66203. /**
  66204. * Texture data comes from a raw cube data
  66205. */
  66206. static DATASOURCE_CUBERAW: number;
  66207. /**
  66208. * Texture data come from a prefiltered cube data file
  66209. */
  66210. static DATASOURCE_CUBEPREFILTERED: number;
  66211. /**
  66212. * Texture content is raw 3D data
  66213. */
  66214. static DATASOURCE_RAW3D: number;
  66215. /**
  66216. * Texture content is a depth texture
  66217. */
  66218. static DATASOURCE_DEPTHTEXTURE: number;
  66219. /**
  66220. * Texture data comes from a raw cube data encoded with RGBD
  66221. */
  66222. static DATASOURCE_CUBERAW_RGBD: number;
  66223. /**
  66224. * Defines if the texture is ready
  66225. */
  66226. isReady: boolean;
  66227. /**
  66228. * Defines if the texture is a cube texture
  66229. */
  66230. isCube: boolean;
  66231. /**
  66232. * Defines if the texture contains 3D data
  66233. */
  66234. is3D: boolean;
  66235. /**
  66236. * Defines if the texture contains multiview data
  66237. */
  66238. isMultiview: boolean;
  66239. /**
  66240. * Gets the URL used to load this texture
  66241. */
  66242. url: string;
  66243. /**
  66244. * Gets the sampling mode of the texture
  66245. */
  66246. samplingMode: number;
  66247. /**
  66248. * Gets a boolean indicating if the texture needs mipmaps generation
  66249. */
  66250. generateMipMaps: boolean;
  66251. /**
  66252. * Gets the number of samples used by the texture (WebGL2+ only)
  66253. */
  66254. samples: number;
  66255. /**
  66256. * Gets the type of the texture (int, float...)
  66257. */
  66258. type: number;
  66259. /**
  66260. * Gets the format of the texture (RGB, RGBA...)
  66261. */
  66262. format: number;
  66263. /**
  66264. * Observable called when the texture is loaded
  66265. */
  66266. onLoadedObservable: Observable<InternalTexture>;
  66267. /**
  66268. * Gets the width of the texture
  66269. */
  66270. width: number;
  66271. /**
  66272. * Gets the height of the texture
  66273. */
  66274. height: number;
  66275. /**
  66276. * Gets the depth of the texture
  66277. */
  66278. depth: number;
  66279. /**
  66280. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66281. */
  66282. baseWidth: number;
  66283. /**
  66284. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66285. */
  66286. baseHeight: number;
  66287. /**
  66288. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66289. */
  66290. baseDepth: number;
  66291. /**
  66292. * Gets a boolean indicating if the texture is inverted on Y axis
  66293. */
  66294. invertY: boolean;
  66295. /** @hidden */
  66296. _invertVScale: boolean;
  66297. /** @hidden */
  66298. _associatedChannel: number;
  66299. /** @hidden */
  66300. _dataSource: number;
  66301. /** @hidden */
  66302. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66303. /** @hidden */
  66304. _bufferView: Nullable<ArrayBufferView>;
  66305. /** @hidden */
  66306. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66307. /** @hidden */
  66308. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66309. /** @hidden */
  66310. _size: number;
  66311. /** @hidden */
  66312. _extension: string;
  66313. /** @hidden */
  66314. _files: Nullable<string[]>;
  66315. /** @hidden */
  66316. _workingCanvas: Nullable<HTMLCanvasElement>;
  66317. /** @hidden */
  66318. _workingContext: Nullable<CanvasRenderingContext2D>;
  66319. /** @hidden */
  66320. _framebuffer: Nullable<WebGLFramebuffer>;
  66321. /** @hidden */
  66322. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66323. /** @hidden */
  66324. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66325. /** @hidden */
  66326. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66327. /** @hidden */
  66328. _attachments: Nullable<number[]>;
  66329. /** @hidden */
  66330. _cachedCoordinatesMode: Nullable<number>;
  66331. /** @hidden */
  66332. _cachedWrapU: Nullable<number>;
  66333. /** @hidden */
  66334. _cachedWrapV: Nullable<number>;
  66335. /** @hidden */
  66336. _cachedWrapR: Nullable<number>;
  66337. /** @hidden */
  66338. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66339. /** @hidden */
  66340. _isDisabled: boolean;
  66341. /** @hidden */
  66342. _compression: Nullable<string>;
  66343. /** @hidden */
  66344. _generateStencilBuffer: boolean;
  66345. /** @hidden */
  66346. _generateDepthBuffer: boolean;
  66347. /** @hidden */
  66348. _comparisonFunction: number;
  66349. /** @hidden */
  66350. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66351. /** @hidden */
  66352. _lodGenerationScale: number;
  66353. /** @hidden */
  66354. _lodGenerationOffset: number;
  66355. /** @hidden */
  66356. _colorTextureArray: Nullable<WebGLTexture>;
  66357. /** @hidden */
  66358. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66359. /** @hidden */
  66360. _lodTextureHigh: Nullable<BaseTexture>;
  66361. /** @hidden */
  66362. _lodTextureMid: Nullable<BaseTexture>;
  66363. /** @hidden */
  66364. _lodTextureLow: Nullable<BaseTexture>;
  66365. /** @hidden */
  66366. _isRGBD: boolean;
  66367. /** @hidden */
  66368. _webGLTexture: Nullable<WebGLTexture>;
  66369. /** @hidden */
  66370. _references: number;
  66371. private _engine;
  66372. /**
  66373. * Gets the Engine the texture belongs to.
  66374. * @returns The babylon engine
  66375. */
  66376. getEngine(): Engine;
  66377. /**
  66378. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66379. */
  66380. readonly dataSource: number;
  66381. /**
  66382. * Creates a new InternalTexture
  66383. * @param engine defines the engine to use
  66384. * @param dataSource defines the type of data that will be used
  66385. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66386. */
  66387. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66388. /**
  66389. * Increments the number of references (ie. the number of Texture that point to it)
  66390. */
  66391. incrementReferences(): void;
  66392. /**
  66393. * Change the size of the texture (not the size of the content)
  66394. * @param width defines the new width
  66395. * @param height defines the new height
  66396. * @param depth defines the new depth (1 by default)
  66397. */
  66398. updateSize(width: int, height: int, depth?: int): void;
  66399. /** @hidden */
  66400. _rebuild(): void;
  66401. /** @hidden */
  66402. _swapAndDie(target: InternalTexture): void;
  66403. /**
  66404. * Dispose the current allocated resources
  66405. */
  66406. dispose(): void;
  66407. }
  66408. }
  66409. declare module BABYLON {
  66410. /**
  66411. * This represents the main contract an easing function should follow.
  66412. * Easing functions are used throughout the animation system.
  66413. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66414. */
  66415. export interface IEasingFunction {
  66416. /**
  66417. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66418. * of the easing function.
  66419. * The link below provides some of the most common examples of easing functions.
  66420. * @see https://easings.net/
  66421. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66422. * @returns the corresponding value on the curve defined by the easing function
  66423. */
  66424. ease(gradient: number): number;
  66425. }
  66426. /**
  66427. * Base class used for every default easing function.
  66428. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66429. */
  66430. export class EasingFunction implements IEasingFunction {
  66431. /**
  66432. * Interpolation follows the mathematical formula associated with the easing function.
  66433. */
  66434. static readonly EASINGMODE_EASEIN: number;
  66435. /**
  66436. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66437. */
  66438. static readonly EASINGMODE_EASEOUT: number;
  66439. /**
  66440. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66441. */
  66442. static readonly EASINGMODE_EASEINOUT: number;
  66443. private _easingMode;
  66444. /**
  66445. * Sets the easing mode of the current function.
  66446. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66447. */
  66448. setEasingMode(easingMode: number): void;
  66449. /**
  66450. * Gets the current easing mode.
  66451. * @returns the easing mode
  66452. */
  66453. getEasingMode(): number;
  66454. /**
  66455. * @hidden
  66456. */
  66457. easeInCore(gradient: number): number;
  66458. /**
  66459. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66460. * of the easing function.
  66461. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66462. * @returns the corresponding value on the curve defined by the easing function
  66463. */
  66464. ease(gradient: number): number;
  66465. }
  66466. /**
  66467. * Easing function with a circle shape (see link below).
  66468. * @see https://easings.net/#easeInCirc
  66469. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66470. */
  66471. export class CircleEase extends EasingFunction implements IEasingFunction {
  66472. /** @hidden */
  66473. easeInCore(gradient: number): number;
  66474. }
  66475. /**
  66476. * Easing function with a ease back shape (see link below).
  66477. * @see https://easings.net/#easeInBack
  66478. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66479. */
  66480. export class BackEase extends EasingFunction implements IEasingFunction {
  66481. /** Defines the amplitude of the function */
  66482. amplitude: number;
  66483. /**
  66484. * Instantiates a back ease easing
  66485. * @see https://easings.net/#easeInBack
  66486. * @param amplitude Defines the amplitude of the function
  66487. */
  66488. constructor(
  66489. /** Defines the amplitude of the function */
  66490. amplitude?: number);
  66491. /** @hidden */
  66492. easeInCore(gradient: number): number;
  66493. }
  66494. /**
  66495. * Easing function with a bouncing shape (see link below).
  66496. * @see https://easings.net/#easeInBounce
  66497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66498. */
  66499. export class BounceEase extends EasingFunction implements IEasingFunction {
  66500. /** Defines the number of bounces */
  66501. bounces: number;
  66502. /** Defines the amplitude of the bounce */
  66503. bounciness: number;
  66504. /**
  66505. * Instantiates a bounce easing
  66506. * @see https://easings.net/#easeInBounce
  66507. * @param bounces Defines the number of bounces
  66508. * @param bounciness Defines the amplitude of the bounce
  66509. */
  66510. constructor(
  66511. /** Defines the number of bounces */
  66512. bounces?: number,
  66513. /** Defines the amplitude of the bounce */
  66514. bounciness?: number);
  66515. /** @hidden */
  66516. easeInCore(gradient: number): number;
  66517. }
  66518. /**
  66519. * Easing function with a power of 3 shape (see link below).
  66520. * @see https://easings.net/#easeInCubic
  66521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66522. */
  66523. export class CubicEase extends EasingFunction implements IEasingFunction {
  66524. /** @hidden */
  66525. easeInCore(gradient: number): number;
  66526. }
  66527. /**
  66528. * Easing function with an elastic shape (see link below).
  66529. * @see https://easings.net/#easeInElastic
  66530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66531. */
  66532. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66533. /** Defines the number of oscillations*/
  66534. oscillations: number;
  66535. /** Defines the amplitude of the oscillations*/
  66536. springiness: number;
  66537. /**
  66538. * Instantiates an elastic easing function
  66539. * @see https://easings.net/#easeInElastic
  66540. * @param oscillations Defines the number of oscillations
  66541. * @param springiness Defines the amplitude of the oscillations
  66542. */
  66543. constructor(
  66544. /** Defines the number of oscillations*/
  66545. oscillations?: number,
  66546. /** Defines the amplitude of the oscillations*/
  66547. springiness?: number);
  66548. /** @hidden */
  66549. easeInCore(gradient: number): number;
  66550. }
  66551. /**
  66552. * Easing function with an exponential shape (see link below).
  66553. * @see https://easings.net/#easeInExpo
  66554. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66555. */
  66556. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66557. /** Defines the exponent of the function */
  66558. exponent: number;
  66559. /**
  66560. * Instantiates an exponential easing function
  66561. * @see https://easings.net/#easeInExpo
  66562. * @param exponent Defines the exponent of the function
  66563. */
  66564. constructor(
  66565. /** Defines the exponent of the function */
  66566. exponent?: number);
  66567. /** @hidden */
  66568. easeInCore(gradient: number): number;
  66569. }
  66570. /**
  66571. * Easing function with a power shape (see link below).
  66572. * @see https://easings.net/#easeInQuad
  66573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66574. */
  66575. export class PowerEase extends EasingFunction implements IEasingFunction {
  66576. /** Defines the power of the function */
  66577. power: number;
  66578. /**
  66579. * Instantiates an power base easing function
  66580. * @see https://easings.net/#easeInQuad
  66581. * @param power Defines the power of the function
  66582. */
  66583. constructor(
  66584. /** Defines the power of the function */
  66585. power?: number);
  66586. /** @hidden */
  66587. easeInCore(gradient: number): number;
  66588. }
  66589. /**
  66590. * Easing function with a power of 2 shape (see link below).
  66591. * @see https://easings.net/#easeInQuad
  66592. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66593. */
  66594. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66595. /** @hidden */
  66596. easeInCore(gradient: number): number;
  66597. }
  66598. /**
  66599. * Easing function with a power of 4 shape (see link below).
  66600. * @see https://easings.net/#easeInQuart
  66601. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66602. */
  66603. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66604. /** @hidden */
  66605. easeInCore(gradient: number): number;
  66606. }
  66607. /**
  66608. * Easing function with a power of 5 shape (see link below).
  66609. * @see https://easings.net/#easeInQuint
  66610. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66611. */
  66612. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66613. /** @hidden */
  66614. easeInCore(gradient: number): number;
  66615. }
  66616. /**
  66617. * Easing function with a sin shape (see link below).
  66618. * @see https://easings.net/#easeInSine
  66619. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66620. */
  66621. export class SineEase extends EasingFunction implements IEasingFunction {
  66622. /** @hidden */
  66623. easeInCore(gradient: number): number;
  66624. }
  66625. /**
  66626. * Easing function with a bezier shape (see link below).
  66627. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66628. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66629. */
  66630. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66631. /** Defines the x component of the start tangent in the bezier curve */
  66632. x1: number;
  66633. /** Defines the y component of the start tangent in the bezier curve */
  66634. y1: number;
  66635. /** Defines the x component of the end tangent in the bezier curve */
  66636. x2: number;
  66637. /** Defines the y component of the end tangent in the bezier curve */
  66638. y2: number;
  66639. /**
  66640. * Instantiates a bezier function
  66641. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66642. * @param x1 Defines the x component of the start tangent in the bezier curve
  66643. * @param y1 Defines the y component of the start tangent in the bezier curve
  66644. * @param x2 Defines the x component of the end tangent in the bezier curve
  66645. * @param y2 Defines the y component of the end tangent in the bezier curve
  66646. */
  66647. constructor(
  66648. /** Defines the x component of the start tangent in the bezier curve */
  66649. x1?: number,
  66650. /** Defines the y component of the start tangent in the bezier curve */
  66651. y1?: number,
  66652. /** Defines the x component of the end tangent in the bezier curve */
  66653. x2?: number,
  66654. /** Defines the y component of the end tangent in the bezier curve */
  66655. y2?: number);
  66656. /** @hidden */
  66657. easeInCore(gradient: number): number;
  66658. }
  66659. }
  66660. declare module BABYLON {
  66661. /**
  66662. * Defines an interface which represents an animation key frame
  66663. */
  66664. export interface IAnimationKey {
  66665. /**
  66666. * Frame of the key frame
  66667. */
  66668. frame: number;
  66669. /**
  66670. * Value at the specifies key frame
  66671. */
  66672. value: any;
  66673. /**
  66674. * The input tangent for the cubic hermite spline
  66675. */
  66676. inTangent?: any;
  66677. /**
  66678. * The output tangent for the cubic hermite spline
  66679. */
  66680. outTangent?: any;
  66681. /**
  66682. * The animation interpolation type
  66683. */
  66684. interpolation?: AnimationKeyInterpolation;
  66685. }
  66686. /**
  66687. * Enum for the animation key frame interpolation type
  66688. */
  66689. export enum AnimationKeyInterpolation {
  66690. /**
  66691. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66692. */
  66693. STEP = 1
  66694. }
  66695. }
  66696. declare module BABYLON {
  66697. /**
  66698. * Represents the range of an animation
  66699. */
  66700. export class AnimationRange {
  66701. /**The name of the animation range**/
  66702. name: string;
  66703. /**The starting frame of the animation */
  66704. from: number;
  66705. /**The ending frame of the animation*/
  66706. to: number;
  66707. /**
  66708. * Initializes the range of an animation
  66709. * @param name The name of the animation range
  66710. * @param from The starting frame of the animation
  66711. * @param to The ending frame of the animation
  66712. */
  66713. constructor(
  66714. /**The name of the animation range**/
  66715. name: string,
  66716. /**The starting frame of the animation */
  66717. from: number,
  66718. /**The ending frame of the animation*/
  66719. to: number);
  66720. /**
  66721. * Makes a copy of the animation range
  66722. * @returns A copy of the animation range
  66723. */
  66724. clone(): AnimationRange;
  66725. }
  66726. }
  66727. declare module BABYLON {
  66728. /**
  66729. * Composed of a frame, and an action function
  66730. */
  66731. export class AnimationEvent {
  66732. /** The frame for which the event is triggered **/
  66733. frame: number;
  66734. /** The event to perform when triggered **/
  66735. action: (currentFrame: number) => void;
  66736. /** Specifies if the event should be triggered only once**/
  66737. onlyOnce?: boolean | undefined;
  66738. /**
  66739. * Specifies if the animation event is done
  66740. */
  66741. isDone: boolean;
  66742. /**
  66743. * Initializes the animation event
  66744. * @param frame The frame for which the event is triggered
  66745. * @param action The event to perform when triggered
  66746. * @param onlyOnce Specifies if the event should be triggered only once
  66747. */
  66748. constructor(
  66749. /** The frame for which the event is triggered **/
  66750. frame: number,
  66751. /** The event to perform when triggered **/
  66752. action: (currentFrame: number) => void,
  66753. /** Specifies if the event should be triggered only once**/
  66754. onlyOnce?: boolean | undefined);
  66755. /** @hidden */
  66756. _clone(): AnimationEvent;
  66757. }
  66758. }
  66759. declare module BABYLON {
  66760. /**
  66761. * Interface used to define a behavior
  66762. */
  66763. export interface Behavior<T> {
  66764. /** gets or sets behavior's name */
  66765. name: string;
  66766. /**
  66767. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66768. */
  66769. init(): void;
  66770. /**
  66771. * Called when the behavior is attached to a target
  66772. * @param target defines the target where the behavior is attached to
  66773. */
  66774. attach(target: T): void;
  66775. /**
  66776. * Called when the behavior is detached from its target
  66777. */
  66778. detach(): void;
  66779. }
  66780. /**
  66781. * Interface implemented by classes supporting behaviors
  66782. */
  66783. export interface IBehaviorAware<T> {
  66784. /**
  66785. * Attach a behavior
  66786. * @param behavior defines the behavior to attach
  66787. * @returns the current host
  66788. */
  66789. addBehavior(behavior: Behavior<T>): T;
  66790. /**
  66791. * Remove a behavior from the current object
  66792. * @param behavior defines the behavior to detach
  66793. * @returns the current host
  66794. */
  66795. removeBehavior(behavior: Behavior<T>): T;
  66796. /**
  66797. * Gets a behavior using its name to search
  66798. * @param name defines the name to search
  66799. * @returns the behavior or null if not found
  66800. */
  66801. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66802. }
  66803. }
  66804. declare module BABYLON {
  66805. /**
  66806. * @hidden
  66807. */
  66808. export class IntersectionInfo {
  66809. bu: Nullable<number>;
  66810. bv: Nullable<number>;
  66811. distance: number;
  66812. faceId: number;
  66813. subMeshId: number;
  66814. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66815. }
  66816. }
  66817. declare module BABYLON {
  66818. /**
  66819. * Class used to store bounding sphere information
  66820. */
  66821. export class BoundingSphere {
  66822. /**
  66823. * Gets the center of the bounding sphere in local space
  66824. */
  66825. readonly center: Vector3;
  66826. /**
  66827. * Radius of the bounding sphere in local space
  66828. */
  66829. radius: number;
  66830. /**
  66831. * Gets the center of the bounding sphere in world space
  66832. */
  66833. readonly centerWorld: Vector3;
  66834. /**
  66835. * Radius of the bounding sphere in world space
  66836. */
  66837. radiusWorld: number;
  66838. /**
  66839. * Gets the minimum vector in local space
  66840. */
  66841. readonly minimum: Vector3;
  66842. /**
  66843. * Gets the maximum vector in local space
  66844. */
  66845. readonly maximum: Vector3;
  66846. private _worldMatrix;
  66847. private static readonly TmpVector3;
  66848. /**
  66849. * Creates a new bounding sphere
  66850. * @param min defines the minimum vector (in local space)
  66851. * @param max defines the maximum vector (in local space)
  66852. * @param worldMatrix defines the new world matrix
  66853. */
  66854. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66855. /**
  66856. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66857. * @param min defines the new minimum vector (in local space)
  66858. * @param max defines the new maximum vector (in local space)
  66859. * @param worldMatrix defines the new world matrix
  66860. */
  66861. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66862. /**
  66863. * Scale the current bounding sphere by applying a scale factor
  66864. * @param factor defines the scale factor to apply
  66865. * @returns the current bounding box
  66866. */
  66867. scale(factor: number): BoundingSphere;
  66868. /**
  66869. * Gets the world matrix of the bounding box
  66870. * @returns a matrix
  66871. */
  66872. getWorldMatrix(): DeepImmutable<Matrix>;
  66873. /** @hidden */
  66874. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66875. /**
  66876. * Tests if the bounding sphere is intersecting the frustum planes
  66877. * @param frustumPlanes defines the frustum planes to test
  66878. * @returns true if there is an intersection
  66879. */
  66880. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66881. /**
  66882. * Tests if the bounding sphere center is in between the frustum planes.
  66883. * Used for optimistic fast inclusion.
  66884. * @param frustumPlanes defines the frustum planes to test
  66885. * @returns true if the sphere center is in between the frustum planes
  66886. */
  66887. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66888. /**
  66889. * Tests if a point is inside the bounding sphere
  66890. * @param point defines the point to test
  66891. * @returns true if the point is inside the bounding sphere
  66892. */
  66893. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66894. /**
  66895. * Checks if two sphere intersct
  66896. * @param sphere0 sphere 0
  66897. * @param sphere1 sphere 1
  66898. * @returns true if the speres intersect
  66899. */
  66900. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66901. }
  66902. }
  66903. declare module BABYLON {
  66904. /**
  66905. * Class used to store bounding box information
  66906. */
  66907. export class BoundingBox implements ICullable {
  66908. /**
  66909. * Gets the 8 vectors representing the bounding box in local space
  66910. */
  66911. readonly vectors: Vector3[];
  66912. /**
  66913. * Gets the center of the bounding box in local space
  66914. */
  66915. readonly center: Vector3;
  66916. /**
  66917. * Gets the center of the bounding box in world space
  66918. */
  66919. readonly centerWorld: Vector3;
  66920. /**
  66921. * Gets the extend size in local space
  66922. */
  66923. readonly extendSize: Vector3;
  66924. /**
  66925. * Gets the extend size in world space
  66926. */
  66927. readonly extendSizeWorld: Vector3;
  66928. /**
  66929. * Gets the OBB (object bounding box) directions
  66930. */
  66931. readonly directions: Vector3[];
  66932. /**
  66933. * Gets the 8 vectors representing the bounding box in world space
  66934. */
  66935. readonly vectorsWorld: Vector3[];
  66936. /**
  66937. * Gets the minimum vector in world space
  66938. */
  66939. readonly minimumWorld: Vector3;
  66940. /**
  66941. * Gets the maximum vector in world space
  66942. */
  66943. readonly maximumWorld: Vector3;
  66944. /**
  66945. * Gets the minimum vector in local space
  66946. */
  66947. readonly minimum: Vector3;
  66948. /**
  66949. * Gets the maximum vector in local space
  66950. */
  66951. readonly maximum: Vector3;
  66952. private _worldMatrix;
  66953. private static readonly TmpVector3;
  66954. /**
  66955. * @hidden
  66956. */
  66957. _tag: number;
  66958. /**
  66959. * Creates a new bounding box
  66960. * @param min defines the minimum vector (in local space)
  66961. * @param max defines the maximum vector (in local space)
  66962. * @param worldMatrix defines the new world matrix
  66963. */
  66964. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66965. /**
  66966. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66967. * @param min defines the new minimum vector (in local space)
  66968. * @param max defines the new maximum vector (in local space)
  66969. * @param worldMatrix defines the new world matrix
  66970. */
  66971. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66972. /**
  66973. * Scale the current bounding box by applying a scale factor
  66974. * @param factor defines the scale factor to apply
  66975. * @returns the current bounding box
  66976. */
  66977. scale(factor: number): BoundingBox;
  66978. /**
  66979. * Gets the world matrix of the bounding box
  66980. * @returns a matrix
  66981. */
  66982. getWorldMatrix(): DeepImmutable<Matrix>;
  66983. /** @hidden */
  66984. _update(world: DeepImmutable<Matrix>): void;
  66985. /**
  66986. * Tests if the bounding box is intersecting the frustum planes
  66987. * @param frustumPlanes defines the frustum planes to test
  66988. * @returns true if there is an intersection
  66989. */
  66990. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66991. /**
  66992. * Tests if the bounding box is entirely inside the frustum planes
  66993. * @param frustumPlanes defines the frustum planes to test
  66994. * @returns true if there is an inclusion
  66995. */
  66996. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66997. /**
  66998. * Tests if a point is inside the bounding box
  66999. * @param point defines the point to test
  67000. * @returns true if the point is inside the bounding box
  67001. */
  67002. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67003. /**
  67004. * Tests if the bounding box intersects with a bounding sphere
  67005. * @param sphere defines the sphere to test
  67006. * @returns true if there is an intersection
  67007. */
  67008. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  67009. /**
  67010. * Tests if the bounding box intersects with a box defined by a min and max vectors
  67011. * @param min defines the min vector to use
  67012. * @param max defines the max vector to use
  67013. * @returns true if there is an intersection
  67014. */
  67015. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  67016. /**
  67017. * Tests if two bounding boxes are intersections
  67018. * @param box0 defines the first box to test
  67019. * @param box1 defines the second box to test
  67020. * @returns true if there is an intersection
  67021. */
  67022. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  67023. /**
  67024. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  67025. * @param minPoint defines the minimum vector of the bounding box
  67026. * @param maxPoint defines the maximum vector of the bounding box
  67027. * @param sphereCenter defines the sphere center
  67028. * @param sphereRadius defines the sphere radius
  67029. * @returns true if there is an intersection
  67030. */
  67031. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67032. /**
  67033. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67034. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67035. * @param frustumPlanes defines the frustum planes to test
  67036. * @return true if there is an inclusion
  67037. */
  67038. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67039. /**
  67040. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67041. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67042. * @param frustumPlanes defines the frustum planes to test
  67043. * @return true if there is an intersection
  67044. */
  67045. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67046. }
  67047. }
  67048. declare module BABYLON {
  67049. /** @hidden */
  67050. export class Collider {
  67051. /** Define if a collision was found */
  67052. collisionFound: boolean;
  67053. /**
  67054. * Define last intersection point in local space
  67055. */
  67056. intersectionPoint: Vector3;
  67057. /**
  67058. * Define last collided mesh
  67059. */
  67060. collidedMesh: Nullable<AbstractMesh>;
  67061. private _collisionPoint;
  67062. private _planeIntersectionPoint;
  67063. private _tempVector;
  67064. private _tempVector2;
  67065. private _tempVector3;
  67066. private _tempVector4;
  67067. private _edge;
  67068. private _baseToVertex;
  67069. private _destinationPoint;
  67070. private _slidePlaneNormal;
  67071. private _displacementVector;
  67072. /** @hidden */
  67073. _radius: Vector3;
  67074. /** @hidden */
  67075. _retry: number;
  67076. private _velocity;
  67077. private _basePoint;
  67078. private _epsilon;
  67079. /** @hidden */
  67080. _velocityWorldLength: number;
  67081. /** @hidden */
  67082. _basePointWorld: Vector3;
  67083. private _velocityWorld;
  67084. private _normalizedVelocity;
  67085. /** @hidden */
  67086. _initialVelocity: Vector3;
  67087. /** @hidden */
  67088. _initialPosition: Vector3;
  67089. private _nearestDistance;
  67090. private _collisionMask;
  67091. collisionMask: number;
  67092. /**
  67093. * Gets the plane normal used to compute the sliding response (in local space)
  67094. */
  67095. readonly slidePlaneNormal: Vector3;
  67096. /** @hidden */
  67097. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67098. /** @hidden */
  67099. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67100. /** @hidden */
  67101. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67102. /** @hidden */
  67103. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67104. /** @hidden */
  67105. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67106. /** @hidden */
  67107. _getResponse(pos: Vector3, vel: Vector3): void;
  67108. }
  67109. }
  67110. declare module BABYLON {
  67111. /**
  67112. * Interface for cullable objects
  67113. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67114. */
  67115. export interface ICullable {
  67116. /**
  67117. * Checks if the object or part of the object is in the frustum
  67118. * @param frustumPlanes Camera near/planes
  67119. * @returns true if the object is in frustum otherwise false
  67120. */
  67121. isInFrustum(frustumPlanes: Plane[]): boolean;
  67122. /**
  67123. * Checks if a cullable object (mesh...) is in the camera frustum
  67124. * Unlike isInFrustum this cheks the full bounding box
  67125. * @param frustumPlanes Camera near/planes
  67126. * @returns true if the object is in frustum otherwise false
  67127. */
  67128. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67129. }
  67130. /**
  67131. * Info for a bounding data of a mesh
  67132. */
  67133. export class BoundingInfo implements ICullable {
  67134. /**
  67135. * Bounding box for the mesh
  67136. */
  67137. readonly boundingBox: BoundingBox;
  67138. /**
  67139. * Bounding sphere for the mesh
  67140. */
  67141. readonly boundingSphere: BoundingSphere;
  67142. private _isLocked;
  67143. private static readonly TmpVector3;
  67144. /**
  67145. * Constructs bounding info
  67146. * @param minimum min vector of the bounding box/sphere
  67147. * @param maximum max vector of the bounding box/sphere
  67148. * @param worldMatrix defines the new world matrix
  67149. */
  67150. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67151. /**
  67152. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67153. * @param min defines the new minimum vector (in local space)
  67154. * @param max defines the new maximum vector (in local space)
  67155. * @param worldMatrix defines the new world matrix
  67156. */
  67157. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67158. /**
  67159. * min vector of the bounding box/sphere
  67160. */
  67161. readonly minimum: Vector3;
  67162. /**
  67163. * max vector of the bounding box/sphere
  67164. */
  67165. readonly maximum: Vector3;
  67166. /**
  67167. * If the info is locked and won't be updated to avoid perf overhead
  67168. */
  67169. isLocked: boolean;
  67170. /**
  67171. * Updates the bounding sphere and box
  67172. * @param world world matrix to be used to update
  67173. */
  67174. update(world: DeepImmutable<Matrix>): void;
  67175. /**
  67176. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67177. * @param center New center of the bounding info
  67178. * @param extend New extend of the bounding info
  67179. * @returns the current bounding info
  67180. */
  67181. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67182. /**
  67183. * Scale the current bounding info by applying a scale factor
  67184. * @param factor defines the scale factor to apply
  67185. * @returns the current bounding info
  67186. */
  67187. scale(factor: number): BoundingInfo;
  67188. /**
  67189. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67190. * @param frustumPlanes defines the frustum to test
  67191. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67192. * @returns true if the bounding info is in the frustum planes
  67193. */
  67194. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67195. /**
  67196. * Gets the world distance between the min and max points of the bounding box
  67197. */
  67198. readonly diagonalLength: number;
  67199. /**
  67200. * Checks if a cullable object (mesh...) is in the camera frustum
  67201. * Unlike isInFrustum this cheks the full bounding box
  67202. * @param frustumPlanes Camera near/planes
  67203. * @returns true if the object is in frustum otherwise false
  67204. */
  67205. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67206. /** @hidden */
  67207. _checkCollision(collider: Collider): boolean;
  67208. /**
  67209. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67210. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67211. * @param point the point to check intersection with
  67212. * @returns if the point intersects
  67213. */
  67214. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67215. /**
  67216. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67217. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67218. * @param boundingInfo the bounding info to check intersection with
  67219. * @param precise if the intersection should be done using OBB
  67220. * @returns if the bounding info intersects
  67221. */
  67222. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67223. }
  67224. }
  67225. declare module BABYLON {
  67226. /**
  67227. * Defines an array and its length.
  67228. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67229. */
  67230. export interface ISmartArrayLike<T> {
  67231. /**
  67232. * The data of the array.
  67233. */
  67234. data: Array<T>;
  67235. /**
  67236. * The active length of the array.
  67237. */
  67238. length: number;
  67239. }
  67240. /**
  67241. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67242. */
  67243. export class SmartArray<T> implements ISmartArrayLike<T> {
  67244. /**
  67245. * The full set of data from the array.
  67246. */
  67247. data: Array<T>;
  67248. /**
  67249. * The active length of the array.
  67250. */
  67251. length: number;
  67252. protected _id: number;
  67253. /**
  67254. * Instantiates a Smart Array.
  67255. * @param capacity defines the default capacity of the array.
  67256. */
  67257. constructor(capacity: number);
  67258. /**
  67259. * Pushes a value at the end of the active data.
  67260. * @param value defines the object to push in the array.
  67261. */
  67262. push(value: T): void;
  67263. /**
  67264. * Iterates over the active data and apply the lambda to them.
  67265. * @param func defines the action to apply on each value.
  67266. */
  67267. forEach(func: (content: T) => void): void;
  67268. /**
  67269. * Sorts the full sets of data.
  67270. * @param compareFn defines the comparison function to apply.
  67271. */
  67272. sort(compareFn: (a: T, b: T) => number): void;
  67273. /**
  67274. * Resets the active data to an empty array.
  67275. */
  67276. reset(): void;
  67277. /**
  67278. * Releases all the data from the array as well as the array.
  67279. */
  67280. dispose(): void;
  67281. /**
  67282. * Concats the active data with a given array.
  67283. * @param array defines the data to concatenate with.
  67284. */
  67285. concat(array: any): void;
  67286. /**
  67287. * Returns the position of a value in the active data.
  67288. * @param value defines the value to find the index for
  67289. * @returns the index if found in the active data otherwise -1
  67290. */
  67291. indexOf(value: T): number;
  67292. /**
  67293. * Returns whether an element is part of the active data.
  67294. * @param value defines the value to look for
  67295. * @returns true if found in the active data otherwise false
  67296. */
  67297. contains(value: T): boolean;
  67298. private static _GlobalId;
  67299. }
  67300. /**
  67301. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67302. * The data in this array can only be present once
  67303. */
  67304. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67305. private _duplicateId;
  67306. /**
  67307. * Pushes a value at the end of the active data.
  67308. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67309. * @param value defines the object to push in the array.
  67310. */
  67311. push(value: T): void;
  67312. /**
  67313. * Pushes a value at the end of the active data.
  67314. * If the data is already present, it won t be added again
  67315. * @param value defines the object to push in the array.
  67316. * @returns true if added false if it was already present
  67317. */
  67318. pushNoDuplicate(value: T): boolean;
  67319. /**
  67320. * Resets the active data to an empty array.
  67321. */
  67322. reset(): void;
  67323. /**
  67324. * Concats the active data with a given array.
  67325. * This ensures no dupplicate will be present in the result.
  67326. * @param array defines the data to concatenate with.
  67327. */
  67328. concatWithNoDuplicate(array: any): void;
  67329. }
  67330. }
  67331. declare module BABYLON {
  67332. /**
  67333. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67334. * separate meshes. This can be use to improve performances.
  67335. * @see http://doc.babylonjs.com/how_to/multi_materials
  67336. */
  67337. export class MultiMaterial extends Material {
  67338. private _subMaterials;
  67339. /**
  67340. * Gets or Sets the list of Materials used within the multi material.
  67341. * They need to be ordered according to the submeshes order in the associated mesh
  67342. */
  67343. subMaterials: Nullable<Material>[];
  67344. /**
  67345. * Function used to align with Node.getChildren()
  67346. * @returns the list of Materials used within the multi material
  67347. */
  67348. getChildren(): Nullable<Material>[];
  67349. /**
  67350. * Instantiates a new Multi Material
  67351. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67352. * separate meshes. This can be use to improve performances.
  67353. * @see http://doc.babylonjs.com/how_to/multi_materials
  67354. * @param name Define the name in the scene
  67355. * @param scene Define the scene the material belongs to
  67356. */
  67357. constructor(name: string, scene: Scene);
  67358. private _hookArray;
  67359. /**
  67360. * Get one of the submaterial by its index in the submaterials array
  67361. * @param index The index to look the sub material at
  67362. * @returns The Material if the index has been defined
  67363. */
  67364. getSubMaterial(index: number): Nullable<Material>;
  67365. /**
  67366. * Get the list of active textures for the whole sub materials list.
  67367. * @returns All the textures that will be used during the rendering
  67368. */
  67369. getActiveTextures(): BaseTexture[];
  67370. /**
  67371. * Gets the current class name of the material e.g. "MultiMaterial"
  67372. * Mainly use in serialization.
  67373. * @returns the class name
  67374. */
  67375. getClassName(): string;
  67376. /**
  67377. * Checks if the material is ready to render the requested sub mesh
  67378. * @param mesh Define the mesh the submesh belongs to
  67379. * @param subMesh Define the sub mesh to look readyness for
  67380. * @param useInstances Define whether or not the material is used with instances
  67381. * @returns true if ready, otherwise false
  67382. */
  67383. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67384. /**
  67385. * Clones the current material and its related sub materials
  67386. * @param name Define the name of the newly cloned material
  67387. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67388. * @returns the cloned material
  67389. */
  67390. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67391. /**
  67392. * Serializes the materials into a JSON representation.
  67393. * @returns the JSON representation
  67394. */
  67395. serialize(): any;
  67396. /**
  67397. * Dispose the material and release its associated resources
  67398. * @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)
  67399. * @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)
  67400. * @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)
  67401. */
  67402. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67403. /**
  67404. * Creates a MultiMaterial from parsed MultiMaterial data.
  67405. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67406. * @param scene defines the hosting scene
  67407. * @returns a new MultiMaterial
  67408. */
  67409. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67410. }
  67411. }
  67412. declare module BABYLON {
  67413. /**
  67414. * Class used to represent data loading progression
  67415. */
  67416. export class SceneLoaderFlags {
  67417. private static _ForceFullSceneLoadingForIncremental;
  67418. private static _ShowLoadingScreen;
  67419. private static _CleanBoneMatrixWeights;
  67420. private static _loggingLevel;
  67421. /**
  67422. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67423. */
  67424. static ForceFullSceneLoadingForIncremental: boolean;
  67425. /**
  67426. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67427. */
  67428. static ShowLoadingScreen: boolean;
  67429. /**
  67430. * Defines the current logging level (while loading the scene)
  67431. * @ignorenaming
  67432. */
  67433. static loggingLevel: number;
  67434. /**
  67435. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67436. */
  67437. static CleanBoneMatrixWeights: boolean;
  67438. }
  67439. }
  67440. declare module BABYLON {
  67441. /**
  67442. * 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.
  67443. * @see https://doc.babylonjs.com/how_to/transformnode
  67444. */
  67445. export class TransformNode extends Node {
  67446. /**
  67447. * Object will not rotate to face the camera
  67448. */
  67449. static BILLBOARDMODE_NONE: number;
  67450. /**
  67451. * Object will rotate to face the camera but only on the x axis
  67452. */
  67453. static BILLBOARDMODE_X: number;
  67454. /**
  67455. * Object will rotate to face the camera but only on the y axis
  67456. */
  67457. static BILLBOARDMODE_Y: number;
  67458. /**
  67459. * Object will rotate to face the camera but only on the z axis
  67460. */
  67461. static BILLBOARDMODE_Z: number;
  67462. /**
  67463. * Object will rotate to face the camera
  67464. */
  67465. static BILLBOARDMODE_ALL: number;
  67466. private _forward;
  67467. private _forwardInverted;
  67468. private _up;
  67469. private _right;
  67470. private _rightInverted;
  67471. private _position;
  67472. private _rotation;
  67473. private _rotationQuaternion;
  67474. protected _scaling: Vector3;
  67475. protected _isDirty: boolean;
  67476. private _transformToBoneReferal;
  67477. private _billboardMode;
  67478. /**
  67479. * Gets or sets the billboard mode. Default is 0.
  67480. *
  67481. * | Value | Type | Description |
  67482. * | --- | --- | --- |
  67483. * | 0 | BILLBOARDMODE_NONE | |
  67484. * | 1 | BILLBOARDMODE_X | |
  67485. * | 2 | BILLBOARDMODE_Y | |
  67486. * | 4 | BILLBOARDMODE_Z | |
  67487. * | 7 | BILLBOARDMODE_ALL | |
  67488. *
  67489. */
  67490. billboardMode: number;
  67491. private _preserveParentRotationForBillboard;
  67492. /**
  67493. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67494. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67495. */
  67496. preserveParentRotationForBillboard: boolean;
  67497. /**
  67498. * 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
  67499. */
  67500. scalingDeterminant: number;
  67501. private _infiniteDistance;
  67502. /**
  67503. * Gets or sets the distance of the object to max, often used by skybox
  67504. */
  67505. infiniteDistance: boolean;
  67506. /**
  67507. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67508. * By default the system will update normals to compensate
  67509. */
  67510. ignoreNonUniformScaling: boolean;
  67511. /**
  67512. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  67513. */
  67514. reIntegrateRotationIntoRotationQuaternion: boolean;
  67515. /** @hidden */
  67516. _poseMatrix: Nullable<Matrix>;
  67517. /** @hidden */
  67518. _localMatrix: Matrix;
  67519. private _usePivotMatrix;
  67520. private _absolutePosition;
  67521. private _pivotMatrix;
  67522. private _pivotMatrixInverse;
  67523. protected _postMultiplyPivotMatrix: boolean;
  67524. protected _isWorldMatrixFrozen: boolean;
  67525. /** @hidden */
  67526. _indexInSceneTransformNodesArray: number;
  67527. /**
  67528. * An event triggered after the world matrix is updated
  67529. */
  67530. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67531. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67532. /**
  67533. * Gets a string identifying the name of the class
  67534. * @returns "TransformNode" string
  67535. */
  67536. getClassName(): string;
  67537. /**
  67538. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67539. */
  67540. position: Vector3;
  67541. /**
  67542. * 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)).
  67543. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67544. */
  67545. rotation: Vector3;
  67546. /**
  67547. * 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)).
  67548. */
  67549. scaling: Vector3;
  67550. /**
  67551. * 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).
  67552. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67553. */
  67554. rotationQuaternion: Nullable<Quaternion>;
  67555. /**
  67556. * The forward direction of that transform in world space.
  67557. */
  67558. readonly forward: Vector3;
  67559. /**
  67560. * The up direction of that transform in world space.
  67561. */
  67562. readonly up: Vector3;
  67563. /**
  67564. * The right direction of that transform in world space.
  67565. */
  67566. readonly right: Vector3;
  67567. /**
  67568. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67569. * @param matrix the matrix to copy the pose from
  67570. * @returns this TransformNode.
  67571. */
  67572. updatePoseMatrix(matrix: Matrix): TransformNode;
  67573. /**
  67574. * Returns the mesh Pose matrix.
  67575. * @returns the pose matrix
  67576. */
  67577. getPoseMatrix(): Matrix;
  67578. /** @hidden */
  67579. _isSynchronized(): boolean;
  67580. /** @hidden */
  67581. _initCache(): void;
  67582. /**
  67583. * Flag the transform node as dirty (Forcing it to update everything)
  67584. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67585. * @returns this transform node
  67586. */
  67587. markAsDirty(property: string): TransformNode;
  67588. /**
  67589. * Returns the current mesh absolute position.
  67590. * Returns a Vector3.
  67591. */
  67592. readonly absolutePosition: Vector3;
  67593. /**
  67594. * Sets a new matrix to apply before all other transformation
  67595. * @param matrix defines the transform matrix
  67596. * @returns the current TransformNode
  67597. */
  67598. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67599. /**
  67600. * Sets a new pivot matrix to the current node
  67601. * @param matrix defines the new pivot matrix to use
  67602. * @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
  67603. * @returns the current TransformNode
  67604. */
  67605. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67606. /**
  67607. * Returns the mesh pivot matrix.
  67608. * Default : Identity.
  67609. * @returns the matrix
  67610. */
  67611. getPivotMatrix(): Matrix;
  67612. /**
  67613. * Prevents the World matrix to be computed any longer.
  67614. * @returns the TransformNode.
  67615. */
  67616. freezeWorldMatrix(): TransformNode;
  67617. /**
  67618. * Allows back the World matrix computation.
  67619. * @returns the TransformNode.
  67620. */
  67621. unfreezeWorldMatrix(): this;
  67622. /**
  67623. * True if the World matrix has been frozen.
  67624. */
  67625. readonly isWorldMatrixFrozen: boolean;
  67626. /**
  67627. * Retuns the mesh absolute position in the World.
  67628. * @returns a Vector3.
  67629. */
  67630. getAbsolutePosition(): Vector3;
  67631. /**
  67632. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67633. * @param absolutePosition the absolute position to set
  67634. * @returns the TransformNode.
  67635. */
  67636. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67637. /**
  67638. * Sets the mesh position in its local space.
  67639. * @param vector3 the position to set in localspace
  67640. * @returns the TransformNode.
  67641. */
  67642. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67643. /**
  67644. * Returns the mesh position in the local space from the current World matrix values.
  67645. * @returns a new Vector3.
  67646. */
  67647. getPositionExpressedInLocalSpace(): Vector3;
  67648. /**
  67649. * Translates the mesh along the passed Vector3 in its local space.
  67650. * @param vector3 the distance to translate in localspace
  67651. * @returns the TransformNode.
  67652. */
  67653. locallyTranslate(vector3: Vector3): TransformNode;
  67654. private static _lookAtVectorCache;
  67655. /**
  67656. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67657. * @param targetPoint the position (must be in same space as current mesh) to look at
  67658. * @param yawCor optional yaw (y-axis) correction in radians
  67659. * @param pitchCor optional pitch (x-axis) correction in radians
  67660. * @param rollCor optional roll (z-axis) correction in radians
  67661. * @param space the choosen space of the target
  67662. * @returns the TransformNode.
  67663. */
  67664. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67665. /**
  67666. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67667. * This Vector3 is expressed in the World space.
  67668. * @param localAxis axis to rotate
  67669. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67670. */
  67671. getDirection(localAxis: Vector3): Vector3;
  67672. /**
  67673. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67674. * localAxis is expressed in the mesh local space.
  67675. * result is computed in the Wordl space from the mesh World matrix.
  67676. * @param localAxis axis to rotate
  67677. * @param result the resulting transformnode
  67678. * @returns this TransformNode.
  67679. */
  67680. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67681. /**
  67682. * Sets this transform node rotation to the given local axis.
  67683. * @param localAxis the axis in local space
  67684. * @param yawCor optional yaw (y-axis) correction in radians
  67685. * @param pitchCor optional pitch (x-axis) correction in radians
  67686. * @param rollCor optional roll (z-axis) correction in radians
  67687. * @returns this TransformNode
  67688. */
  67689. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67690. /**
  67691. * Sets a new pivot point to the current node
  67692. * @param point defines the new pivot point to use
  67693. * @param space defines if the point is in world or local space (local by default)
  67694. * @returns the current TransformNode
  67695. */
  67696. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67697. /**
  67698. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67699. * @returns the pivot point
  67700. */
  67701. getPivotPoint(): Vector3;
  67702. /**
  67703. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67704. * @param result the vector3 to store the result
  67705. * @returns this TransformNode.
  67706. */
  67707. getPivotPointToRef(result: Vector3): TransformNode;
  67708. /**
  67709. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67710. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67711. */
  67712. getAbsolutePivotPoint(): Vector3;
  67713. /**
  67714. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67715. * @param result vector3 to store the result
  67716. * @returns this TransformNode.
  67717. */
  67718. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67719. /**
  67720. * Defines the passed node as the parent of the current node.
  67721. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67722. * @see https://doc.babylonjs.com/how_to/parenting
  67723. * @param node the node ot set as the parent
  67724. * @returns this TransformNode.
  67725. */
  67726. setParent(node: Nullable<Node>): TransformNode;
  67727. private _nonUniformScaling;
  67728. /**
  67729. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67730. */
  67731. readonly nonUniformScaling: boolean;
  67732. /** @hidden */
  67733. _updateNonUniformScalingState(value: boolean): boolean;
  67734. /**
  67735. * Attach the current TransformNode to another TransformNode associated with a bone
  67736. * @param bone Bone affecting the TransformNode
  67737. * @param affectedTransformNode TransformNode associated with the bone
  67738. * @returns this object
  67739. */
  67740. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67741. /**
  67742. * Detach the transform node if its associated with a bone
  67743. * @returns this object
  67744. */
  67745. detachFromBone(): TransformNode;
  67746. private static _rotationAxisCache;
  67747. /**
  67748. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67749. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67750. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67751. * The passed axis is also normalized.
  67752. * @param axis the axis to rotate around
  67753. * @param amount the amount to rotate in radians
  67754. * @param space Space to rotate in (Default: local)
  67755. * @returns the TransformNode.
  67756. */
  67757. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67758. /**
  67759. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67760. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67761. * The passed axis is also normalized. .
  67762. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67763. * @param point the point to rotate around
  67764. * @param axis the axis to rotate around
  67765. * @param amount the amount to rotate in radians
  67766. * @returns the TransformNode
  67767. */
  67768. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67769. /**
  67770. * Translates the mesh along the axis vector for the passed distance in the given space.
  67771. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67772. * @param axis the axis to translate in
  67773. * @param distance the distance to translate
  67774. * @param space Space to rotate in (Default: local)
  67775. * @returns the TransformNode.
  67776. */
  67777. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67778. /**
  67779. * Adds a rotation step to the mesh current rotation.
  67780. * x, y, z are Euler angles expressed in radians.
  67781. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67782. * This means this rotation is made in the mesh local space only.
  67783. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67784. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67785. * ```javascript
  67786. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67787. * ```
  67788. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67789. * 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.
  67790. * @param x Rotation to add
  67791. * @param y Rotation to add
  67792. * @param z Rotation to add
  67793. * @returns the TransformNode.
  67794. */
  67795. addRotation(x: number, y: number, z: number): TransformNode;
  67796. /**
  67797. * @hidden
  67798. */
  67799. protected _getEffectiveParent(): Nullable<Node>;
  67800. /**
  67801. * Computes the world matrix of the node
  67802. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67803. * @returns the world matrix
  67804. */
  67805. computeWorldMatrix(force?: boolean): Matrix;
  67806. protected _afterComputeWorldMatrix(): void;
  67807. /**
  67808. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67809. * @param func callback function to add
  67810. *
  67811. * @returns the TransformNode.
  67812. */
  67813. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67814. /**
  67815. * Removes a registered callback function.
  67816. * @param func callback function to remove
  67817. * @returns the TransformNode.
  67818. */
  67819. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67820. /**
  67821. * Gets the position of the current mesh in camera space
  67822. * @param camera defines the camera to use
  67823. * @returns a position
  67824. */
  67825. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67826. /**
  67827. * Returns the distance from the mesh to the active camera
  67828. * @param camera defines the camera to use
  67829. * @returns the distance
  67830. */
  67831. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67832. /**
  67833. * Clone the current transform node
  67834. * @param name Name of the new clone
  67835. * @param newParent New parent for the clone
  67836. * @param doNotCloneChildren Do not clone children hierarchy
  67837. * @returns the new transform node
  67838. */
  67839. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67840. /**
  67841. * Serializes the objects information.
  67842. * @param currentSerializationObject defines the object to serialize in
  67843. * @returns the serialized object
  67844. */
  67845. serialize(currentSerializationObject?: any): any;
  67846. /**
  67847. * Returns a new TransformNode object parsed from the source provided.
  67848. * @param parsedTransformNode is the source.
  67849. * @param scene the scne the object belongs to
  67850. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67851. * @returns a new TransformNode object parsed from the source provided.
  67852. */
  67853. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67854. /**
  67855. * Get all child-transformNodes of this node
  67856. * @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
  67857. * @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
  67858. * @returns an array of TransformNode
  67859. */
  67860. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67861. /**
  67862. * Releases resources associated with this transform node.
  67863. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67864. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67865. */
  67866. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67867. }
  67868. }
  67869. declare module BABYLON {
  67870. /**
  67871. * Class used to override all child animations of a given target
  67872. */
  67873. export class AnimationPropertiesOverride {
  67874. /**
  67875. * Gets or sets a value indicating if animation blending must be used
  67876. */
  67877. enableBlending: boolean;
  67878. /**
  67879. * Gets or sets the blending speed to use when enableBlending is true
  67880. */
  67881. blendingSpeed: number;
  67882. /**
  67883. * Gets or sets the default loop mode to use
  67884. */
  67885. loopMode: number;
  67886. }
  67887. }
  67888. declare module BABYLON {
  67889. /**
  67890. * Class used to store bone information
  67891. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67892. */
  67893. export class Bone extends Node {
  67894. /**
  67895. * defines the bone name
  67896. */
  67897. name: string;
  67898. private static _tmpVecs;
  67899. private static _tmpQuat;
  67900. private static _tmpMats;
  67901. /**
  67902. * Gets the list of child bones
  67903. */
  67904. children: Bone[];
  67905. /** Gets the animations associated with this bone */
  67906. animations: Animation[];
  67907. /**
  67908. * Gets or sets bone length
  67909. */
  67910. length: number;
  67911. /**
  67912. * @hidden Internal only
  67913. * Set this value to map this bone to a different index in the transform matrices
  67914. * Set this value to -1 to exclude the bone from the transform matrices
  67915. */
  67916. _index: Nullable<number>;
  67917. private _skeleton;
  67918. private _localMatrix;
  67919. private _restPose;
  67920. private _baseMatrix;
  67921. private _absoluteTransform;
  67922. private _invertedAbsoluteTransform;
  67923. private _parent;
  67924. private _scalingDeterminant;
  67925. private _worldTransform;
  67926. private _localScaling;
  67927. private _localRotation;
  67928. private _localPosition;
  67929. private _needToDecompose;
  67930. private _needToCompose;
  67931. /** @hidden */
  67932. _linkedTransformNode: Nullable<TransformNode>;
  67933. /** @hidden */
  67934. _waitingTransformNodeId: Nullable<string>;
  67935. /** @hidden */
  67936. /** @hidden */
  67937. _matrix: Matrix;
  67938. /**
  67939. * Create a new bone
  67940. * @param name defines the bone name
  67941. * @param skeleton defines the parent skeleton
  67942. * @param parentBone defines the parent (can be null if the bone is the root)
  67943. * @param localMatrix defines the local matrix
  67944. * @param restPose defines the rest pose matrix
  67945. * @param baseMatrix defines the base matrix
  67946. * @param index defines index of the bone in the hiearchy
  67947. */
  67948. constructor(
  67949. /**
  67950. * defines the bone name
  67951. */
  67952. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67953. /**
  67954. * Gets the current object class name.
  67955. * @return the class name
  67956. */
  67957. getClassName(): string;
  67958. /**
  67959. * Gets the parent skeleton
  67960. * @returns a skeleton
  67961. */
  67962. getSkeleton(): Skeleton;
  67963. /**
  67964. * Gets parent bone
  67965. * @returns a bone or null if the bone is the root of the bone hierarchy
  67966. */
  67967. getParent(): Nullable<Bone>;
  67968. /**
  67969. * Returns an array containing the root bones
  67970. * @returns an array containing the root bones
  67971. */
  67972. getChildren(): Array<Bone>;
  67973. /**
  67974. * Sets the parent bone
  67975. * @param parent defines the parent (can be null if the bone is the root)
  67976. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67977. */
  67978. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67979. /**
  67980. * Gets the local matrix
  67981. * @returns a matrix
  67982. */
  67983. getLocalMatrix(): Matrix;
  67984. /**
  67985. * Gets the base matrix (initial matrix which remains unchanged)
  67986. * @returns a matrix
  67987. */
  67988. getBaseMatrix(): Matrix;
  67989. /**
  67990. * Gets the rest pose matrix
  67991. * @returns a matrix
  67992. */
  67993. getRestPose(): Matrix;
  67994. /**
  67995. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67996. */
  67997. getWorldMatrix(): Matrix;
  67998. /**
  67999. * Sets the local matrix to rest pose matrix
  68000. */
  68001. returnToRest(): void;
  68002. /**
  68003. * Gets the inverse of the absolute transform matrix.
  68004. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  68005. * @returns a matrix
  68006. */
  68007. getInvertedAbsoluteTransform(): Matrix;
  68008. /**
  68009. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  68010. * @returns a matrix
  68011. */
  68012. getAbsoluteTransform(): Matrix;
  68013. /**
  68014. * Links with the given transform node.
  68015. * The local matrix of this bone is copied from the transform node every frame.
  68016. * @param transformNode defines the transform node to link to
  68017. */
  68018. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  68019. /** Gets or sets current position (in local space) */
  68020. position: Vector3;
  68021. /** Gets or sets current rotation (in local space) */
  68022. rotation: Vector3;
  68023. /** Gets or sets current rotation quaternion (in local space) */
  68024. rotationQuaternion: Quaternion;
  68025. /** Gets or sets current scaling (in local space) */
  68026. scaling: Vector3;
  68027. /**
  68028. * Gets the animation properties override
  68029. */
  68030. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  68031. private _decompose;
  68032. private _compose;
  68033. /**
  68034. * Update the base and local matrices
  68035. * @param matrix defines the new base or local matrix
  68036. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68037. * @param updateLocalMatrix defines if the local matrix should be updated
  68038. */
  68039. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68040. /** @hidden */
  68041. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68042. /**
  68043. * Flag the bone as dirty (Forcing it to update everything)
  68044. */
  68045. markAsDirty(): void;
  68046. private _markAsDirtyAndCompose;
  68047. private _markAsDirtyAndDecompose;
  68048. /**
  68049. * Translate the bone in local or world space
  68050. * @param vec The amount to translate the bone
  68051. * @param space The space that the translation is in
  68052. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68053. */
  68054. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68055. /**
  68056. * Set the postion of the bone in local or world space
  68057. * @param position The position to set the bone
  68058. * @param space The space that the position is in
  68059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68060. */
  68061. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68062. /**
  68063. * Set the absolute position of the bone (world space)
  68064. * @param position The position to set the bone
  68065. * @param mesh The mesh that this bone is attached to
  68066. */
  68067. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68068. /**
  68069. * Scale the bone on the x, y and z axes (in local space)
  68070. * @param x The amount to scale the bone on the x axis
  68071. * @param y The amount to scale the bone on the y axis
  68072. * @param z The amount to scale the bone on the z axis
  68073. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68074. */
  68075. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68076. /**
  68077. * Set the bone scaling in local space
  68078. * @param scale defines the scaling vector
  68079. */
  68080. setScale(scale: Vector3): void;
  68081. /**
  68082. * Gets the current scaling in local space
  68083. * @returns the current scaling vector
  68084. */
  68085. getScale(): Vector3;
  68086. /**
  68087. * Gets the current scaling in local space and stores it in a target vector
  68088. * @param result defines the target vector
  68089. */
  68090. getScaleToRef(result: Vector3): void;
  68091. /**
  68092. * Set the yaw, pitch, and roll of the bone in local or world space
  68093. * @param yaw The rotation of the bone on the y axis
  68094. * @param pitch The rotation of the bone on the x axis
  68095. * @param roll The rotation of the bone on the z axis
  68096. * @param space The space that the axes of rotation are in
  68097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68098. */
  68099. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68100. /**
  68101. * Add a rotation to the bone on an axis in local or world space
  68102. * @param axis The axis to rotate the bone on
  68103. * @param amount The amount to rotate the bone
  68104. * @param space The space that the axis is in
  68105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68106. */
  68107. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68108. /**
  68109. * Set the rotation of the bone to a particular axis angle in local or world space
  68110. * @param axis The axis to rotate the bone on
  68111. * @param angle The angle that the bone should be rotated to
  68112. * @param space The space that the axis is in
  68113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68114. */
  68115. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68116. /**
  68117. * Set the euler rotation of the bone in local of world space
  68118. * @param rotation The euler rotation that the bone should be set to
  68119. * @param space The space that the rotation is in
  68120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68121. */
  68122. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68123. /**
  68124. * Set the quaternion rotation of the bone in local of world space
  68125. * @param quat The quaternion rotation that the bone should be set to
  68126. * @param space The space that the rotation is in
  68127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68128. */
  68129. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68130. /**
  68131. * Set the rotation matrix of the bone in local of world space
  68132. * @param rotMat The rotation matrix that the bone should be set to
  68133. * @param space The space that the rotation is in
  68134. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68135. */
  68136. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68137. private _rotateWithMatrix;
  68138. private _getNegativeRotationToRef;
  68139. /**
  68140. * Get the position of the bone in local or world space
  68141. * @param space The space that the returned position is in
  68142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68143. * @returns The position of the bone
  68144. */
  68145. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68146. /**
  68147. * Copy the position of the bone to a vector3 in local or world space
  68148. * @param space The space that the returned position is in
  68149. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68150. * @param result The vector3 to copy the position to
  68151. */
  68152. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68153. /**
  68154. * Get the absolute position of the bone (world space)
  68155. * @param mesh The mesh that this bone is attached to
  68156. * @returns The absolute position of the bone
  68157. */
  68158. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68159. /**
  68160. * Copy the absolute position of the bone (world space) to the result param
  68161. * @param mesh The mesh that this bone is attached to
  68162. * @param result The vector3 to copy the absolute position to
  68163. */
  68164. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68165. /**
  68166. * Compute the absolute transforms of this bone and its children
  68167. */
  68168. computeAbsoluteTransforms(): void;
  68169. /**
  68170. * Get the world direction from an axis that is in the local space of the bone
  68171. * @param localAxis The local direction that is used to compute the world direction
  68172. * @param mesh The mesh that this bone is attached to
  68173. * @returns The world direction
  68174. */
  68175. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68176. /**
  68177. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68178. * @param localAxis The local direction that is used to compute the world direction
  68179. * @param mesh The mesh that this bone is attached to
  68180. * @param result The vector3 that the world direction will be copied to
  68181. */
  68182. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68183. /**
  68184. * Get the euler rotation of the bone in local or world space
  68185. * @param space The space that the rotation should be in
  68186. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68187. * @returns The euler rotation
  68188. */
  68189. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68190. /**
  68191. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68192. * @param space The space that the rotation should be in
  68193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68194. * @param result The vector3 that the rotation should be copied to
  68195. */
  68196. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68197. /**
  68198. * Get the quaternion rotation of the bone in either local or world space
  68199. * @param space The space that the rotation should be in
  68200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68201. * @returns The quaternion rotation
  68202. */
  68203. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68204. /**
  68205. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68206. * @param space The space that the rotation should be in
  68207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68208. * @param result The quaternion that the rotation should be copied to
  68209. */
  68210. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68211. /**
  68212. * Get the rotation matrix of the bone in local or world space
  68213. * @param space The space that the rotation should be in
  68214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68215. * @returns The rotation matrix
  68216. */
  68217. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68218. /**
  68219. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68220. * @param space The space that the rotation should be in
  68221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68222. * @param result The quaternion that the rotation should be copied to
  68223. */
  68224. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68225. /**
  68226. * Get the world position of a point that is in the local space of the bone
  68227. * @param position The local position
  68228. * @param mesh The mesh that this bone is attached to
  68229. * @returns The world position
  68230. */
  68231. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68232. /**
  68233. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68234. * @param position The local position
  68235. * @param mesh The mesh that this bone is attached to
  68236. * @param result The vector3 that the world position should be copied to
  68237. */
  68238. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68239. /**
  68240. * Get the local position of a point that is in world space
  68241. * @param position The world position
  68242. * @param mesh The mesh that this bone is attached to
  68243. * @returns The local position
  68244. */
  68245. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68246. /**
  68247. * Get the local position of a point that is in world space and copy it to the result param
  68248. * @param position The world position
  68249. * @param mesh The mesh that this bone is attached to
  68250. * @param result The vector3 that the local position should be copied to
  68251. */
  68252. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68253. }
  68254. }
  68255. declare module BABYLON {
  68256. /**
  68257. * Enum that determines the text-wrapping mode to use.
  68258. */
  68259. export enum InspectableType {
  68260. /**
  68261. * Checkbox for booleans
  68262. */
  68263. Checkbox = 0,
  68264. /**
  68265. * Sliders for numbers
  68266. */
  68267. Slider = 1,
  68268. /**
  68269. * Vector3
  68270. */
  68271. Vector3 = 2,
  68272. /**
  68273. * Quaternions
  68274. */
  68275. Quaternion = 3,
  68276. /**
  68277. * Color3
  68278. */
  68279. Color3 = 4
  68280. }
  68281. /**
  68282. * Interface used to define custom inspectable properties.
  68283. * This interface is used by the inspector to display custom property grids
  68284. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68285. */
  68286. export interface IInspectable {
  68287. /**
  68288. * Gets the label to display
  68289. */
  68290. label: string;
  68291. /**
  68292. * Gets the name of the property to edit
  68293. */
  68294. propertyName: string;
  68295. /**
  68296. * Gets the type of the editor to use
  68297. */
  68298. type: InspectableType;
  68299. /**
  68300. * Gets the minimum value of the property when using in "slider" mode
  68301. */
  68302. min?: number;
  68303. /**
  68304. * Gets the maximum value of the property when using in "slider" mode
  68305. */
  68306. max?: number;
  68307. /**
  68308. * Gets the setp to use when using in "slider" mode
  68309. */
  68310. step?: number;
  68311. }
  68312. }
  68313. declare module BABYLON {
  68314. /**
  68315. * This represents the required contract to create a new type of texture loader.
  68316. */
  68317. export interface IInternalTextureLoader {
  68318. /**
  68319. * Defines wether the loader supports cascade loading the different faces.
  68320. */
  68321. supportCascades: boolean;
  68322. /**
  68323. * This returns if the loader support the current file information.
  68324. * @param extension defines the file extension of the file being loaded
  68325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68326. * @param fallback defines the fallback internal texture if any
  68327. * @param isBase64 defines whether the texture is encoded as a base64
  68328. * @param isBuffer defines whether the texture data are stored as a buffer
  68329. * @returns true if the loader can load the specified file
  68330. */
  68331. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68332. /**
  68333. * Transform the url before loading if required.
  68334. * @param rootUrl the url of the texture
  68335. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68336. * @returns the transformed texture
  68337. */
  68338. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68339. /**
  68340. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68341. * @param rootUrl the url of the texture
  68342. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68343. * @returns the fallback texture
  68344. */
  68345. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68346. /**
  68347. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68348. * @param data contains the texture data
  68349. * @param texture defines the BabylonJS internal texture
  68350. * @param createPolynomials will be true if polynomials have been requested
  68351. * @param onLoad defines the callback to trigger once the texture is ready
  68352. * @param onError defines the callback to trigger in case of error
  68353. */
  68354. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68355. /**
  68356. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68357. * @param data contains the texture data
  68358. * @param texture defines the BabylonJS internal texture
  68359. * @param callback defines the method to call once ready to upload
  68360. */
  68361. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68362. }
  68363. }
  68364. declare module BABYLON {
  68365. interface Engine {
  68366. /**
  68367. * Creates a depth stencil cube texture.
  68368. * This is only available in WebGL 2.
  68369. * @param size The size of face edge in the cube texture.
  68370. * @param options The options defining the cube texture.
  68371. * @returns The cube texture
  68372. */
  68373. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68374. /**
  68375. * Creates a cube texture
  68376. * @param rootUrl defines the url where the files to load is located
  68377. * @param scene defines the current scene
  68378. * @param files defines the list of files to load (1 per face)
  68379. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68380. * @param onLoad defines an optional callback raised when the texture is loaded
  68381. * @param onError defines an optional callback raised if there is an issue to load the texture
  68382. * @param format defines the format of the data
  68383. * @param forcedExtension defines the extension to use to pick the right loader
  68384. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68385. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68386. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68387. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68388. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68389. * @returns the cube texture as an InternalTexture
  68390. */
  68391. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  68392. /**
  68393. * Creates a cube texture
  68394. * @param rootUrl defines the url where the files to load is located
  68395. * @param scene defines the current scene
  68396. * @param files defines the list of files to load (1 per face)
  68397. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68398. * @param onLoad defines an optional callback raised when the texture is loaded
  68399. * @param onError defines an optional callback raised if there is an issue to load the texture
  68400. * @param format defines the format of the data
  68401. * @param forcedExtension defines the extension to use to pick the right loader
  68402. * @returns the cube texture as an InternalTexture
  68403. */
  68404. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  68405. /**
  68406. * Creates a cube texture
  68407. * @param rootUrl defines the url where the files to load is located
  68408. * @param scene defines the current scene
  68409. * @param files defines the list of files to load (1 per face)
  68410. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68411. * @param onLoad defines an optional callback raised when the texture is loaded
  68412. * @param onError defines an optional callback raised if there is an issue to load the texture
  68413. * @param format defines the format of the data
  68414. * @param forcedExtension defines the extension to use to pick the right loader
  68415. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68416. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68417. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68418. * @returns the cube texture as an InternalTexture
  68419. */
  68420. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  68421. /** @hidden */
  68422. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68423. /** @hidden */
  68424. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68425. /** @hidden */
  68426. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68427. /** @hidden */
  68428. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68429. }
  68430. }
  68431. declare module BABYLON {
  68432. /**
  68433. * Class for creating a cube texture
  68434. */
  68435. export class CubeTexture extends BaseTexture {
  68436. private _delayedOnLoad;
  68437. /**
  68438. * The url of the texture
  68439. */
  68440. url: string;
  68441. /**
  68442. * Gets or sets the center of the bounding box associated with the cube texture.
  68443. * It must define where the camera used to render the texture was set
  68444. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68445. */
  68446. boundingBoxPosition: Vector3;
  68447. private _boundingBoxSize;
  68448. /**
  68449. * Gets or sets the size of the bounding box associated with the cube texture
  68450. * When defined, the cubemap will switch to local mode
  68451. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68452. * @example https://www.babylonjs-playground.com/#RNASML
  68453. */
  68454. /**
  68455. * Returns the bounding box size
  68456. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68457. */
  68458. boundingBoxSize: Vector3;
  68459. protected _rotationY: number;
  68460. /**
  68461. * Sets texture matrix rotation angle around Y axis in radians.
  68462. */
  68463. /**
  68464. * Gets texture matrix rotation angle around Y axis radians.
  68465. */
  68466. rotationY: number;
  68467. /**
  68468. * Are mip maps generated for this texture or not.
  68469. */
  68470. readonly noMipmap: boolean;
  68471. private _noMipmap;
  68472. private _files;
  68473. private _extensions;
  68474. private _textureMatrix;
  68475. private _format;
  68476. private _createPolynomials;
  68477. /** @hidden */
  68478. _prefiltered: boolean;
  68479. /**
  68480. * Creates a cube texture from an array of image urls
  68481. * @param files defines an array of image urls
  68482. * @param scene defines the hosting scene
  68483. * @param noMipmap specifies if mip maps are not used
  68484. * @returns a cube texture
  68485. */
  68486. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68487. /**
  68488. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68489. * @param url defines the url of the prefiltered texture
  68490. * @param scene defines the scene the texture is attached to
  68491. * @param forcedExtension defines the extension of the file if different from the url
  68492. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68493. * @return the prefiltered texture
  68494. */
  68495. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68496. /**
  68497. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68498. * as prefiltered data.
  68499. * @param rootUrl defines the url of the texture or the root name of the six images
  68500. * @param scene defines the scene the texture is attached to
  68501. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68502. * @param noMipmap defines if mipmaps should be created or not
  68503. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68504. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68505. * @param onError defines a callback triggered in case of error during load
  68506. * @param format defines the internal format to use for the texture once loaded
  68507. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68508. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68509. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68510. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68511. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68512. * @return the cube texture
  68513. */
  68514. 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);
  68515. /**
  68516. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68517. */
  68518. readonly isPrefiltered: boolean;
  68519. /**
  68520. * Get the current class name of the texture useful for serialization or dynamic coding.
  68521. * @returns "CubeTexture"
  68522. */
  68523. getClassName(): string;
  68524. /**
  68525. * Update the url (and optional buffer) of this texture if url was null during construction.
  68526. * @param url the url of the texture
  68527. * @param forcedExtension defines the extension to use
  68528. * @param onLoad callback called when the texture is loaded (defaults to null)
  68529. */
  68530. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68531. /**
  68532. * Delays loading of the cube texture
  68533. * @param forcedExtension defines the extension to use
  68534. */
  68535. delayLoad(forcedExtension?: string): void;
  68536. /**
  68537. * Returns the reflection texture matrix
  68538. * @returns the reflection texture matrix
  68539. */
  68540. getReflectionTextureMatrix(): Matrix;
  68541. /**
  68542. * Sets the reflection texture matrix
  68543. * @param value Reflection texture matrix
  68544. */
  68545. setReflectionTextureMatrix(value: Matrix): void;
  68546. /**
  68547. * Parses text to create a cube texture
  68548. * @param parsedTexture define the serialized text to read from
  68549. * @param scene defines the hosting scene
  68550. * @param rootUrl defines the root url of the cube texture
  68551. * @returns a cube texture
  68552. */
  68553. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68554. /**
  68555. * Makes a clone, or deep copy, of the cube texture
  68556. * @returns a new cube texture
  68557. */
  68558. clone(): CubeTexture;
  68559. }
  68560. }
  68561. declare module BABYLON {
  68562. /** @hidden */
  68563. export var postprocessVertexShader: {
  68564. name: string;
  68565. shader: string;
  68566. };
  68567. }
  68568. declare module BABYLON {
  68569. /**
  68570. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68571. * This is the base of the follow, arc rotate cameras and Free camera
  68572. * @see http://doc.babylonjs.com/features/cameras
  68573. */
  68574. export class TargetCamera extends Camera {
  68575. private static _RigCamTransformMatrix;
  68576. private static _TargetTransformMatrix;
  68577. private static _TargetFocalPoint;
  68578. /**
  68579. * Define the current direction the camera is moving to
  68580. */
  68581. cameraDirection: Vector3;
  68582. /**
  68583. * Define the current rotation the camera is rotating to
  68584. */
  68585. cameraRotation: Vector2;
  68586. /**
  68587. * When set, the up vector of the camera will be updated by the rotation of the camera
  68588. */
  68589. updateUpVectorFromRotation: boolean;
  68590. private _tmpQuaternion;
  68591. /**
  68592. * Define the current rotation of the camera
  68593. */
  68594. rotation: Vector3;
  68595. /**
  68596. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68597. */
  68598. rotationQuaternion: Quaternion;
  68599. /**
  68600. * Define the current speed of the camera
  68601. */
  68602. speed: number;
  68603. /**
  68604. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68605. * around all axis.
  68606. */
  68607. noRotationConstraint: boolean;
  68608. /**
  68609. * Define the current target of the camera as an object or a position.
  68610. */
  68611. lockedTarget: any;
  68612. /** @hidden */
  68613. _currentTarget: Vector3;
  68614. /** @hidden */
  68615. _initialFocalDistance: number;
  68616. /** @hidden */
  68617. _viewMatrix: Matrix;
  68618. /** @hidden */
  68619. _camMatrix: Matrix;
  68620. /** @hidden */
  68621. _cameraTransformMatrix: Matrix;
  68622. /** @hidden */
  68623. _cameraRotationMatrix: Matrix;
  68624. /** @hidden */
  68625. _referencePoint: Vector3;
  68626. /** @hidden */
  68627. _transformedReferencePoint: Vector3;
  68628. protected _globalCurrentTarget: Vector3;
  68629. protected _globalCurrentUpVector: Vector3;
  68630. /** @hidden */
  68631. _reset: () => void;
  68632. private _defaultUp;
  68633. /**
  68634. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68635. * This is the base of the follow, arc rotate cameras and Free camera
  68636. * @see http://doc.babylonjs.com/features/cameras
  68637. * @param name Defines the name of the camera in the scene
  68638. * @param position Defines the start position of the camera in the scene
  68639. * @param scene Defines the scene the camera belongs to
  68640. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68641. */
  68642. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68643. /**
  68644. * Gets the position in front of the camera at a given distance.
  68645. * @param distance The distance from the camera we want the position to be
  68646. * @returns the position
  68647. */
  68648. getFrontPosition(distance: number): Vector3;
  68649. /** @hidden */
  68650. _getLockedTargetPosition(): Nullable<Vector3>;
  68651. private _storedPosition;
  68652. private _storedRotation;
  68653. private _storedRotationQuaternion;
  68654. /**
  68655. * Store current camera state of the camera (fov, position, rotation, etc..)
  68656. * @returns the camera
  68657. */
  68658. storeState(): Camera;
  68659. /**
  68660. * Restored camera state. You must call storeState() first
  68661. * @returns whether it was successful or not
  68662. * @hidden
  68663. */
  68664. _restoreStateValues(): boolean;
  68665. /** @hidden */
  68666. _initCache(): void;
  68667. /** @hidden */
  68668. _updateCache(ignoreParentClass?: boolean): void;
  68669. /** @hidden */
  68670. _isSynchronizedViewMatrix(): boolean;
  68671. /** @hidden */
  68672. _computeLocalCameraSpeed(): number;
  68673. /**
  68674. * Defines the target the camera should look at.
  68675. * This will automatically adapt alpha beta and radius to fit within the new target.
  68676. * @param target Defines the new target as a Vector or a mesh
  68677. */
  68678. setTarget(target: Vector3): void;
  68679. /**
  68680. * Return the current target position of the camera. This value is expressed in local space.
  68681. * @returns the target position
  68682. */
  68683. getTarget(): Vector3;
  68684. /** @hidden */
  68685. _decideIfNeedsToMove(): boolean;
  68686. /** @hidden */
  68687. _updatePosition(): void;
  68688. /** @hidden */
  68689. _checkInputs(): void;
  68690. protected _updateCameraRotationMatrix(): void;
  68691. /**
  68692. * 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)
  68693. * @returns the current camera
  68694. */
  68695. private _rotateUpVectorWithCameraRotationMatrix;
  68696. private _cachedRotationZ;
  68697. private _cachedQuaternionRotationZ;
  68698. /** @hidden */
  68699. _getViewMatrix(): Matrix;
  68700. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68701. /**
  68702. * @hidden
  68703. */
  68704. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68705. /**
  68706. * @hidden
  68707. */
  68708. _updateRigCameras(): void;
  68709. private _getRigCamPositionAndTarget;
  68710. /**
  68711. * Gets the current object class name.
  68712. * @return the class name
  68713. */
  68714. getClassName(): string;
  68715. }
  68716. }
  68717. declare module BABYLON {
  68718. /**
  68719. * @ignore
  68720. * This is a list of all the different input types that are available in the application.
  68721. * Fo instance: ArcRotateCameraGamepadInput...
  68722. */
  68723. export var CameraInputTypes: {};
  68724. /**
  68725. * This is the contract to implement in order to create a new input class.
  68726. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68727. */
  68728. export interface ICameraInput<TCamera extends Camera> {
  68729. /**
  68730. * Defines the camera the input is attached to.
  68731. */
  68732. camera: Nullable<TCamera>;
  68733. /**
  68734. * Gets the class name of the current intput.
  68735. * @returns the class name
  68736. */
  68737. getClassName(): string;
  68738. /**
  68739. * Get the friendly name associated with the input class.
  68740. * @returns the input friendly name
  68741. */
  68742. getSimpleName(): string;
  68743. /**
  68744. * Attach the input controls to a specific dom element to get the input from.
  68745. * @param element Defines the element the controls should be listened from
  68746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68747. */
  68748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68749. /**
  68750. * Detach the current controls from the specified dom element.
  68751. * @param element Defines the element to stop listening the inputs from
  68752. */
  68753. detachControl(element: Nullable<HTMLElement>): void;
  68754. /**
  68755. * Update the current camera state depending on the inputs that have been used this frame.
  68756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68757. */
  68758. checkInputs?: () => void;
  68759. }
  68760. /**
  68761. * Represents a map of input types to input instance or input index to input instance.
  68762. */
  68763. export interface CameraInputsMap<TCamera extends Camera> {
  68764. /**
  68765. * Accessor to the input by input type.
  68766. */
  68767. [name: string]: ICameraInput<TCamera>;
  68768. /**
  68769. * Accessor to the input by input index.
  68770. */
  68771. [idx: number]: ICameraInput<TCamera>;
  68772. }
  68773. /**
  68774. * This represents the input manager used within a camera.
  68775. * It helps dealing with all the different kind of input attached to a camera.
  68776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68777. */
  68778. export class CameraInputsManager<TCamera extends Camera> {
  68779. /**
  68780. * Defines the list of inputs attahed to the camera.
  68781. */
  68782. attached: CameraInputsMap<TCamera>;
  68783. /**
  68784. * Defines the dom element the camera is collecting inputs from.
  68785. * This is null if the controls have not been attached.
  68786. */
  68787. attachedElement: Nullable<HTMLElement>;
  68788. /**
  68789. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68790. */
  68791. noPreventDefault: boolean;
  68792. /**
  68793. * Defined the camera the input manager belongs to.
  68794. */
  68795. camera: TCamera;
  68796. /**
  68797. * Update the current camera state depending on the inputs that have been used this frame.
  68798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68799. */
  68800. checkInputs: () => void;
  68801. /**
  68802. * Instantiate a new Camera Input Manager.
  68803. * @param camera Defines the camera the input manager blongs to
  68804. */
  68805. constructor(camera: TCamera);
  68806. /**
  68807. * Add an input method to a camera
  68808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68809. * @param input camera input method
  68810. */
  68811. add(input: ICameraInput<TCamera>): void;
  68812. /**
  68813. * Remove a specific input method from a camera
  68814. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68815. * @param inputToRemove camera input method
  68816. */
  68817. remove(inputToRemove: ICameraInput<TCamera>): void;
  68818. /**
  68819. * Remove a specific input type from a camera
  68820. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68821. * @param inputType the type of the input to remove
  68822. */
  68823. removeByType(inputType: string): void;
  68824. private _addCheckInputs;
  68825. /**
  68826. * Attach the input controls to the currently attached dom element to listen the events from.
  68827. * @param input Defines the input to attach
  68828. */
  68829. attachInput(input: ICameraInput<TCamera>): void;
  68830. /**
  68831. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68832. * @param element Defines the dom element to collect the events from
  68833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68834. */
  68835. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68836. /**
  68837. * Detach the current manager inputs controls from a specific dom element.
  68838. * @param element Defines the dom element to collect the events from
  68839. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68840. */
  68841. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68842. /**
  68843. * Rebuild the dynamic inputCheck function from the current list of
  68844. * defined inputs in the manager.
  68845. */
  68846. rebuildInputCheck(): void;
  68847. /**
  68848. * Remove all attached input methods from a camera
  68849. */
  68850. clear(): void;
  68851. /**
  68852. * Serialize the current input manager attached to a camera.
  68853. * This ensures than once parsed,
  68854. * the input associated to the camera will be identical to the current ones
  68855. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68856. */
  68857. serialize(serializedCamera: any): void;
  68858. /**
  68859. * Parses an input manager serialized JSON to restore the previous list of inputs
  68860. * and states associated to a camera.
  68861. * @param parsedCamera Defines the JSON to parse
  68862. */
  68863. parse(parsedCamera: any): void;
  68864. }
  68865. }
  68866. declare module BABYLON {
  68867. /**
  68868. * Gather the list of keyboard event types as constants.
  68869. */
  68870. export class KeyboardEventTypes {
  68871. /**
  68872. * The keydown event is fired when a key becomes active (pressed).
  68873. */
  68874. static readonly KEYDOWN: number;
  68875. /**
  68876. * The keyup event is fired when a key has been released.
  68877. */
  68878. static readonly KEYUP: number;
  68879. }
  68880. /**
  68881. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68882. */
  68883. export class KeyboardInfo {
  68884. /**
  68885. * Defines the type of event (KeyboardEventTypes)
  68886. */
  68887. type: number;
  68888. /**
  68889. * Defines the related dom event
  68890. */
  68891. event: KeyboardEvent;
  68892. /**
  68893. * Instantiates a new keyboard info.
  68894. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68895. * @param type Defines the type of event (KeyboardEventTypes)
  68896. * @param event Defines the related dom event
  68897. */
  68898. constructor(
  68899. /**
  68900. * Defines the type of event (KeyboardEventTypes)
  68901. */
  68902. type: number,
  68903. /**
  68904. * Defines the related dom event
  68905. */
  68906. event: KeyboardEvent);
  68907. }
  68908. /**
  68909. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68910. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68911. */
  68912. export class KeyboardInfoPre extends KeyboardInfo {
  68913. /**
  68914. * Defines the type of event (KeyboardEventTypes)
  68915. */
  68916. type: number;
  68917. /**
  68918. * Defines the related dom event
  68919. */
  68920. event: KeyboardEvent;
  68921. /**
  68922. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68923. */
  68924. skipOnPointerObservable: boolean;
  68925. /**
  68926. * Instantiates a new keyboard pre info.
  68927. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68928. * @param type Defines the type of event (KeyboardEventTypes)
  68929. * @param event Defines the related dom event
  68930. */
  68931. constructor(
  68932. /**
  68933. * Defines the type of event (KeyboardEventTypes)
  68934. */
  68935. type: number,
  68936. /**
  68937. * Defines the related dom event
  68938. */
  68939. event: KeyboardEvent);
  68940. }
  68941. }
  68942. declare module BABYLON {
  68943. /**
  68944. * Manage the keyboard inputs to control the movement of a free camera.
  68945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68946. */
  68947. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68948. /**
  68949. * Defines the camera the input is attached to.
  68950. */
  68951. camera: FreeCamera;
  68952. /**
  68953. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68954. */
  68955. keysUp: number[];
  68956. /**
  68957. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68958. */
  68959. keysDown: number[];
  68960. /**
  68961. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68962. */
  68963. keysLeft: number[];
  68964. /**
  68965. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68966. */
  68967. keysRight: number[];
  68968. private _keys;
  68969. private _onCanvasBlurObserver;
  68970. private _onKeyboardObserver;
  68971. private _engine;
  68972. private _scene;
  68973. /**
  68974. * Attach the input controls to a specific dom element to get the input from.
  68975. * @param element Defines the element the controls should be listened from
  68976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68977. */
  68978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68979. /**
  68980. * Detach the current controls from the specified dom element.
  68981. * @param element Defines the element to stop listening the inputs from
  68982. */
  68983. detachControl(element: Nullable<HTMLElement>): void;
  68984. /**
  68985. * Update the current camera state depending on the inputs that have been used this frame.
  68986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68987. */
  68988. checkInputs(): void;
  68989. /**
  68990. * Gets the class name of the current intput.
  68991. * @returns the class name
  68992. */
  68993. getClassName(): string;
  68994. /** @hidden */
  68995. _onLostFocus(): void;
  68996. /**
  68997. * Get the friendly name associated with the input class.
  68998. * @returns the input friendly name
  68999. */
  69000. getSimpleName(): string;
  69001. }
  69002. }
  69003. declare module BABYLON {
  69004. /**
  69005. * Interface describing all the common properties and methods a shadow light needs to implement.
  69006. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  69007. * as well as binding the different shadow properties to the effects.
  69008. */
  69009. export interface IShadowLight extends Light {
  69010. /**
  69011. * The light id in the scene (used in scene.findLighById for instance)
  69012. */
  69013. id: string;
  69014. /**
  69015. * The position the shdow will be casted from.
  69016. */
  69017. position: Vector3;
  69018. /**
  69019. * In 2d mode (needCube being false), the direction used to cast the shadow.
  69020. */
  69021. direction: Vector3;
  69022. /**
  69023. * The transformed position. Position of the light in world space taking parenting in account.
  69024. */
  69025. transformedPosition: Vector3;
  69026. /**
  69027. * The transformed direction. Direction of the light in world space taking parenting in account.
  69028. */
  69029. transformedDirection: Vector3;
  69030. /**
  69031. * The friendly name of the light in the scene.
  69032. */
  69033. name: string;
  69034. /**
  69035. * Defines the shadow projection clipping minimum z value.
  69036. */
  69037. shadowMinZ: number;
  69038. /**
  69039. * Defines the shadow projection clipping maximum z value.
  69040. */
  69041. shadowMaxZ: number;
  69042. /**
  69043. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69044. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69045. */
  69046. computeTransformedInformation(): boolean;
  69047. /**
  69048. * Gets the scene the light belongs to.
  69049. * @returns The scene
  69050. */
  69051. getScene(): Scene;
  69052. /**
  69053. * Callback defining a custom Projection Matrix Builder.
  69054. * This can be used to override the default projection matrix computation.
  69055. */
  69056. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69057. /**
  69058. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69059. * @param matrix The materix to updated with the projection information
  69060. * @param viewMatrix The transform matrix of the light
  69061. * @param renderList The list of mesh to render in the map
  69062. * @returns The current light
  69063. */
  69064. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69065. /**
  69066. * Gets the current depth scale used in ESM.
  69067. * @returns The scale
  69068. */
  69069. getDepthScale(): number;
  69070. /**
  69071. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69072. * @returns true if a cube texture needs to be use
  69073. */
  69074. needCube(): boolean;
  69075. /**
  69076. * Detects if the projection matrix requires to be recomputed this frame.
  69077. * @returns true if it requires to be recomputed otherwise, false.
  69078. */
  69079. needProjectionMatrixCompute(): boolean;
  69080. /**
  69081. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69082. */
  69083. forceProjectionMatrixCompute(): void;
  69084. /**
  69085. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69086. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69087. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69088. */
  69089. getShadowDirection(faceIndex?: number): Vector3;
  69090. /**
  69091. * Gets the minZ used for shadow according to both the scene and the light.
  69092. * @param activeCamera The camera we are returning the min for
  69093. * @returns the depth min z
  69094. */
  69095. getDepthMinZ(activeCamera: Camera): number;
  69096. /**
  69097. * Gets the maxZ used for shadow according to both the scene and the light.
  69098. * @param activeCamera The camera we are returning the max for
  69099. * @returns the depth max z
  69100. */
  69101. getDepthMaxZ(activeCamera: Camera): number;
  69102. }
  69103. /**
  69104. * Base implementation IShadowLight
  69105. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69106. */
  69107. export abstract class ShadowLight extends Light implements IShadowLight {
  69108. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69109. protected _position: Vector3;
  69110. protected _setPosition(value: Vector3): void;
  69111. /**
  69112. * Sets the position the shadow will be casted from. Also use as the light position for both
  69113. * point and spot lights.
  69114. */
  69115. /**
  69116. * Sets the position the shadow will be casted from. Also use as the light position for both
  69117. * point and spot lights.
  69118. */
  69119. position: Vector3;
  69120. protected _direction: Vector3;
  69121. protected _setDirection(value: Vector3): void;
  69122. /**
  69123. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69124. * Also use as the light direction on spot and directional lights.
  69125. */
  69126. /**
  69127. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69128. * Also use as the light direction on spot and directional lights.
  69129. */
  69130. direction: Vector3;
  69131. private _shadowMinZ;
  69132. /**
  69133. * Gets the shadow projection clipping minimum z value.
  69134. */
  69135. /**
  69136. * Sets the shadow projection clipping minimum z value.
  69137. */
  69138. shadowMinZ: number;
  69139. private _shadowMaxZ;
  69140. /**
  69141. * Sets the shadow projection clipping maximum z value.
  69142. */
  69143. /**
  69144. * Gets the shadow projection clipping maximum z value.
  69145. */
  69146. shadowMaxZ: number;
  69147. /**
  69148. * Callback defining a custom Projection Matrix Builder.
  69149. * This can be used to override the default projection matrix computation.
  69150. */
  69151. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69152. /**
  69153. * The transformed position. Position of the light in world space taking parenting in account.
  69154. */
  69155. transformedPosition: Vector3;
  69156. /**
  69157. * The transformed direction. Direction of the light in world space taking parenting in account.
  69158. */
  69159. transformedDirection: Vector3;
  69160. private _needProjectionMatrixCompute;
  69161. /**
  69162. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69163. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69164. */
  69165. computeTransformedInformation(): boolean;
  69166. /**
  69167. * Return the depth scale used for the shadow map.
  69168. * @returns the depth scale.
  69169. */
  69170. getDepthScale(): number;
  69171. /**
  69172. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69173. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69174. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69175. */
  69176. getShadowDirection(faceIndex?: number): Vector3;
  69177. /**
  69178. * Returns the ShadowLight absolute position in the World.
  69179. * @returns the position vector in world space
  69180. */
  69181. getAbsolutePosition(): Vector3;
  69182. /**
  69183. * Sets the ShadowLight direction toward the passed target.
  69184. * @param target The point to target in local space
  69185. * @returns the updated ShadowLight direction
  69186. */
  69187. setDirectionToTarget(target: Vector3): Vector3;
  69188. /**
  69189. * Returns the light rotation in euler definition.
  69190. * @returns the x y z rotation in local space.
  69191. */
  69192. getRotation(): Vector3;
  69193. /**
  69194. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69195. * @returns true if a cube texture needs to be use
  69196. */
  69197. needCube(): boolean;
  69198. /**
  69199. * Detects if the projection matrix requires to be recomputed this frame.
  69200. * @returns true if it requires to be recomputed otherwise, false.
  69201. */
  69202. needProjectionMatrixCompute(): boolean;
  69203. /**
  69204. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69205. */
  69206. forceProjectionMatrixCompute(): void;
  69207. /** @hidden */
  69208. _initCache(): void;
  69209. /** @hidden */
  69210. _isSynchronized(): boolean;
  69211. /**
  69212. * Computes the world matrix of the node
  69213. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69214. * @returns the world matrix
  69215. */
  69216. computeWorldMatrix(force?: boolean): Matrix;
  69217. /**
  69218. * Gets the minZ used for shadow according to both the scene and the light.
  69219. * @param activeCamera The camera we are returning the min for
  69220. * @returns the depth min z
  69221. */
  69222. getDepthMinZ(activeCamera: Camera): number;
  69223. /**
  69224. * Gets the maxZ used for shadow according to both the scene and the light.
  69225. * @param activeCamera The camera we are returning the max for
  69226. * @returns the depth max z
  69227. */
  69228. getDepthMaxZ(activeCamera: Camera): number;
  69229. /**
  69230. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69231. * @param matrix The materix to updated with the projection information
  69232. * @param viewMatrix The transform matrix of the light
  69233. * @param renderList The list of mesh to render in the map
  69234. * @returns The current light
  69235. */
  69236. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69237. }
  69238. }
  69239. declare module BABYLON {
  69240. /**
  69241. * "Static Class" containing the most commonly used helper while dealing with material for
  69242. * rendering purpose.
  69243. *
  69244. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69245. *
  69246. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69247. */
  69248. export class MaterialHelper {
  69249. /**
  69250. * Bind the current view position to an effect.
  69251. * @param effect The effect to be bound
  69252. * @param scene The scene the eyes position is used from
  69253. */
  69254. static BindEyePosition(effect: Effect, scene: Scene): void;
  69255. /**
  69256. * Helps preparing the defines values about the UVs in used in the effect.
  69257. * UVs are shared as much as we can accross channels in the shaders.
  69258. * @param texture The texture we are preparing the UVs for
  69259. * @param defines The defines to update
  69260. * @param key The channel key "diffuse", "specular"... used in the shader
  69261. */
  69262. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69263. /**
  69264. * Binds a texture matrix value to its corrsponding uniform
  69265. * @param texture The texture to bind the matrix for
  69266. * @param uniformBuffer The uniform buffer receivin the data
  69267. * @param key The channel key "diffuse", "specular"... used in the shader
  69268. */
  69269. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69270. /**
  69271. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69272. * @param mesh defines the current mesh
  69273. * @param scene defines the current scene
  69274. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69275. * @param pointsCloud defines if point cloud rendering has to be turned on
  69276. * @param fogEnabled defines if fog has to be turned on
  69277. * @param alphaTest defines if alpha testing has to be turned on
  69278. * @param defines defines the current list of defines
  69279. */
  69280. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69281. /**
  69282. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69283. * @param scene defines the current scene
  69284. * @param engine defines the current engine
  69285. * @param defines specifies the list of active defines
  69286. * @param useInstances defines if instances have to be turned on
  69287. * @param useClipPlane defines if clip plane have to be turned on
  69288. */
  69289. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69290. /**
  69291. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69292. * @param mesh The mesh containing the geometry data we will draw
  69293. * @param defines The defines to update
  69294. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69295. * @param useBones Precise whether bones should be used or not (override mesh info)
  69296. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69297. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69298. * @returns false if defines are considered not dirty and have not been checked
  69299. */
  69300. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69301. /**
  69302. * Prepares the defines related to multiview
  69303. * @param scene The scene we are intending to draw
  69304. * @param defines The defines to update
  69305. */
  69306. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69307. /**
  69308. * Prepares the defines related to the light information passed in parameter
  69309. * @param scene The scene we are intending to draw
  69310. * @param mesh The mesh the effect is compiling for
  69311. * @param defines The defines to update
  69312. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69313. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69314. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69315. * @returns true if normals will be required for the rest of the effect
  69316. */
  69317. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69318. /**
  69319. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69320. * that won t be acctive due to defines being turned off.
  69321. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69322. * @param samplersList The samplers list
  69323. * @param defines The defines helping in the list generation
  69324. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69325. */
  69326. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69327. /**
  69328. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69329. * @param defines The defines to update while falling back
  69330. * @param fallbacks The authorized effect fallbacks
  69331. * @param maxSimultaneousLights The maximum number of lights allowed
  69332. * @param rank the current rank of the Effect
  69333. * @returns The newly affected rank
  69334. */
  69335. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69336. /**
  69337. * Prepares the list of attributes required for morph targets according to the effect defines.
  69338. * @param attribs The current list of supported attribs
  69339. * @param mesh The mesh to prepare the morph targets attributes for
  69340. * @param defines The current Defines of the effect
  69341. */
  69342. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69343. /**
  69344. * Prepares the list of attributes required for bones according to the effect defines.
  69345. * @param attribs The current list of supported attribs
  69346. * @param mesh The mesh to prepare the bones attributes for
  69347. * @param defines The current Defines of the effect
  69348. * @param fallbacks The current efffect fallback strategy
  69349. */
  69350. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69351. /**
  69352. * Prepares the list of attributes required for instances according to the effect defines.
  69353. * @param attribs The current list of supported attribs
  69354. * @param defines The current Defines of the effect
  69355. */
  69356. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69357. /**
  69358. * Binds the light shadow information to the effect for the given mesh.
  69359. * @param light The light containing the generator
  69360. * @param scene The scene the lights belongs to
  69361. * @param mesh The mesh we are binding the information to render
  69362. * @param lightIndex The light index in the effect used to render the mesh
  69363. * @param effect The effect we are binding the data to
  69364. */
  69365. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69366. /**
  69367. * Binds the light information to the effect.
  69368. * @param light The light containing the generator
  69369. * @param effect The effect we are binding the data to
  69370. * @param lightIndex The light index in the effect used to render
  69371. */
  69372. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69373. /**
  69374. * Binds the lights information from the scene to the effect for the given mesh.
  69375. * @param scene The scene the lights belongs to
  69376. * @param mesh The mesh we are binding the information to render
  69377. * @param effect The effect we are binding the data to
  69378. * @param defines The generated defines for the effect
  69379. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69380. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69381. */
  69382. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69383. private static _tempFogColor;
  69384. /**
  69385. * Binds the fog information from the scene to the effect for the given mesh.
  69386. * @param scene The scene the lights belongs to
  69387. * @param mesh The mesh we are binding the information to render
  69388. * @param effect The effect we are binding the data to
  69389. * @param linearSpace Defines if the fog effect is applied in linear space
  69390. */
  69391. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69392. /**
  69393. * Binds the bones information from the mesh to the effect.
  69394. * @param mesh The mesh we are binding the information to render
  69395. * @param effect The effect we are binding the data to
  69396. */
  69397. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69398. /**
  69399. * Binds the morph targets information from the mesh to the effect.
  69400. * @param abstractMesh The mesh we are binding the information to render
  69401. * @param effect The effect we are binding the data to
  69402. */
  69403. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69404. /**
  69405. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69406. * @param defines The generated defines used in the effect
  69407. * @param effect The effect we are binding the data to
  69408. * @param scene The scene we are willing to render with logarithmic scale for
  69409. */
  69410. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69411. /**
  69412. * Binds the clip plane information from the scene to the effect.
  69413. * @param scene The scene the clip plane information are extracted from
  69414. * @param effect The effect we are binding the data to
  69415. */
  69416. static BindClipPlane(effect: Effect, scene: Scene): void;
  69417. }
  69418. }
  69419. declare module BABYLON {
  69420. /** @hidden */
  69421. export var kernelBlurVaryingDeclaration: {
  69422. name: string;
  69423. shader: string;
  69424. };
  69425. }
  69426. declare module BABYLON {
  69427. /** @hidden */
  69428. export var kernelBlurFragment: {
  69429. name: string;
  69430. shader: string;
  69431. };
  69432. }
  69433. declare module BABYLON {
  69434. /** @hidden */
  69435. export var kernelBlurFragment2: {
  69436. name: string;
  69437. shader: string;
  69438. };
  69439. }
  69440. declare module BABYLON {
  69441. /** @hidden */
  69442. export var kernelBlurPixelShader: {
  69443. name: string;
  69444. shader: string;
  69445. };
  69446. }
  69447. declare module BABYLON {
  69448. /** @hidden */
  69449. export var kernelBlurVertex: {
  69450. name: string;
  69451. shader: string;
  69452. };
  69453. }
  69454. declare module BABYLON {
  69455. /** @hidden */
  69456. export var kernelBlurVertexShader: {
  69457. name: string;
  69458. shader: string;
  69459. };
  69460. }
  69461. declare module BABYLON {
  69462. /**
  69463. * The Blur Post Process which blurs an image based on a kernel and direction.
  69464. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69465. */
  69466. export class BlurPostProcess extends PostProcess {
  69467. /** The direction in which to blur the image. */
  69468. direction: Vector2;
  69469. private blockCompilation;
  69470. protected _kernel: number;
  69471. protected _idealKernel: number;
  69472. protected _packedFloat: boolean;
  69473. private _staticDefines;
  69474. /**
  69475. * Sets the length in pixels of the blur sample region
  69476. */
  69477. /**
  69478. * Gets the length in pixels of the blur sample region
  69479. */
  69480. kernel: number;
  69481. /**
  69482. * Sets wether or not the blur needs to unpack/repack floats
  69483. */
  69484. /**
  69485. * Gets wether or not the blur is unpacking/repacking floats
  69486. */
  69487. packedFloat: boolean;
  69488. /**
  69489. * Creates a new instance BlurPostProcess
  69490. * @param name The name of the effect.
  69491. * @param direction The direction in which to blur the image.
  69492. * @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.
  69493. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69494. * @param camera The camera to apply the render pass to.
  69495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69496. * @param engine The engine which the post process will be applied. (default: current engine)
  69497. * @param reusable If the post process can be reused on the same frame. (default: false)
  69498. * @param textureType Type of textures used when performing the post process. (default: 0)
  69499. * @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)
  69500. */
  69501. constructor(name: string,
  69502. /** The direction in which to blur the image. */
  69503. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69504. /**
  69505. * Updates the effect with the current post process compile time values and recompiles the shader.
  69506. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69507. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69508. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69509. * @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
  69510. * @param onCompiled Called when the shader has been compiled.
  69511. * @param onError Called if there is an error when compiling a shader.
  69512. */
  69513. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69514. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69515. /**
  69516. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69517. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69518. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69519. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69520. * The gaps between physical kernels are compensated for in the weighting of the samples
  69521. * @param idealKernel Ideal blur kernel.
  69522. * @return Nearest best kernel.
  69523. */
  69524. protected _nearestBestKernel(idealKernel: number): number;
  69525. /**
  69526. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69527. * @param x The point on the Gaussian distribution to sample.
  69528. * @return the value of the Gaussian function at x.
  69529. */
  69530. protected _gaussianWeight(x: number): number;
  69531. /**
  69532. * Generates a string that can be used as a floating point number in GLSL.
  69533. * @param x Value to print.
  69534. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69535. * @return GLSL float string.
  69536. */
  69537. protected _glslFloat(x: number, decimalFigures?: number): string;
  69538. }
  69539. }
  69540. declare module BABYLON {
  69541. /** @hidden */
  69542. export var shadowMapPixelShader: {
  69543. name: string;
  69544. shader: string;
  69545. };
  69546. }
  69547. declare module BABYLON {
  69548. /** @hidden */
  69549. export var bonesDeclaration: {
  69550. name: string;
  69551. shader: string;
  69552. };
  69553. }
  69554. declare module BABYLON {
  69555. /** @hidden */
  69556. export var morphTargetsVertexGlobalDeclaration: {
  69557. name: string;
  69558. shader: string;
  69559. };
  69560. }
  69561. declare module BABYLON {
  69562. /** @hidden */
  69563. export var morphTargetsVertexDeclaration: {
  69564. name: string;
  69565. shader: string;
  69566. };
  69567. }
  69568. declare module BABYLON {
  69569. /** @hidden */
  69570. export var instancesDeclaration: {
  69571. name: string;
  69572. shader: string;
  69573. };
  69574. }
  69575. declare module BABYLON {
  69576. /** @hidden */
  69577. export var helperFunctions: {
  69578. name: string;
  69579. shader: string;
  69580. };
  69581. }
  69582. declare module BABYLON {
  69583. /** @hidden */
  69584. export var morphTargetsVertex: {
  69585. name: string;
  69586. shader: string;
  69587. };
  69588. }
  69589. declare module BABYLON {
  69590. /** @hidden */
  69591. export var instancesVertex: {
  69592. name: string;
  69593. shader: string;
  69594. };
  69595. }
  69596. declare module BABYLON {
  69597. /** @hidden */
  69598. export var bonesVertex: {
  69599. name: string;
  69600. shader: string;
  69601. };
  69602. }
  69603. declare module BABYLON {
  69604. /** @hidden */
  69605. export var shadowMapVertexShader: {
  69606. name: string;
  69607. shader: string;
  69608. };
  69609. }
  69610. declare module BABYLON {
  69611. /** @hidden */
  69612. export var depthBoxBlurPixelShader: {
  69613. name: string;
  69614. shader: string;
  69615. };
  69616. }
  69617. declare module BABYLON {
  69618. /**
  69619. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69620. */
  69621. export interface ICustomShaderOptions {
  69622. /**
  69623. * Gets or sets the custom shader name to use
  69624. */
  69625. shaderName: string;
  69626. /**
  69627. * The list of attribute names used in the shader
  69628. */
  69629. attributes?: string[];
  69630. /**
  69631. * The list of unifrom names used in the shader
  69632. */
  69633. uniforms?: string[];
  69634. /**
  69635. * The list of sampler names used in the shader
  69636. */
  69637. samplers?: string[];
  69638. /**
  69639. * The list of defines used in the shader
  69640. */
  69641. defines?: string[];
  69642. }
  69643. /**
  69644. * Interface to implement to create a shadow generator compatible with BJS.
  69645. */
  69646. export interface IShadowGenerator {
  69647. /**
  69648. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69649. * @returns The render target texture if present otherwise, null
  69650. */
  69651. getShadowMap(): Nullable<RenderTargetTexture>;
  69652. /**
  69653. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69654. * @returns The render target texture if the shadow map is present otherwise, null
  69655. */
  69656. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69657. /**
  69658. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69659. * @param subMesh The submesh we want to render in the shadow map
  69660. * @param useInstances Defines wether will draw in the map using instances
  69661. * @returns true if ready otherwise, false
  69662. */
  69663. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69664. /**
  69665. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69666. * @param defines Defines of the material we want to update
  69667. * @param lightIndex Index of the light in the enabled light list of the material
  69668. */
  69669. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69670. /**
  69671. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69672. * defined in the generator but impacting the effect).
  69673. * It implies the unifroms available on the materials are the standard BJS ones.
  69674. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69675. * @param effect The effect we are binfing the information for
  69676. */
  69677. bindShadowLight(lightIndex: string, effect: Effect): void;
  69678. /**
  69679. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69680. * (eq to shadow prjection matrix * light transform matrix)
  69681. * @returns The transform matrix used to create the shadow map
  69682. */
  69683. getTransformMatrix(): Matrix;
  69684. /**
  69685. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69686. * Cube and 2D textures for instance.
  69687. */
  69688. recreateShadowMap(): void;
  69689. /**
  69690. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69691. * @param onCompiled Callback triggered at the and of the effects compilation
  69692. * @param options Sets of optional options forcing the compilation with different modes
  69693. */
  69694. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69695. useInstances: boolean;
  69696. }>): void;
  69697. /**
  69698. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69699. * @param options Sets of optional options forcing the compilation with different modes
  69700. * @returns A promise that resolves when the compilation completes
  69701. */
  69702. forceCompilationAsync(options?: Partial<{
  69703. useInstances: boolean;
  69704. }>): Promise<void>;
  69705. /**
  69706. * Serializes the shadow generator setup to a json object.
  69707. * @returns The serialized JSON object
  69708. */
  69709. serialize(): any;
  69710. /**
  69711. * Disposes the Shadow map and related Textures and effects.
  69712. */
  69713. dispose(): void;
  69714. }
  69715. /**
  69716. * Default implementation IShadowGenerator.
  69717. * This is the main object responsible of generating shadows in the framework.
  69718. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69719. */
  69720. export class ShadowGenerator implements IShadowGenerator {
  69721. /**
  69722. * Shadow generator mode None: no filtering applied.
  69723. */
  69724. static readonly FILTER_NONE: number;
  69725. /**
  69726. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69727. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69728. */
  69729. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69730. /**
  69731. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69732. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69733. */
  69734. static readonly FILTER_POISSONSAMPLING: number;
  69735. /**
  69736. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69737. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69738. */
  69739. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69740. /**
  69741. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69742. * edge artifacts on steep falloff.
  69743. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69744. */
  69745. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69746. /**
  69747. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69748. * edge artifacts on steep falloff.
  69749. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69750. */
  69751. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69752. /**
  69753. * Shadow generator mode PCF: Percentage Closer Filtering
  69754. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69755. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69756. */
  69757. static readonly FILTER_PCF: number;
  69758. /**
  69759. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69760. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69761. * Contact Hardening
  69762. */
  69763. static readonly FILTER_PCSS: number;
  69764. /**
  69765. * Reserved for PCF and PCSS
  69766. * Highest Quality.
  69767. *
  69768. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69769. *
  69770. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69771. */
  69772. static readonly QUALITY_HIGH: number;
  69773. /**
  69774. * Reserved for PCF and PCSS
  69775. * Good tradeoff for quality/perf cross devices
  69776. *
  69777. * Execute PCF on a 3*3 kernel.
  69778. *
  69779. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69780. */
  69781. static readonly QUALITY_MEDIUM: number;
  69782. /**
  69783. * Reserved for PCF and PCSS
  69784. * The lowest quality but the fastest.
  69785. *
  69786. * Execute PCF on a 1*1 kernel.
  69787. *
  69788. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69789. */
  69790. static readonly QUALITY_LOW: number;
  69791. /** Gets or sets the custom shader name to use */
  69792. customShaderOptions: ICustomShaderOptions;
  69793. /**
  69794. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69795. */
  69796. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69797. /**
  69798. * Observable triggered before a mesh is rendered in the shadow map.
  69799. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69800. */
  69801. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69802. private _bias;
  69803. /**
  69804. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69805. */
  69806. /**
  69807. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69808. */
  69809. bias: number;
  69810. private _normalBias;
  69811. /**
  69812. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69813. */
  69814. /**
  69815. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69816. */
  69817. normalBias: number;
  69818. private _blurBoxOffset;
  69819. /**
  69820. * Gets the blur box offset: offset applied during the blur pass.
  69821. * Only useful if useKernelBlur = false
  69822. */
  69823. /**
  69824. * Sets the blur box offset: offset applied during the blur pass.
  69825. * Only useful if useKernelBlur = false
  69826. */
  69827. blurBoxOffset: number;
  69828. private _blurScale;
  69829. /**
  69830. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69831. * 2 means half of the size.
  69832. */
  69833. /**
  69834. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69835. * 2 means half of the size.
  69836. */
  69837. blurScale: number;
  69838. private _blurKernel;
  69839. /**
  69840. * Gets the blur kernel: kernel size of the blur pass.
  69841. * Only useful if useKernelBlur = true
  69842. */
  69843. /**
  69844. * Sets the blur kernel: kernel size of the blur pass.
  69845. * Only useful if useKernelBlur = true
  69846. */
  69847. blurKernel: number;
  69848. private _useKernelBlur;
  69849. /**
  69850. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69851. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69852. */
  69853. /**
  69854. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69855. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69856. */
  69857. useKernelBlur: boolean;
  69858. private _depthScale;
  69859. /**
  69860. * Gets the depth scale used in ESM mode.
  69861. */
  69862. /**
  69863. * Sets the depth scale used in ESM mode.
  69864. * This can override the scale stored on the light.
  69865. */
  69866. depthScale: number;
  69867. private _filter;
  69868. /**
  69869. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69870. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69871. */
  69872. /**
  69873. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69874. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69875. */
  69876. filter: number;
  69877. /**
  69878. * Gets if the current filter is set to Poisson Sampling.
  69879. */
  69880. /**
  69881. * Sets the current filter to Poisson Sampling.
  69882. */
  69883. usePoissonSampling: boolean;
  69884. /**
  69885. * Gets if the current filter is set to ESM.
  69886. */
  69887. /**
  69888. * Sets the current filter is to ESM.
  69889. */
  69890. useExponentialShadowMap: boolean;
  69891. /**
  69892. * Gets if the current filter is set to filtered ESM.
  69893. */
  69894. /**
  69895. * Gets if the current filter is set to filtered ESM.
  69896. */
  69897. useBlurExponentialShadowMap: boolean;
  69898. /**
  69899. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69900. * exponential to prevent steep falloff artifacts).
  69901. */
  69902. /**
  69903. * Sets the current filter to "close ESM" (using the inverse of the
  69904. * exponential to prevent steep falloff artifacts).
  69905. */
  69906. useCloseExponentialShadowMap: boolean;
  69907. /**
  69908. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69909. * exponential to prevent steep falloff artifacts).
  69910. */
  69911. /**
  69912. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69913. * exponential to prevent steep falloff artifacts).
  69914. */
  69915. useBlurCloseExponentialShadowMap: boolean;
  69916. /**
  69917. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69918. */
  69919. /**
  69920. * Sets the current filter to "PCF" (percentage closer filtering).
  69921. */
  69922. usePercentageCloserFiltering: boolean;
  69923. private _filteringQuality;
  69924. /**
  69925. * Gets the PCF or PCSS Quality.
  69926. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69927. */
  69928. /**
  69929. * Sets the PCF or PCSS Quality.
  69930. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69931. */
  69932. filteringQuality: number;
  69933. /**
  69934. * Gets if the current filter is set to "PCSS" (contact hardening).
  69935. */
  69936. /**
  69937. * Sets the current filter to "PCSS" (contact hardening).
  69938. */
  69939. useContactHardeningShadow: boolean;
  69940. private _contactHardeningLightSizeUVRatio;
  69941. /**
  69942. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69943. * Using a ratio helps keeping shape stability independently of the map size.
  69944. *
  69945. * It does not account for the light projection as it was having too much
  69946. * instability during the light setup or during light position changes.
  69947. *
  69948. * Only valid if useContactHardeningShadow is true.
  69949. */
  69950. /**
  69951. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69952. * Using a ratio helps keeping shape stability independently of the map size.
  69953. *
  69954. * It does not account for the light projection as it was having too much
  69955. * instability during the light setup or during light position changes.
  69956. *
  69957. * Only valid if useContactHardeningShadow is true.
  69958. */
  69959. contactHardeningLightSizeUVRatio: number;
  69960. private _darkness;
  69961. /**
  69962. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69963. * 0 means strongest and 1 would means no shadow.
  69964. * @returns the darkness.
  69965. */
  69966. getDarkness(): number;
  69967. /**
  69968. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69969. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69970. * @returns the shadow generator allowing fluent coding.
  69971. */
  69972. setDarkness(darkness: number): ShadowGenerator;
  69973. private _transparencyShadow;
  69974. /**
  69975. * Sets the ability to have transparent shadow (boolean).
  69976. * @param transparent True if transparent else False
  69977. * @returns the shadow generator allowing fluent coding
  69978. */
  69979. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69980. private _shadowMap;
  69981. private _shadowMap2;
  69982. /**
  69983. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69984. * @returns The render target texture if present otherwise, null
  69985. */
  69986. getShadowMap(): Nullable<RenderTargetTexture>;
  69987. /**
  69988. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69989. * @returns The render target texture if the shadow map is present otherwise, null
  69990. */
  69991. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69992. /**
  69993. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69994. * @param mesh Mesh to add
  69995. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69996. * @returns the Shadow Generator itself
  69997. */
  69998. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69999. /**
  70000. * Helper function to remove a mesh and its descendants from the list of shadow casters
  70001. * @param mesh Mesh to remove
  70002. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  70003. * @returns the Shadow Generator itself
  70004. */
  70005. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  70006. /**
  70007. * Controls the extent to which the shadows fade out at the edge of the frustum
  70008. * Used only by directionals and spots
  70009. */
  70010. frustumEdgeFalloff: number;
  70011. private _light;
  70012. /**
  70013. * Returns the associated light object.
  70014. * @returns the light generating the shadow
  70015. */
  70016. getLight(): IShadowLight;
  70017. /**
  70018. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  70019. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  70020. * It might on the other hand introduce peter panning.
  70021. */
  70022. forceBackFacesOnly: boolean;
  70023. private _scene;
  70024. private _lightDirection;
  70025. private _effect;
  70026. private _viewMatrix;
  70027. private _projectionMatrix;
  70028. private _transformMatrix;
  70029. private _cachedPosition;
  70030. private _cachedDirection;
  70031. private _cachedDefines;
  70032. private _currentRenderID;
  70033. private _boxBlurPostprocess;
  70034. private _kernelBlurXPostprocess;
  70035. private _kernelBlurYPostprocess;
  70036. private _blurPostProcesses;
  70037. private _mapSize;
  70038. private _currentFaceIndex;
  70039. private _currentFaceIndexCache;
  70040. private _textureType;
  70041. private _defaultTextureMatrix;
  70042. /** @hidden */
  70043. static _SceneComponentInitialization: (scene: Scene) => void;
  70044. /**
  70045. * Creates a ShadowGenerator object.
  70046. * A ShadowGenerator is the required tool to use the shadows.
  70047. * Each light casting shadows needs to use its own ShadowGenerator.
  70048. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70049. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70050. * @param light The light object generating the shadows.
  70051. * @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.
  70052. */
  70053. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70054. private _initializeGenerator;
  70055. private _initializeShadowMap;
  70056. private _initializeBlurRTTAndPostProcesses;
  70057. private _renderForShadowMap;
  70058. private _renderSubMeshForShadowMap;
  70059. private _applyFilterValues;
  70060. /**
  70061. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70062. * @param onCompiled Callback triggered at the and of the effects compilation
  70063. * @param options Sets of optional options forcing the compilation with different modes
  70064. */
  70065. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70066. useInstances: boolean;
  70067. }>): void;
  70068. /**
  70069. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70070. * @param options Sets of optional options forcing the compilation with different modes
  70071. * @returns A promise that resolves when the compilation completes
  70072. */
  70073. forceCompilationAsync(options?: Partial<{
  70074. useInstances: boolean;
  70075. }>): Promise<void>;
  70076. /**
  70077. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70078. * @param subMesh The submesh we want to render in the shadow map
  70079. * @param useInstances Defines wether will draw in the map using instances
  70080. * @returns true if ready otherwise, false
  70081. */
  70082. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70083. /**
  70084. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70085. * @param defines Defines of the material we want to update
  70086. * @param lightIndex Index of the light in the enabled light list of the material
  70087. */
  70088. prepareDefines(defines: any, lightIndex: number): void;
  70089. /**
  70090. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70091. * defined in the generator but impacting the effect).
  70092. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70093. * @param effect The effect we are binfing the information for
  70094. */
  70095. bindShadowLight(lightIndex: string, effect: Effect): void;
  70096. /**
  70097. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70098. * (eq to shadow prjection matrix * light transform matrix)
  70099. * @returns The transform matrix used to create the shadow map
  70100. */
  70101. getTransformMatrix(): Matrix;
  70102. /**
  70103. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70104. * Cube and 2D textures for instance.
  70105. */
  70106. recreateShadowMap(): void;
  70107. private _disposeBlurPostProcesses;
  70108. private _disposeRTTandPostProcesses;
  70109. /**
  70110. * Disposes the ShadowGenerator.
  70111. * Returns nothing.
  70112. */
  70113. dispose(): void;
  70114. /**
  70115. * Serializes the shadow generator setup to a json object.
  70116. * @returns The serialized JSON object
  70117. */
  70118. serialize(): any;
  70119. /**
  70120. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70121. * @param parsedShadowGenerator The JSON object to parse
  70122. * @param scene The scene to create the shadow map for
  70123. * @returns The parsed shadow generator
  70124. */
  70125. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70126. }
  70127. }
  70128. declare module BABYLON {
  70129. /**
  70130. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70131. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70132. * 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.
  70133. */
  70134. export abstract class Light extends Node {
  70135. /**
  70136. * Falloff Default: light is falling off following the material specification:
  70137. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70138. */
  70139. static readonly FALLOFF_DEFAULT: number;
  70140. /**
  70141. * Falloff Physical: light is falling off following the inverse squared distance law.
  70142. */
  70143. static readonly FALLOFF_PHYSICAL: number;
  70144. /**
  70145. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70146. * to enhance interoperability with other engines.
  70147. */
  70148. static readonly FALLOFF_GLTF: number;
  70149. /**
  70150. * Falloff Standard: light is falling off like in the standard material
  70151. * to enhance interoperability with other materials.
  70152. */
  70153. static readonly FALLOFF_STANDARD: number;
  70154. /**
  70155. * If every light affecting the material is in this lightmapMode,
  70156. * material.lightmapTexture adds or multiplies
  70157. * (depends on material.useLightmapAsShadowmap)
  70158. * after every other light calculations.
  70159. */
  70160. static readonly LIGHTMAP_DEFAULT: number;
  70161. /**
  70162. * material.lightmapTexture as only diffuse lighting from this light
  70163. * adds only specular lighting from this light
  70164. * adds dynamic shadows
  70165. */
  70166. static readonly LIGHTMAP_SPECULAR: number;
  70167. /**
  70168. * material.lightmapTexture as only lighting
  70169. * no light calculation from this light
  70170. * only adds dynamic shadows from this light
  70171. */
  70172. static readonly LIGHTMAP_SHADOWSONLY: number;
  70173. /**
  70174. * Each light type uses the default quantity according to its type:
  70175. * point/spot lights use luminous intensity
  70176. * directional lights use illuminance
  70177. */
  70178. static readonly INTENSITYMODE_AUTOMATIC: number;
  70179. /**
  70180. * lumen (lm)
  70181. */
  70182. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70183. /**
  70184. * candela (lm/sr)
  70185. */
  70186. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70187. /**
  70188. * lux (lm/m^2)
  70189. */
  70190. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70191. /**
  70192. * nit (cd/m^2)
  70193. */
  70194. static readonly INTENSITYMODE_LUMINANCE: number;
  70195. /**
  70196. * Light type const id of the point light.
  70197. */
  70198. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70199. /**
  70200. * Light type const id of the directional light.
  70201. */
  70202. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70203. /**
  70204. * Light type const id of the spot light.
  70205. */
  70206. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70207. /**
  70208. * Light type const id of the hemispheric light.
  70209. */
  70210. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70211. /**
  70212. * Diffuse gives the basic color to an object.
  70213. */
  70214. diffuse: Color3;
  70215. /**
  70216. * Specular produces a highlight color on an object.
  70217. * Note: This is note affecting PBR materials.
  70218. */
  70219. specular: Color3;
  70220. /**
  70221. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70222. * falling off base on range or angle.
  70223. * This can be set to any values in Light.FALLOFF_x.
  70224. *
  70225. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70226. * other types of materials.
  70227. */
  70228. falloffType: number;
  70229. /**
  70230. * Strength of the light.
  70231. * Note: By default it is define in the framework own unit.
  70232. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70233. */
  70234. intensity: number;
  70235. private _range;
  70236. protected _inverseSquaredRange: number;
  70237. /**
  70238. * Defines how far from the source the light is impacting in scene units.
  70239. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70240. */
  70241. /**
  70242. * Defines how far from the source the light is impacting in scene units.
  70243. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70244. */
  70245. range: number;
  70246. /**
  70247. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70248. * of light.
  70249. */
  70250. private _photometricScale;
  70251. private _intensityMode;
  70252. /**
  70253. * Gets the photometric scale used to interpret the intensity.
  70254. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70255. */
  70256. /**
  70257. * Sets the photometric scale used to interpret the intensity.
  70258. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70259. */
  70260. intensityMode: number;
  70261. private _radius;
  70262. /**
  70263. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70264. */
  70265. /**
  70266. * sets the light radius used by PBR Materials to simulate soft area lights.
  70267. */
  70268. radius: number;
  70269. private _renderPriority;
  70270. /**
  70271. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70272. * exceeding the number allowed of the materials.
  70273. */
  70274. renderPriority: number;
  70275. private _shadowEnabled;
  70276. /**
  70277. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70278. * the current shadow generator.
  70279. */
  70280. /**
  70281. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70282. * the current shadow generator.
  70283. */
  70284. shadowEnabled: boolean;
  70285. private _includedOnlyMeshes;
  70286. /**
  70287. * Gets the only meshes impacted by this light.
  70288. */
  70289. /**
  70290. * Sets the only meshes impacted by this light.
  70291. */
  70292. includedOnlyMeshes: AbstractMesh[];
  70293. private _excludedMeshes;
  70294. /**
  70295. * Gets the meshes not impacted by this light.
  70296. */
  70297. /**
  70298. * Sets the meshes not impacted by this light.
  70299. */
  70300. excludedMeshes: AbstractMesh[];
  70301. private _excludeWithLayerMask;
  70302. /**
  70303. * Gets the layer id use to find what meshes are not impacted by the light.
  70304. * Inactive if 0
  70305. */
  70306. /**
  70307. * Sets the layer id use to find what meshes are not impacted by the light.
  70308. * Inactive if 0
  70309. */
  70310. excludeWithLayerMask: number;
  70311. private _includeOnlyWithLayerMask;
  70312. /**
  70313. * Gets the layer id use to find what meshes are impacted by the light.
  70314. * Inactive if 0
  70315. */
  70316. /**
  70317. * Sets the layer id use to find what meshes are impacted by the light.
  70318. * Inactive if 0
  70319. */
  70320. includeOnlyWithLayerMask: number;
  70321. private _lightmapMode;
  70322. /**
  70323. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70324. */
  70325. /**
  70326. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70327. */
  70328. lightmapMode: number;
  70329. /**
  70330. * Shadow generator associted to the light.
  70331. * @hidden Internal use only.
  70332. */
  70333. _shadowGenerator: Nullable<IShadowGenerator>;
  70334. /**
  70335. * @hidden Internal use only.
  70336. */
  70337. _excludedMeshesIds: string[];
  70338. /**
  70339. * @hidden Internal use only.
  70340. */
  70341. _includedOnlyMeshesIds: string[];
  70342. /**
  70343. * The current light unifom buffer.
  70344. * @hidden Internal use only.
  70345. */
  70346. _uniformBuffer: UniformBuffer;
  70347. /**
  70348. * Creates a Light object in the scene.
  70349. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70350. * @param name The firendly name of the light
  70351. * @param scene The scene the light belongs too
  70352. */
  70353. constructor(name: string, scene: Scene);
  70354. protected abstract _buildUniformLayout(): void;
  70355. /**
  70356. * Sets the passed Effect "effect" with the Light information.
  70357. * @param effect The effect to update
  70358. * @param lightIndex The index of the light in the effect to update
  70359. * @returns The light
  70360. */
  70361. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70362. /**
  70363. * Returns the string "Light".
  70364. * @returns the class name
  70365. */
  70366. getClassName(): string;
  70367. /** @hidden */
  70368. readonly _isLight: boolean;
  70369. /**
  70370. * Converts the light information to a readable string for debug purpose.
  70371. * @param fullDetails Supports for multiple levels of logging within scene loading
  70372. * @returns the human readable light info
  70373. */
  70374. toString(fullDetails?: boolean): string;
  70375. /** @hidden */
  70376. protected _syncParentEnabledState(): void;
  70377. /**
  70378. * Set the enabled state of this node.
  70379. * @param value - the new enabled state
  70380. */
  70381. setEnabled(value: boolean): void;
  70382. /**
  70383. * Returns the Light associated shadow generator if any.
  70384. * @return the associated shadow generator.
  70385. */
  70386. getShadowGenerator(): Nullable<IShadowGenerator>;
  70387. /**
  70388. * Returns a Vector3, the absolute light position in the World.
  70389. * @returns the world space position of the light
  70390. */
  70391. getAbsolutePosition(): Vector3;
  70392. /**
  70393. * Specifies if the light will affect the passed mesh.
  70394. * @param mesh The mesh to test against the light
  70395. * @return true the mesh is affected otherwise, false.
  70396. */
  70397. canAffectMesh(mesh: AbstractMesh): boolean;
  70398. /**
  70399. * Sort function to order lights for rendering.
  70400. * @param a First Light object to compare to second.
  70401. * @param b Second Light object to compare first.
  70402. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70403. */
  70404. static CompareLightsPriority(a: Light, b: Light): number;
  70405. /**
  70406. * Releases resources associated with this node.
  70407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70409. */
  70410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70411. /**
  70412. * Returns the light type ID (integer).
  70413. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70414. */
  70415. getTypeID(): number;
  70416. /**
  70417. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70418. * @returns the scaled intensity in intensity mode unit
  70419. */
  70420. getScaledIntensity(): number;
  70421. /**
  70422. * Returns a new Light object, named "name", from the current one.
  70423. * @param name The name of the cloned light
  70424. * @returns the new created light
  70425. */
  70426. clone(name: string): Nullable<Light>;
  70427. /**
  70428. * Serializes the current light into a Serialization object.
  70429. * @returns the serialized object.
  70430. */
  70431. serialize(): any;
  70432. /**
  70433. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70434. * This new light is named "name" and added to the passed scene.
  70435. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70436. * @param name The friendly name of the light
  70437. * @param scene The scene the new light will belong to
  70438. * @returns the constructor function
  70439. */
  70440. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70441. /**
  70442. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70443. * @param parsedLight The JSON representation of the light
  70444. * @param scene The scene to create the parsed light in
  70445. * @returns the created light after parsing
  70446. */
  70447. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70448. private _hookArrayForExcluded;
  70449. private _hookArrayForIncludedOnly;
  70450. private _resyncMeshes;
  70451. /**
  70452. * Forces the meshes to update their light related information in their rendering used effects
  70453. * @hidden Internal Use Only
  70454. */
  70455. _markMeshesAsLightDirty(): void;
  70456. /**
  70457. * Recomputes the cached photometric scale if needed.
  70458. */
  70459. private _computePhotometricScale;
  70460. /**
  70461. * Returns the Photometric Scale according to the light type and intensity mode.
  70462. */
  70463. private _getPhotometricScale;
  70464. /**
  70465. * Reorder the light in the scene according to their defined priority.
  70466. * @hidden Internal Use Only
  70467. */
  70468. _reorderLightsInScene(): void;
  70469. /**
  70470. * Prepares the list of defines specific to the light type.
  70471. * @param defines the list of defines
  70472. * @param lightIndex defines the index of the light for the effect
  70473. */
  70474. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70475. }
  70476. }
  70477. declare module BABYLON {
  70478. /**
  70479. * Interface used to define Action
  70480. */
  70481. export interface IAction {
  70482. /**
  70483. * Trigger for the action
  70484. */
  70485. trigger: number;
  70486. /** Options of the trigger */
  70487. triggerOptions: any;
  70488. /**
  70489. * Gets the trigger parameters
  70490. * @returns the trigger parameters
  70491. */
  70492. getTriggerParameter(): any;
  70493. /**
  70494. * Internal only - executes current action event
  70495. * @hidden
  70496. */
  70497. _executeCurrent(evt?: ActionEvent): void;
  70498. /**
  70499. * Serialize placeholder for child classes
  70500. * @param parent of child
  70501. * @returns the serialized object
  70502. */
  70503. serialize(parent: any): any;
  70504. /**
  70505. * Internal only
  70506. * @hidden
  70507. */
  70508. _prepare(): void;
  70509. /**
  70510. * Internal only - manager for action
  70511. * @hidden
  70512. */
  70513. _actionManager: AbstractActionManager;
  70514. }
  70515. /**
  70516. * The action to be carried out following a trigger
  70517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70518. */
  70519. export class Action implements IAction {
  70520. /** the trigger, with or without parameters, for the action */
  70521. triggerOptions: any;
  70522. /**
  70523. * Trigger for the action
  70524. */
  70525. trigger: number;
  70526. /**
  70527. * Internal only - manager for action
  70528. * @hidden
  70529. */
  70530. _actionManager: ActionManager;
  70531. private _nextActiveAction;
  70532. private _child;
  70533. private _condition?;
  70534. private _triggerParameter;
  70535. /**
  70536. * An event triggered prior to action being executed.
  70537. */
  70538. onBeforeExecuteObservable: Observable<Action>;
  70539. /**
  70540. * Creates a new Action
  70541. * @param triggerOptions the trigger, with or without parameters, for the action
  70542. * @param condition an optional determinant of action
  70543. */
  70544. constructor(
  70545. /** the trigger, with or without parameters, for the action */
  70546. triggerOptions: any, condition?: Condition);
  70547. /**
  70548. * Internal only
  70549. * @hidden
  70550. */
  70551. _prepare(): void;
  70552. /**
  70553. * Gets the trigger parameters
  70554. * @returns the trigger parameters
  70555. */
  70556. getTriggerParameter(): any;
  70557. /**
  70558. * Internal only - executes current action event
  70559. * @hidden
  70560. */
  70561. _executeCurrent(evt?: ActionEvent): void;
  70562. /**
  70563. * Execute placeholder for child classes
  70564. * @param evt optional action event
  70565. */
  70566. execute(evt?: ActionEvent): void;
  70567. /**
  70568. * Skips to next active action
  70569. */
  70570. skipToNextActiveAction(): void;
  70571. /**
  70572. * Adds action to chain of actions, may be a DoNothingAction
  70573. * @param action defines the next action to execute
  70574. * @returns The action passed in
  70575. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70576. */
  70577. then(action: Action): Action;
  70578. /**
  70579. * Internal only
  70580. * @hidden
  70581. */
  70582. _getProperty(propertyPath: string): string;
  70583. /**
  70584. * Internal only
  70585. * @hidden
  70586. */
  70587. _getEffectiveTarget(target: any, propertyPath: string): any;
  70588. /**
  70589. * Serialize placeholder for child classes
  70590. * @param parent of child
  70591. * @returns the serialized object
  70592. */
  70593. serialize(parent: any): any;
  70594. /**
  70595. * Internal only called by serialize
  70596. * @hidden
  70597. */
  70598. protected _serialize(serializedAction: any, parent?: any): any;
  70599. /**
  70600. * Internal only
  70601. * @hidden
  70602. */
  70603. static _SerializeValueAsString: (value: any) => string;
  70604. /**
  70605. * Internal only
  70606. * @hidden
  70607. */
  70608. static _GetTargetProperty: (target: Scene | Node) => {
  70609. name: string;
  70610. targetType: string;
  70611. value: string;
  70612. };
  70613. }
  70614. }
  70615. declare module BABYLON {
  70616. /**
  70617. * A Condition applied to an Action
  70618. */
  70619. export class Condition {
  70620. /**
  70621. * Internal only - manager for action
  70622. * @hidden
  70623. */
  70624. _actionManager: ActionManager;
  70625. /**
  70626. * Internal only
  70627. * @hidden
  70628. */
  70629. _evaluationId: number;
  70630. /**
  70631. * Internal only
  70632. * @hidden
  70633. */
  70634. _currentResult: boolean;
  70635. /**
  70636. * Creates a new Condition
  70637. * @param actionManager the manager of the action the condition is applied to
  70638. */
  70639. constructor(actionManager: ActionManager);
  70640. /**
  70641. * Check if the current condition is valid
  70642. * @returns a boolean
  70643. */
  70644. isValid(): boolean;
  70645. /**
  70646. * Internal only
  70647. * @hidden
  70648. */
  70649. _getProperty(propertyPath: string): string;
  70650. /**
  70651. * Internal only
  70652. * @hidden
  70653. */
  70654. _getEffectiveTarget(target: any, propertyPath: string): any;
  70655. /**
  70656. * Serialize placeholder for child classes
  70657. * @returns the serialized object
  70658. */
  70659. serialize(): any;
  70660. /**
  70661. * Internal only
  70662. * @hidden
  70663. */
  70664. protected _serialize(serializedCondition: any): any;
  70665. }
  70666. /**
  70667. * Defines specific conditional operators as extensions of Condition
  70668. */
  70669. export class ValueCondition extends Condition {
  70670. /** path to specify the property of the target the conditional operator uses */
  70671. propertyPath: string;
  70672. /** the value compared by the conditional operator against the current value of the property */
  70673. value: any;
  70674. /** the conditional operator, default ValueCondition.IsEqual */
  70675. operator: number;
  70676. /**
  70677. * Internal only
  70678. * @hidden
  70679. */
  70680. private static _IsEqual;
  70681. /**
  70682. * Internal only
  70683. * @hidden
  70684. */
  70685. private static _IsDifferent;
  70686. /**
  70687. * Internal only
  70688. * @hidden
  70689. */
  70690. private static _IsGreater;
  70691. /**
  70692. * Internal only
  70693. * @hidden
  70694. */
  70695. private static _IsLesser;
  70696. /**
  70697. * returns the number for IsEqual
  70698. */
  70699. static readonly IsEqual: number;
  70700. /**
  70701. * Returns the number for IsDifferent
  70702. */
  70703. static readonly IsDifferent: number;
  70704. /**
  70705. * Returns the number for IsGreater
  70706. */
  70707. static readonly IsGreater: number;
  70708. /**
  70709. * Returns the number for IsLesser
  70710. */
  70711. static readonly IsLesser: number;
  70712. /**
  70713. * Internal only The action manager for the condition
  70714. * @hidden
  70715. */
  70716. _actionManager: ActionManager;
  70717. /**
  70718. * Internal only
  70719. * @hidden
  70720. */
  70721. private _target;
  70722. /**
  70723. * Internal only
  70724. * @hidden
  70725. */
  70726. private _effectiveTarget;
  70727. /**
  70728. * Internal only
  70729. * @hidden
  70730. */
  70731. private _property;
  70732. /**
  70733. * Creates a new ValueCondition
  70734. * @param actionManager manager for the action the condition applies to
  70735. * @param target for the action
  70736. * @param propertyPath path to specify the property of the target the conditional operator uses
  70737. * @param value the value compared by the conditional operator against the current value of the property
  70738. * @param operator the conditional operator, default ValueCondition.IsEqual
  70739. */
  70740. constructor(actionManager: ActionManager, target: any,
  70741. /** path to specify the property of the target the conditional operator uses */
  70742. propertyPath: string,
  70743. /** the value compared by the conditional operator against the current value of the property */
  70744. value: any,
  70745. /** the conditional operator, default ValueCondition.IsEqual */
  70746. operator?: number);
  70747. /**
  70748. * Compares the given value with the property value for the specified conditional operator
  70749. * @returns the result of the comparison
  70750. */
  70751. isValid(): boolean;
  70752. /**
  70753. * Serialize the ValueCondition into a JSON compatible object
  70754. * @returns serialization object
  70755. */
  70756. serialize(): any;
  70757. /**
  70758. * Gets the name of the conditional operator for the ValueCondition
  70759. * @param operator the conditional operator
  70760. * @returns the name
  70761. */
  70762. static GetOperatorName(operator: number): string;
  70763. }
  70764. /**
  70765. * Defines a predicate condition as an extension of Condition
  70766. */
  70767. export class PredicateCondition extends Condition {
  70768. /** defines the predicate function used to validate the condition */
  70769. predicate: () => boolean;
  70770. /**
  70771. * Internal only - manager for action
  70772. * @hidden
  70773. */
  70774. _actionManager: ActionManager;
  70775. /**
  70776. * Creates a new PredicateCondition
  70777. * @param actionManager manager for the action the condition applies to
  70778. * @param predicate defines the predicate function used to validate the condition
  70779. */
  70780. constructor(actionManager: ActionManager,
  70781. /** defines the predicate function used to validate the condition */
  70782. predicate: () => boolean);
  70783. /**
  70784. * @returns the validity of the predicate condition
  70785. */
  70786. isValid(): boolean;
  70787. }
  70788. /**
  70789. * Defines a state condition as an extension of Condition
  70790. */
  70791. export class StateCondition extends Condition {
  70792. /** Value to compare with target state */
  70793. value: string;
  70794. /**
  70795. * Internal only - manager for action
  70796. * @hidden
  70797. */
  70798. _actionManager: ActionManager;
  70799. /**
  70800. * Internal only
  70801. * @hidden
  70802. */
  70803. private _target;
  70804. /**
  70805. * Creates a new StateCondition
  70806. * @param actionManager manager for the action the condition applies to
  70807. * @param target of the condition
  70808. * @param value to compare with target state
  70809. */
  70810. constructor(actionManager: ActionManager, target: any,
  70811. /** Value to compare with target state */
  70812. value: string);
  70813. /**
  70814. * Gets a boolean indicating if the current condition is met
  70815. * @returns the validity of the state
  70816. */
  70817. isValid(): boolean;
  70818. /**
  70819. * Serialize the StateCondition into a JSON compatible object
  70820. * @returns serialization object
  70821. */
  70822. serialize(): any;
  70823. }
  70824. }
  70825. declare module BABYLON {
  70826. /**
  70827. * This defines an action responsible to toggle a boolean once triggered.
  70828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70829. */
  70830. export class SwitchBooleanAction extends Action {
  70831. /**
  70832. * The path to the boolean property in the target object
  70833. */
  70834. propertyPath: string;
  70835. private _target;
  70836. private _effectiveTarget;
  70837. private _property;
  70838. /**
  70839. * Instantiate the action
  70840. * @param triggerOptions defines the trigger options
  70841. * @param target defines the object containing the boolean
  70842. * @param propertyPath defines the path to the boolean property in the target object
  70843. * @param condition defines the trigger related conditions
  70844. */
  70845. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70846. /** @hidden */
  70847. _prepare(): void;
  70848. /**
  70849. * Execute the action toggle the boolean value.
  70850. */
  70851. execute(): void;
  70852. /**
  70853. * Serializes the actions and its related information.
  70854. * @param parent defines the object to serialize in
  70855. * @returns the serialized object
  70856. */
  70857. serialize(parent: any): any;
  70858. }
  70859. /**
  70860. * This defines an action responsible to set a the state field of the target
  70861. * to a desired value once triggered.
  70862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70863. */
  70864. export class SetStateAction extends Action {
  70865. /**
  70866. * The value to store in the state field.
  70867. */
  70868. value: string;
  70869. private _target;
  70870. /**
  70871. * Instantiate the action
  70872. * @param triggerOptions defines the trigger options
  70873. * @param target defines the object containing the state property
  70874. * @param value defines the value to store in the state field
  70875. * @param condition defines the trigger related conditions
  70876. */
  70877. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70878. /**
  70879. * Execute the action and store the value on the target state property.
  70880. */
  70881. execute(): void;
  70882. /**
  70883. * Serializes the actions and its related information.
  70884. * @param parent defines the object to serialize in
  70885. * @returns the serialized object
  70886. */
  70887. serialize(parent: any): any;
  70888. }
  70889. /**
  70890. * This defines an action responsible to set a property of the target
  70891. * to a desired value once triggered.
  70892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70893. */
  70894. export class SetValueAction extends Action {
  70895. /**
  70896. * The path of the property to set in the target.
  70897. */
  70898. propertyPath: string;
  70899. /**
  70900. * The value to set in the property
  70901. */
  70902. value: any;
  70903. private _target;
  70904. private _effectiveTarget;
  70905. private _property;
  70906. /**
  70907. * Instantiate the action
  70908. * @param triggerOptions defines the trigger options
  70909. * @param target defines the object containing the property
  70910. * @param propertyPath defines the path of the property to set in the target
  70911. * @param value defines the value to set in the property
  70912. * @param condition defines the trigger related conditions
  70913. */
  70914. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70915. /** @hidden */
  70916. _prepare(): void;
  70917. /**
  70918. * Execute the action and set the targetted property to the desired value.
  70919. */
  70920. execute(): void;
  70921. /**
  70922. * Serializes the actions and its related information.
  70923. * @param parent defines the object to serialize in
  70924. * @returns the serialized object
  70925. */
  70926. serialize(parent: any): any;
  70927. }
  70928. /**
  70929. * This defines an action responsible to increment the target value
  70930. * to a desired value once triggered.
  70931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70932. */
  70933. export class IncrementValueAction extends Action {
  70934. /**
  70935. * The path of the property to increment in the target.
  70936. */
  70937. propertyPath: string;
  70938. /**
  70939. * The value we should increment the property by.
  70940. */
  70941. value: any;
  70942. private _target;
  70943. private _effectiveTarget;
  70944. private _property;
  70945. /**
  70946. * Instantiate the action
  70947. * @param triggerOptions defines the trigger options
  70948. * @param target defines the object containing the property
  70949. * @param propertyPath defines the path of the property to increment in the target
  70950. * @param value defines the value value we should increment the property by
  70951. * @param condition defines the trigger related conditions
  70952. */
  70953. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70954. /** @hidden */
  70955. _prepare(): void;
  70956. /**
  70957. * Execute the action and increment the target of the value amount.
  70958. */
  70959. execute(): void;
  70960. /**
  70961. * Serializes the actions and its related information.
  70962. * @param parent defines the object to serialize in
  70963. * @returns the serialized object
  70964. */
  70965. serialize(parent: any): any;
  70966. }
  70967. /**
  70968. * This defines an action responsible to start an animation once triggered.
  70969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70970. */
  70971. export class PlayAnimationAction extends Action {
  70972. /**
  70973. * Where the animation should start (animation frame)
  70974. */
  70975. from: number;
  70976. /**
  70977. * Where the animation should stop (animation frame)
  70978. */
  70979. to: number;
  70980. /**
  70981. * Define if the animation should loop or stop after the first play.
  70982. */
  70983. loop?: boolean;
  70984. private _target;
  70985. /**
  70986. * Instantiate the action
  70987. * @param triggerOptions defines the trigger options
  70988. * @param target defines the target animation or animation name
  70989. * @param from defines from where the animation should start (animation frame)
  70990. * @param end defines where the animation should stop (animation frame)
  70991. * @param loop defines if the animation should loop or stop after the first play
  70992. * @param condition defines the trigger related conditions
  70993. */
  70994. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70995. /** @hidden */
  70996. _prepare(): void;
  70997. /**
  70998. * Execute the action and play the animation.
  70999. */
  71000. execute(): void;
  71001. /**
  71002. * Serializes the actions and its related information.
  71003. * @param parent defines the object to serialize in
  71004. * @returns the serialized object
  71005. */
  71006. serialize(parent: any): any;
  71007. }
  71008. /**
  71009. * This defines an action responsible to stop an animation once triggered.
  71010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71011. */
  71012. export class StopAnimationAction extends Action {
  71013. private _target;
  71014. /**
  71015. * Instantiate the action
  71016. * @param triggerOptions defines the trigger options
  71017. * @param target defines the target animation or animation name
  71018. * @param condition defines the trigger related conditions
  71019. */
  71020. constructor(triggerOptions: any, target: any, condition?: Condition);
  71021. /** @hidden */
  71022. _prepare(): void;
  71023. /**
  71024. * Execute the action and stop the animation.
  71025. */
  71026. execute(): void;
  71027. /**
  71028. * Serializes the actions and its related information.
  71029. * @param parent defines the object to serialize in
  71030. * @returns the serialized object
  71031. */
  71032. serialize(parent: any): any;
  71033. }
  71034. /**
  71035. * This defines an action responsible that does nothing once triggered.
  71036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71037. */
  71038. export class DoNothingAction extends Action {
  71039. /**
  71040. * Instantiate the action
  71041. * @param triggerOptions defines the trigger options
  71042. * @param condition defines the trigger related conditions
  71043. */
  71044. constructor(triggerOptions?: any, condition?: Condition);
  71045. /**
  71046. * Execute the action and do nothing.
  71047. */
  71048. execute(): void;
  71049. /**
  71050. * Serializes the actions and its related information.
  71051. * @param parent defines the object to serialize in
  71052. * @returns the serialized object
  71053. */
  71054. serialize(parent: any): any;
  71055. }
  71056. /**
  71057. * This defines an action responsible to trigger several actions once triggered.
  71058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71059. */
  71060. export class CombineAction extends Action {
  71061. /**
  71062. * The list of aggregated animations to run.
  71063. */
  71064. children: Action[];
  71065. /**
  71066. * Instantiate the action
  71067. * @param triggerOptions defines the trigger options
  71068. * @param children defines the list of aggregated animations to run
  71069. * @param condition defines the trigger related conditions
  71070. */
  71071. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71072. /** @hidden */
  71073. _prepare(): void;
  71074. /**
  71075. * Execute the action and executes all the aggregated actions.
  71076. */
  71077. execute(evt: ActionEvent): void;
  71078. /**
  71079. * Serializes the actions and its related information.
  71080. * @param parent defines the object to serialize in
  71081. * @returns the serialized object
  71082. */
  71083. serialize(parent: any): any;
  71084. }
  71085. /**
  71086. * This defines an action responsible to run code (external event) once triggered.
  71087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71088. */
  71089. export class ExecuteCodeAction extends Action {
  71090. /**
  71091. * The callback function to run.
  71092. */
  71093. func: (evt: ActionEvent) => void;
  71094. /**
  71095. * Instantiate the action
  71096. * @param triggerOptions defines the trigger options
  71097. * @param func defines the callback function to run
  71098. * @param condition defines the trigger related conditions
  71099. */
  71100. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71101. /**
  71102. * Execute the action and run the attached code.
  71103. */
  71104. execute(evt: ActionEvent): void;
  71105. }
  71106. /**
  71107. * This defines an action responsible to set the parent property of the target once triggered.
  71108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71109. */
  71110. export class SetParentAction extends Action {
  71111. private _parent;
  71112. private _target;
  71113. /**
  71114. * Instantiate the action
  71115. * @param triggerOptions defines the trigger options
  71116. * @param target defines the target containing the parent property
  71117. * @param parent defines from where the animation should start (animation frame)
  71118. * @param condition defines the trigger related conditions
  71119. */
  71120. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71121. /** @hidden */
  71122. _prepare(): void;
  71123. /**
  71124. * Execute the action and set the parent property.
  71125. */
  71126. execute(): void;
  71127. /**
  71128. * Serializes the actions and its related information.
  71129. * @param parent defines the object to serialize in
  71130. * @returns the serialized object
  71131. */
  71132. serialize(parent: any): any;
  71133. }
  71134. }
  71135. declare module BABYLON {
  71136. /**
  71137. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71138. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71140. */
  71141. export class ActionManager extends AbstractActionManager {
  71142. /**
  71143. * Nothing
  71144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71145. */
  71146. static readonly NothingTrigger: number;
  71147. /**
  71148. * On pick
  71149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71150. */
  71151. static readonly OnPickTrigger: number;
  71152. /**
  71153. * On left pick
  71154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71155. */
  71156. static readonly OnLeftPickTrigger: number;
  71157. /**
  71158. * On right pick
  71159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71160. */
  71161. static readonly OnRightPickTrigger: number;
  71162. /**
  71163. * On center pick
  71164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71165. */
  71166. static readonly OnCenterPickTrigger: number;
  71167. /**
  71168. * On pick down
  71169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71170. */
  71171. static readonly OnPickDownTrigger: number;
  71172. /**
  71173. * On double pick
  71174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71175. */
  71176. static readonly OnDoublePickTrigger: number;
  71177. /**
  71178. * On pick up
  71179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71180. */
  71181. static readonly OnPickUpTrigger: number;
  71182. /**
  71183. * On pick out.
  71184. * This trigger will only be raised if you also declared a OnPickDown
  71185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71186. */
  71187. static readonly OnPickOutTrigger: number;
  71188. /**
  71189. * On long press
  71190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71191. */
  71192. static readonly OnLongPressTrigger: number;
  71193. /**
  71194. * On pointer over
  71195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71196. */
  71197. static readonly OnPointerOverTrigger: number;
  71198. /**
  71199. * On pointer out
  71200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71201. */
  71202. static readonly OnPointerOutTrigger: number;
  71203. /**
  71204. * On every frame
  71205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71206. */
  71207. static readonly OnEveryFrameTrigger: number;
  71208. /**
  71209. * On intersection enter
  71210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71211. */
  71212. static readonly OnIntersectionEnterTrigger: number;
  71213. /**
  71214. * On intersection exit
  71215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71216. */
  71217. static readonly OnIntersectionExitTrigger: number;
  71218. /**
  71219. * On key down
  71220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71221. */
  71222. static readonly OnKeyDownTrigger: number;
  71223. /**
  71224. * On key up
  71225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71226. */
  71227. static readonly OnKeyUpTrigger: number;
  71228. private _scene;
  71229. /**
  71230. * Creates a new action manager
  71231. * @param scene defines the hosting scene
  71232. */
  71233. constructor(scene: Scene);
  71234. /**
  71235. * Releases all associated resources
  71236. */
  71237. dispose(): void;
  71238. /**
  71239. * Gets hosting scene
  71240. * @returns the hosting scene
  71241. */
  71242. getScene(): Scene;
  71243. /**
  71244. * Does this action manager handles actions of any of the given triggers
  71245. * @param triggers defines the triggers to be tested
  71246. * @return a boolean indicating whether one (or more) of the triggers is handled
  71247. */
  71248. hasSpecificTriggers(triggers: number[]): boolean;
  71249. /**
  71250. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71251. * speed.
  71252. * @param triggerA defines the trigger to be tested
  71253. * @param triggerB defines the trigger to be tested
  71254. * @return a boolean indicating whether one (or more) of the triggers is handled
  71255. */
  71256. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71257. /**
  71258. * Does this action manager handles actions of a given trigger
  71259. * @param trigger defines the trigger to be tested
  71260. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71261. * @return whether the trigger is handled
  71262. */
  71263. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71264. /**
  71265. * Does this action manager has pointer triggers
  71266. */
  71267. readonly hasPointerTriggers: boolean;
  71268. /**
  71269. * Does this action manager has pick triggers
  71270. */
  71271. readonly hasPickTriggers: boolean;
  71272. /**
  71273. * Registers an action to this action manager
  71274. * @param action defines the action to be registered
  71275. * @return the action amended (prepared) after registration
  71276. */
  71277. registerAction(action: IAction): Nullable<IAction>;
  71278. /**
  71279. * Unregisters an action to this action manager
  71280. * @param action defines the action to be unregistered
  71281. * @return a boolean indicating whether the action has been unregistered
  71282. */
  71283. unregisterAction(action: IAction): Boolean;
  71284. /**
  71285. * Process a specific trigger
  71286. * @param trigger defines the trigger to process
  71287. * @param evt defines the event details to be processed
  71288. */
  71289. processTrigger(trigger: number, evt?: IActionEvent): void;
  71290. /** @hidden */
  71291. _getEffectiveTarget(target: any, propertyPath: string): any;
  71292. /** @hidden */
  71293. _getProperty(propertyPath: string): string;
  71294. /**
  71295. * Serialize this manager to a JSON object
  71296. * @param name defines the property name to store this manager
  71297. * @returns a JSON representation of this manager
  71298. */
  71299. serialize(name: string): any;
  71300. /**
  71301. * Creates a new ActionManager from a JSON data
  71302. * @param parsedActions defines the JSON data to read from
  71303. * @param object defines the hosting mesh
  71304. * @param scene defines the hosting scene
  71305. */
  71306. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71307. /**
  71308. * Get a trigger name by index
  71309. * @param trigger defines the trigger index
  71310. * @returns a trigger name
  71311. */
  71312. static GetTriggerName(trigger: number): string;
  71313. }
  71314. }
  71315. declare module BABYLON {
  71316. /**
  71317. * Class representing a ray with position and direction
  71318. */
  71319. export class Ray {
  71320. /** origin point */
  71321. origin: Vector3;
  71322. /** direction */
  71323. direction: Vector3;
  71324. /** length of the ray */
  71325. length: number;
  71326. private static readonly TmpVector3;
  71327. private _tmpRay;
  71328. /**
  71329. * Creates a new ray
  71330. * @param origin origin point
  71331. * @param direction direction
  71332. * @param length length of the ray
  71333. */
  71334. constructor(
  71335. /** origin point */
  71336. origin: Vector3,
  71337. /** direction */
  71338. direction: Vector3,
  71339. /** length of the ray */
  71340. length?: number);
  71341. /**
  71342. * Checks if the ray intersects a box
  71343. * @param minimum bound of the box
  71344. * @param maximum bound of the box
  71345. * @param intersectionTreshold extra extend to be added to the box in all direction
  71346. * @returns if the box was hit
  71347. */
  71348. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71349. /**
  71350. * Checks if the ray intersects a box
  71351. * @param box the bounding box to check
  71352. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71353. * @returns if the box was hit
  71354. */
  71355. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71356. /**
  71357. * If the ray hits a sphere
  71358. * @param sphere the bounding sphere to check
  71359. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71360. * @returns true if it hits the sphere
  71361. */
  71362. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71363. /**
  71364. * If the ray hits a triange
  71365. * @param vertex0 triangle vertex
  71366. * @param vertex1 triangle vertex
  71367. * @param vertex2 triangle vertex
  71368. * @returns intersection information if hit
  71369. */
  71370. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71371. /**
  71372. * Checks if ray intersects a plane
  71373. * @param plane the plane to check
  71374. * @returns the distance away it was hit
  71375. */
  71376. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71377. /**
  71378. * Checks if ray intersects a mesh
  71379. * @param mesh the mesh to check
  71380. * @param fastCheck if only the bounding box should checked
  71381. * @returns picking info of the intersecton
  71382. */
  71383. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71384. /**
  71385. * Checks if ray intersects a mesh
  71386. * @param meshes the meshes to check
  71387. * @param fastCheck if only the bounding box should checked
  71388. * @param results array to store result in
  71389. * @returns Array of picking infos
  71390. */
  71391. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71392. private _comparePickingInfo;
  71393. private static smallnum;
  71394. private static rayl;
  71395. /**
  71396. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71397. * @param sega the first point of the segment to test the intersection against
  71398. * @param segb the second point of the segment to test the intersection against
  71399. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71400. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71401. */
  71402. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71403. /**
  71404. * Update the ray from viewport position
  71405. * @param x position
  71406. * @param y y position
  71407. * @param viewportWidth viewport width
  71408. * @param viewportHeight viewport height
  71409. * @param world world matrix
  71410. * @param view view matrix
  71411. * @param projection projection matrix
  71412. * @returns this ray updated
  71413. */
  71414. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71415. /**
  71416. * Creates a ray with origin and direction of 0,0,0
  71417. * @returns the new ray
  71418. */
  71419. static Zero(): Ray;
  71420. /**
  71421. * Creates a new ray from screen space and viewport
  71422. * @param x position
  71423. * @param y y position
  71424. * @param viewportWidth viewport width
  71425. * @param viewportHeight viewport height
  71426. * @param world world matrix
  71427. * @param view view matrix
  71428. * @param projection projection matrix
  71429. * @returns new ray
  71430. */
  71431. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71432. /**
  71433. * 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
  71434. * transformed to the given world matrix.
  71435. * @param origin The origin point
  71436. * @param end The end point
  71437. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71438. * @returns the new ray
  71439. */
  71440. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71441. /**
  71442. * Transforms a ray by a matrix
  71443. * @param ray ray to transform
  71444. * @param matrix matrix to apply
  71445. * @returns the resulting new ray
  71446. */
  71447. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71448. /**
  71449. * Transforms a ray by a matrix
  71450. * @param ray ray to transform
  71451. * @param matrix matrix to apply
  71452. * @param result ray to store result in
  71453. */
  71454. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71455. /**
  71456. * Unproject a ray from screen space to object space
  71457. * @param sourceX defines the screen space x coordinate to use
  71458. * @param sourceY defines the screen space y coordinate to use
  71459. * @param viewportWidth defines the current width of the viewport
  71460. * @param viewportHeight defines the current height of the viewport
  71461. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71462. * @param view defines the view matrix to use
  71463. * @param projection defines the projection matrix to use
  71464. */
  71465. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71466. }
  71467. /**
  71468. * Type used to define predicate used to select faces when a mesh intersection is detected
  71469. */
  71470. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71471. interface Scene {
  71472. /** @hidden */
  71473. _tempPickingRay: Nullable<Ray>;
  71474. /** @hidden */
  71475. _cachedRayForTransform: Ray;
  71476. /** @hidden */
  71477. _pickWithRayInverseMatrix: Matrix;
  71478. /** @hidden */
  71479. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71480. /** @hidden */
  71481. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71482. }
  71483. }
  71484. declare module BABYLON {
  71485. /**
  71486. * Groups all the scene component constants in one place to ease maintenance.
  71487. * @hidden
  71488. */
  71489. export class SceneComponentConstants {
  71490. static readonly NAME_EFFECTLAYER: string;
  71491. static readonly NAME_LAYER: string;
  71492. static readonly NAME_LENSFLARESYSTEM: string;
  71493. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71494. static readonly NAME_PARTICLESYSTEM: string;
  71495. static readonly NAME_GAMEPAD: string;
  71496. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71497. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71498. static readonly NAME_DEPTHRENDERER: string;
  71499. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71500. static readonly NAME_SPRITE: string;
  71501. static readonly NAME_OUTLINERENDERER: string;
  71502. static readonly NAME_PROCEDURALTEXTURE: string;
  71503. static readonly NAME_SHADOWGENERATOR: string;
  71504. static readonly NAME_OCTREE: string;
  71505. static readonly NAME_PHYSICSENGINE: string;
  71506. static readonly NAME_AUDIO: string;
  71507. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71508. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71509. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71510. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71511. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71512. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71513. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71514. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71515. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71516. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71517. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71518. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71519. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71520. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71521. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71522. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71523. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71524. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71525. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71526. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71527. static readonly STEP_AFTERRENDER_AUDIO: number;
  71528. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71529. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71530. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71531. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71532. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71533. static readonly STEP_POINTERMOVE_SPRITE: number;
  71534. static readonly STEP_POINTERDOWN_SPRITE: number;
  71535. static readonly STEP_POINTERUP_SPRITE: number;
  71536. }
  71537. /**
  71538. * This represents a scene component.
  71539. *
  71540. * This is used to decouple the dependency the scene is having on the different workloads like
  71541. * layers, post processes...
  71542. */
  71543. export interface ISceneComponent {
  71544. /**
  71545. * The name of the component. Each component must have a unique name.
  71546. */
  71547. name: string;
  71548. /**
  71549. * The scene the component belongs to.
  71550. */
  71551. scene: Scene;
  71552. /**
  71553. * Register the component to one instance of a 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. }
  71566. /**
  71567. * This represents a SERIALIZABLE scene component.
  71568. *
  71569. * This extends Scene Component to add Serialization methods on top.
  71570. */
  71571. export interface ISceneSerializableComponent extends ISceneComponent {
  71572. /**
  71573. * Adds all the element from the container to the scene
  71574. * @param container the container holding the elements
  71575. */
  71576. addFromContainer(container: AbstractScene): void;
  71577. /**
  71578. * Removes all the elements in the container from the scene
  71579. * @param container contains the elements to remove
  71580. * @param dispose if the removed element should be disposed (default: false)
  71581. */
  71582. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71583. /**
  71584. * Serializes the component data to the specified json object
  71585. * @param serializationObject The object to serialize to
  71586. */
  71587. serialize(serializationObject: any): void;
  71588. }
  71589. /**
  71590. * Strong typing of a Mesh related stage step action
  71591. */
  71592. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71593. /**
  71594. * Strong typing of a Evaluate Sub Mesh related stage step action
  71595. */
  71596. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71597. /**
  71598. * Strong typing of a Active Mesh related stage step action
  71599. */
  71600. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71601. /**
  71602. * Strong typing of a Camera related stage step action
  71603. */
  71604. export type CameraStageAction = (camera: Camera) => void;
  71605. /**
  71606. * Strong typing of a Camera Frame buffer related stage step action
  71607. */
  71608. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71609. /**
  71610. * Strong typing of a Render Target related stage step action
  71611. */
  71612. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71613. /**
  71614. * Strong typing of a RenderingGroup related stage step action
  71615. */
  71616. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71617. /**
  71618. * Strong typing of a Mesh Render related stage step action
  71619. */
  71620. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71621. /**
  71622. * Strong typing of a simple stage step action
  71623. */
  71624. export type SimpleStageAction = () => void;
  71625. /**
  71626. * Strong typing of a render target action.
  71627. */
  71628. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71629. /**
  71630. * Strong typing of a pointer move action.
  71631. */
  71632. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71633. /**
  71634. * Strong typing of a pointer up/down action.
  71635. */
  71636. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71637. /**
  71638. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71639. * @hidden
  71640. */
  71641. export class Stage<T extends Function> extends Array<{
  71642. index: number;
  71643. component: ISceneComponent;
  71644. action: T;
  71645. }> {
  71646. /**
  71647. * Hide ctor from the rest of the world.
  71648. * @param items The items to add.
  71649. */
  71650. private constructor();
  71651. /**
  71652. * Creates a new Stage.
  71653. * @returns A new instance of a Stage
  71654. */
  71655. static Create<T extends Function>(): Stage<T>;
  71656. /**
  71657. * Registers a step in an ordered way in the targeted stage.
  71658. * @param index Defines the position to register the step in
  71659. * @param component Defines the component attached to the step
  71660. * @param action Defines the action to launch during the step
  71661. */
  71662. registerStep(index: number, component: ISceneComponent, action: T): void;
  71663. /**
  71664. * Clears all the steps from the stage.
  71665. */
  71666. clear(): void;
  71667. }
  71668. }
  71669. declare module BABYLON {
  71670. interface Scene {
  71671. /** @hidden */
  71672. _pointerOverSprite: Nullable<Sprite>;
  71673. /** @hidden */
  71674. _pickedDownSprite: Nullable<Sprite>;
  71675. /** @hidden */
  71676. _tempSpritePickingRay: Nullable<Ray>;
  71677. /**
  71678. * All of the sprite managers added to this scene
  71679. * @see http://doc.babylonjs.com/babylon101/sprites
  71680. */
  71681. spriteManagers: Array<ISpriteManager>;
  71682. /**
  71683. * An event triggered when sprites rendering is about to start
  71684. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71685. */
  71686. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71687. /**
  71688. * An event triggered when sprites rendering is done
  71689. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71690. */
  71691. onAfterSpritesRenderingObservable: Observable<Scene>;
  71692. /** @hidden */
  71693. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71694. /** Launch a ray to try to pick a sprite in the scene
  71695. * @param x position on screen
  71696. * @param y position on screen
  71697. * @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
  71698. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71699. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71700. * @returns a PickingInfo
  71701. */
  71702. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71703. /** Use the given ray to pick a sprite in the scene
  71704. * @param ray The ray (in world space) to use to pick meshes
  71705. * @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
  71706. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71707. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71708. * @returns a PickingInfo
  71709. */
  71710. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71711. /**
  71712. * Force the sprite under the pointer
  71713. * @param sprite defines the sprite to use
  71714. */
  71715. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71716. /**
  71717. * Gets the sprite under the pointer
  71718. * @returns a Sprite or null if no sprite is under the pointer
  71719. */
  71720. getPointerOverSprite(): Nullable<Sprite>;
  71721. }
  71722. /**
  71723. * Defines the sprite scene component responsible to manage sprites
  71724. * in a given scene.
  71725. */
  71726. export class SpriteSceneComponent implements ISceneComponent {
  71727. /**
  71728. * The component name helpfull to identify the component in the list of scene components.
  71729. */
  71730. readonly name: string;
  71731. /**
  71732. * The scene the component belongs to.
  71733. */
  71734. scene: Scene;
  71735. /** @hidden */
  71736. private _spritePredicate;
  71737. /**
  71738. * Creates a new instance of the component for the given scene
  71739. * @param scene Defines the scene to register the component in
  71740. */
  71741. constructor(scene: Scene);
  71742. /**
  71743. * Registers the component in a given scene
  71744. */
  71745. register(): void;
  71746. /**
  71747. * Rebuilds the elements related to this component in case of
  71748. * context lost for instance.
  71749. */
  71750. rebuild(): void;
  71751. /**
  71752. * Disposes the component and the associated ressources.
  71753. */
  71754. dispose(): void;
  71755. private _pickSpriteButKeepRay;
  71756. private _pointerMove;
  71757. private _pointerDown;
  71758. private _pointerUp;
  71759. }
  71760. }
  71761. declare module BABYLON {
  71762. /** @hidden */
  71763. export var fogFragmentDeclaration: {
  71764. name: string;
  71765. shader: string;
  71766. };
  71767. }
  71768. declare module BABYLON {
  71769. /** @hidden */
  71770. export var fogFragment: {
  71771. name: string;
  71772. shader: string;
  71773. };
  71774. }
  71775. declare module BABYLON {
  71776. /** @hidden */
  71777. export var spritesPixelShader: {
  71778. name: string;
  71779. shader: string;
  71780. };
  71781. }
  71782. declare module BABYLON {
  71783. /** @hidden */
  71784. export var fogVertexDeclaration: {
  71785. name: string;
  71786. shader: string;
  71787. };
  71788. }
  71789. declare module BABYLON {
  71790. /** @hidden */
  71791. export var spritesVertexShader: {
  71792. name: string;
  71793. shader: string;
  71794. };
  71795. }
  71796. declare module BABYLON {
  71797. /**
  71798. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71799. */
  71800. export interface ISpriteManager extends IDisposable {
  71801. /**
  71802. * Restricts the camera to viewing objects with the same layerMask.
  71803. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71804. */
  71805. layerMask: number;
  71806. /**
  71807. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71808. */
  71809. isPickable: boolean;
  71810. /**
  71811. * Specifies the rendering group id for this mesh (0 by default)
  71812. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71813. */
  71814. renderingGroupId: number;
  71815. /**
  71816. * Defines the list of sprites managed by the manager.
  71817. */
  71818. sprites: Array<Sprite>;
  71819. /**
  71820. * Tests the intersection of a sprite with a specific ray.
  71821. * @param ray The ray we are sending to test the collision
  71822. * @param camera The camera space we are sending rays in
  71823. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71824. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71825. * @returns picking info or null.
  71826. */
  71827. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71828. /**
  71829. * Renders the list of sprites on screen.
  71830. */
  71831. render(): void;
  71832. }
  71833. /**
  71834. * Class used to manage multiple sprites on the same spritesheet
  71835. * @see http://doc.babylonjs.com/babylon101/sprites
  71836. */
  71837. export class SpriteManager implements ISpriteManager {
  71838. /** defines the manager's name */
  71839. name: string;
  71840. /** Gets the list of sprites */
  71841. sprites: Sprite[];
  71842. /** Gets or sets the rendering group id (0 by default) */
  71843. renderingGroupId: number;
  71844. /** Gets or sets camera layer mask */
  71845. layerMask: number;
  71846. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71847. fogEnabled: boolean;
  71848. /** Gets or sets a boolean indicating if the sprites are pickable */
  71849. isPickable: boolean;
  71850. /** Defines the default width of a cell in the spritesheet */
  71851. cellWidth: number;
  71852. /** Defines the default height of a cell in the spritesheet */
  71853. cellHeight: number;
  71854. /**
  71855. * An event triggered when the manager is disposed.
  71856. */
  71857. onDisposeObservable: Observable<SpriteManager>;
  71858. private _onDisposeObserver;
  71859. /**
  71860. * Callback called when the manager is disposed
  71861. */
  71862. onDispose: () => void;
  71863. private _capacity;
  71864. private _spriteTexture;
  71865. private _epsilon;
  71866. private _scene;
  71867. private _vertexData;
  71868. private _buffer;
  71869. private _vertexBuffers;
  71870. private _indexBuffer;
  71871. private _effectBase;
  71872. private _effectFog;
  71873. /**
  71874. * Gets or sets the spritesheet texture
  71875. */
  71876. texture: Texture;
  71877. /**
  71878. * Creates a new sprite manager
  71879. * @param name defines the manager's name
  71880. * @param imgUrl defines the sprite sheet url
  71881. * @param capacity defines the maximum allowed number of sprites
  71882. * @param cellSize defines the size of a sprite cell
  71883. * @param scene defines the hosting scene
  71884. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71885. * @param samplingMode defines the smapling mode to use with spritesheet
  71886. */
  71887. constructor(
  71888. /** defines the manager's name */
  71889. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71890. private _appendSpriteVertex;
  71891. /**
  71892. * Intersects the sprites with a ray
  71893. * @param ray defines the ray to intersect with
  71894. * @param camera defines the current active camera
  71895. * @param predicate defines a predicate used to select candidate sprites
  71896. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71897. * @returns null if no hit or a PickingInfo
  71898. */
  71899. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71900. /**
  71901. * Render all child sprites
  71902. */
  71903. render(): void;
  71904. /**
  71905. * Release associated resources
  71906. */
  71907. dispose(): void;
  71908. }
  71909. }
  71910. declare module BABYLON {
  71911. /**
  71912. * Class used to represent a sprite
  71913. * @see http://doc.babylonjs.com/babylon101/sprites
  71914. */
  71915. export class Sprite {
  71916. /** defines the name */
  71917. name: string;
  71918. /** Gets or sets the current world position */
  71919. position: Vector3;
  71920. /** Gets or sets the main color */
  71921. color: Color4;
  71922. /** Gets or sets the width */
  71923. width: number;
  71924. /** Gets or sets the height */
  71925. height: number;
  71926. /** Gets or sets rotation angle */
  71927. angle: number;
  71928. /** Gets or sets the cell index in the sprite sheet */
  71929. cellIndex: number;
  71930. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71931. invertU: number;
  71932. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71933. invertV: number;
  71934. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71935. disposeWhenFinishedAnimating: boolean;
  71936. /** Gets the list of attached animations */
  71937. animations: Animation[];
  71938. /** Gets or sets a boolean indicating if the sprite can be picked */
  71939. isPickable: boolean;
  71940. /**
  71941. * Gets or sets the associated action manager
  71942. */
  71943. actionManager: Nullable<ActionManager>;
  71944. private _animationStarted;
  71945. private _loopAnimation;
  71946. private _fromIndex;
  71947. private _toIndex;
  71948. private _delay;
  71949. private _direction;
  71950. private _manager;
  71951. private _time;
  71952. private _onAnimationEnd;
  71953. /**
  71954. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71955. */
  71956. isVisible: boolean;
  71957. /**
  71958. * Gets or sets the sprite size
  71959. */
  71960. size: number;
  71961. /**
  71962. * Creates a new Sprite
  71963. * @param name defines the name
  71964. * @param manager defines the manager
  71965. */
  71966. constructor(
  71967. /** defines the name */
  71968. name: string, manager: ISpriteManager);
  71969. /**
  71970. * Starts an animation
  71971. * @param from defines the initial key
  71972. * @param to defines the end key
  71973. * @param loop defines if the animation must loop
  71974. * @param delay defines the start delay (in ms)
  71975. * @param onAnimationEnd defines a callback to call when animation ends
  71976. */
  71977. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71978. /** Stops current animation (if any) */
  71979. stopAnimation(): void;
  71980. /** @hidden */
  71981. _animate(deltaTime: number): void;
  71982. /** Release associated resources */
  71983. dispose(): void;
  71984. }
  71985. }
  71986. declare module BABYLON {
  71987. /**
  71988. * Information about the result of picking within a scene
  71989. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71990. */
  71991. export class PickingInfo {
  71992. /** @hidden */
  71993. _pickingUnavailable: boolean;
  71994. /**
  71995. * If the pick collided with an object
  71996. */
  71997. hit: boolean;
  71998. /**
  71999. * Distance away where the pick collided
  72000. */
  72001. distance: number;
  72002. /**
  72003. * The location of pick collision
  72004. */
  72005. pickedPoint: Nullable<Vector3>;
  72006. /**
  72007. * The mesh corresponding the the pick collision
  72008. */
  72009. pickedMesh: Nullable<AbstractMesh>;
  72010. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  72011. bu: number;
  72012. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  72013. bv: number;
  72014. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  72015. faceId: number;
  72016. /** Id of the the submesh that was picked */
  72017. subMeshId: number;
  72018. /** If a sprite was picked, this will be the sprite the pick collided with */
  72019. pickedSprite: Nullable<Sprite>;
  72020. /**
  72021. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  72022. */
  72023. originMesh: Nullable<AbstractMesh>;
  72024. /**
  72025. * The ray that was used to perform the picking.
  72026. */
  72027. ray: Nullable<Ray>;
  72028. /**
  72029. * Gets the normal correspodning to the face the pick collided with
  72030. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  72031. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72032. * @returns The normal correspodning to the face the pick collided with
  72033. */
  72034. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72035. /**
  72036. * Gets the texture coordinates of where the pick occured
  72037. * @returns the vector containing the coordnates of the texture
  72038. */
  72039. getTextureCoordinates(): Nullable<Vector2>;
  72040. }
  72041. }
  72042. declare module BABYLON {
  72043. /**
  72044. * Gather the list of pointer event types as constants.
  72045. */
  72046. export class PointerEventTypes {
  72047. /**
  72048. * 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.
  72049. */
  72050. static readonly POINTERDOWN: number;
  72051. /**
  72052. * The pointerup event is fired when a pointer is no longer active.
  72053. */
  72054. static readonly POINTERUP: number;
  72055. /**
  72056. * The pointermove event is fired when a pointer changes coordinates.
  72057. */
  72058. static readonly POINTERMOVE: number;
  72059. /**
  72060. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72061. */
  72062. static readonly POINTERWHEEL: number;
  72063. /**
  72064. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72065. */
  72066. static readonly POINTERPICK: number;
  72067. /**
  72068. * The pointertap event is fired when a the object has been touched and released without drag.
  72069. */
  72070. static readonly POINTERTAP: number;
  72071. /**
  72072. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72073. */
  72074. static readonly POINTERDOUBLETAP: number;
  72075. }
  72076. /**
  72077. * Base class of pointer info types.
  72078. */
  72079. export class PointerInfoBase {
  72080. /**
  72081. * Defines the type of event (PointerEventTypes)
  72082. */
  72083. type: number;
  72084. /**
  72085. * Defines the related dom event
  72086. */
  72087. event: PointerEvent | MouseWheelEvent;
  72088. /**
  72089. * Instantiates the base class of pointers info.
  72090. * @param type Defines the type of event (PointerEventTypes)
  72091. * @param event Defines the related dom event
  72092. */
  72093. constructor(
  72094. /**
  72095. * Defines the type of event (PointerEventTypes)
  72096. */
  72097. type: number,
  72098. /**
  72099. * Defines the related dom event
  72100. */
  72101. event: PointerEvent | MouseWheelEvent);
  72102. }
  72103. /**
  72104. * This class is used to store pointer related info for the onPrePointerObservable event.
  72105. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72106. */
  72107. export class PointerInfoPre extends PointerInfoBase {
  72108. /**
  72109. * Ray from a pointer if availible (eg. 6dof controller)
  72110. */
  72111. ray: Nullable<Ray>;
  72112. /**
  72113. * Defines the local position of the pointer on the canvas.
  72114. */
  72115. localPosition: Vector2;
  72116. /**
  72117. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72118. */
  72119. skipOnPointerObservable: boolean;
  72120. /**
  72121. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72122. * @param type Defines the type of event (PointerEventTypes)
  72123. * @param event Defines the related dom event
  72124. * @param localX Defines the local x coordinates of the pointer when the event occured
  72125. * @param localY Defines the local y coordinates of the pointer when the event occured
  72126. */
  72127. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72128. }
  72129. /**
  72130. * This type contains all the data related to a pointer event in Babylon.js.
  72131. * 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.
  72132. */
  72133. export class PointerInfo extends PointerInfoBase {
  72134. /**
  72135. * Defines the picking info associated to the info (if any)\
  72136. */
  72137. pickInfo: Nullable<PickingInfo>;
  72138. /**
  72139. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72140. * @param type Defines the type of event (PointerEventTypes)
  72141. * @param event Defines the related dom event
  72142. * @param pickInfo Defines the picking info associated to the info (if any)\
  72143. */
  72144. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72145. /**
  72146. * Defines the picking info associated to the info (if any)\
  72147. */
  72148. pickInfo: Nullable<PickingInfo>);
  72149. }
  72150. /**
  72151. * Data relating to a touch event on the screen.
  72152. */
  72153. export interface PointerTouch {
  72154. /**
  72155. * X coordinate of touch.
  72156. */
  72157. x: number;
  72158. /**
  72159. * Y coordinate of touch.
  72160. */
  72161. y: number;
  72162. /**
  72163. * Id of touch. Unique for each finger.
  72164. */
  72165. pointerId: number;
  72166. /**
  72167. * Event type passed from DOM.
  72168. */
  72169. type: any;
  72170. }
  72171. }
  72172. declare module BABYLON {
  72173. /**
  72174. * Manage the mouse inputs to control the movement of a free camera.
  72175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72176. */
  72177. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72178. /**
  72179. * Define if touch is enabled in the mouse input
  72180. */
  72181. touchEnabled: boolean;
  72182. /**
  72183. * Defines the camera the input is attached to.
  72184. */
  72185. camera: FreeCamera;
  72186. /**
  72187. * Defines the buttons associated with the input to handle camera move.
  72188. */
  72189. buttons: number[];
  72190. /**
  72191. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72192. */
  72193. angularSensibility: number;
  72194. private _pointerInput;
  72195. private _onMouseMove;
  72196. private _observer;
  72197. private previousPosition;
  72198. /**
  72199. * Observable for when a pointer move event occurs containing the move offset
  72200. */
  72201. onPointerMovedObservable: Observable<{
  72202. offsetX: number;
  72203. offsetY: number;
  72204. }>;
  72205. /**
  72206. * @hidden
  72207. * If the camera should be rotated automatically based on pointer movement
  72208. */
  72209. _allowCameraRotation: boolean;
  72210. /**
  72211. * Manage the mouse inputs to control the movement of a free camera.
  72212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72213. * @param touchEnabled Defines if touch is enabled or not
  72214. */
  72215. constructor(
  72216. /**
  72217. * Define if touch is enabled in the mouse input
  72218. */
  72219. touchEnabled?: boolean);
  72220. /**
  72221. * Attach the input controls to a specific dom element to get the input from.
  72222. * @param element Defines the element the controls should be listened from
  72223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72224. */
  72225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72226. /**
  72227. * Called on JS contextmenu event.
  72228. * Override this method to provide functionality.
  72229. */
  72230. protected onContextMenu(evt: PointerEvent): void;
  72231. /**
  72232. * Detach the current controls from the specified dom element.
  72233. * @param element Defines the element to stop listening the inputs from
  72234. */
  72235. detachControl(element: Nullable<HTMLElement>): void;
  72236. /**
  72237. * Gets the class name of the current intput.
  72238. * @returns the class name
  72239. */
  72240. getClassName(): string;
  72241. /**
  72242. * Get the friendly name associated with the input class.
  72243. * @returns the input friendly name
  72244. */
  72245. getSimpleName(): string;
  72246. }
  72247. }
  72248. declare module BABYLON {
  72249. /**
  72250. * Manage the touch inputs to control the movement of a free camera.
  72251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72252. */
  72253. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72254. /**
  72255. * Defines the camera the input is attached to.
  72256. */
  72257. camera: FreeCamera;
  72258. /**
  72259. * Defines the touch sensibility for rotation.
  72260. * The higher the faster.
  72261. */
  72262. touchAngularSensibility: number;
  72263. /**
  72264. * Defines the touch sensibility for move.
  72265. * The higher the faster.
  72266. */
  72267. touchMoveSensibility: number;
  72268. private _offsetX;
  72269. private _offsetY;
  72270. private _pointerPressed;
  72271. private _pointerInput;
  72272. private _observer;
  72273. private _onLostFocus;
  72274. /**
  72275. * Attach the input controls to a specific dom element to get the input from.
  72276. * @param element Defines the element the controls should be listened from
  72277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72278. */
  72279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72280. /**
  72281. * Detach the current controls from the specified dom element.
  72282. * @param element Defines the element to stop listening the inputs from
  72283. */
  72284. detachControl(element: Nullable<HTMLElement>): void;
  72285. /**
  72286. * Update the current camera state depending on the inputs that have been used this frame.
  72287. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72288. */
  72289. checkInputs(): void;
  72290. /**
  72291. * Gets the class name of the current intput.
  72292. * @returns the class name
  72293. */
  72294. getClassName(): string;
  72295. /**
  72296. * Get the friendly name associated with the input class.
  72297. * @returns the input friendly name
  72298. */
  72299. getSimpleName(): string;
  72300. }
  72301. }
  72302. declare module BABYLON {
  72303. /**
  72304. * Default Inputs manager for the FreeCamera.
  72305. * It groups all the default supported inputs for ease of use.
  72306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72307. */
  72308. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72309. /**
  72310. * @hidden
  72311. */
  72312. _mouseInput: Nullable<FreeCameraMouseInput>;
  72313. /**
  72314. * Instantiates a new FreeCameraInputsManager.
  72315. * @param camera Defines the camera the inputs belong to
  72316. */
  72317. constructor(camera: FreeCamera);
  72318. /**
  72319. * Add keyboard input support to the input manager.
  72320. * @returns the current input manager
  72321. */
  72322. addKeyboard(): FreeCameraInputsManager;
  72323. /**
  72324. * Add mouse input support to the input manager.
  72325. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72326. * @returns the current input manager
  72327. */
  72328. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72329. /**
  72330. * Removes the mouse input support from the manager
  72331. * @returns the current input manager
  72332. */
  72333. removeMouse(): FreeCameraInputsManager;
  72334. /**
  72335. * Add touch input support to the input manager.
  72336. * @returns the current input manager
  72337. */
  72338. addTouch(): FreeCameraInputsManager;
  72339. /**
  72340. * Remove all attached input methods from a camera
  72341. */
  72342. clear(): void;
  72343. }
  72344. }
  72345. declare module BABYLON {
  72346. /**
  72347. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72348. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72349. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72350. */
  72351. export class FreeCamera extends TargetCamera {
  72352. /**
  72353. * Define the collision ellipsoid of the camera.
  72354. * This is helpful to simulate a camera body like the player body around the camera
  72355. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72356. */
  72357. ellipsoid: Vector3;
  72358. /**
  72359. * Define an offset for the position of the ellipsoid around the camera.
  72360. * This can be helpful to determine the center of the body near the gravity center of the body
  72361. * instead of its head.
  72362. */
  72363. ellipsoidOffset: Vector3;
  72364. /**
  72365. * Enable or disable collisions of the camera with the rest of the scene objects.
  72366. */
  72367. checkCollisions: boolean;
  72368. /**
  72369. * Enable or disable gravity on the camera.
  72370. */
  72371. applyGravity: boolean;
  72372. /**
  72373. * Define the input manager associated to the camera.
  72374. */
  72375. inputs: FreeCameraInputsManager;
  72376. /**
  72377. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72378. * Higher values reduce sensitivity.
  72379. */
  72380. /**
  72381. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72382. * Higher values reduce sensitivity.
  72383. */
  72384. angularSensibility: number;
  72385. /**
  72386. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72387. */
  72388. keysUp: number[];
  72389. /**
  72390. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72391. */
  72392. keysDown: number[];
  72393. /**
  72394. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72395. */
  72396. keysLeft: number[];
  72397. /**
  72398. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72399. */
  72400. keysRight: number[];
  72401. /**
  72402. * Event raised when the camera collide with a mesh in the scene.
  72403. */
  72404. onCollide: (collidedMesh: AbstractMesh) => void;
  72405. private _collider;
  72406. private _needMoveForGravity;
  72407. private _oldPosition;
  72408. private _diffPosition;
  72409. private _newPosition;
  72410. /** @hidden */
  72411. _localDirection: Vector3;
  72412. /** @hidden */
  72413. _transformedDirection: Vector3;
  72414. /**
  72415. * Instantiates a Free Camera.
  72416. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72417. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72418. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72419. * @param name Define the name of the camera in the scene
  72420. * @param position Define the start position of the camera in the scene
  72421. * @param scene Define the scene the camera belongs to
  72422. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72423. */
  72424. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72425. /**
  72426. * Attached controls to the current camera.
  72427. * @param element Defines the element the controls should be listened from
  72428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72429. */
  72430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72431. /**
  72432. * Detach the current controls from the camera.
  72433. * The camera will stop reacting to inputs.
  72434. * @param element Defines the element to stop listening the inputs from
  72435. */
  72436. detachControl(element: HTMLElement): void;
  72437. private _collisionMask;
  72438. /**
  72439. * Define a collision mask to limit the list of object the camera can collide with
  72440. */
  72441. collisionMask: number;
  72442. /** @hidden */
  72443. _collideWithWorld(displacement: Vector3): void;
  72444. private _onCollisionPositionChange;
  72445. /** @hidden */
  72446. _checkInputs(): void;
  72447. /** @hidden */
  72448. _decideIfNeedsToMove(): boolean;
  72449. /** @hidden */
  72450. _updatePosition(): void;
  72451. /**
  72452. * Destroy the camera and release the current resources hold by it.
  72453. */
  72454. dispose(): void;
  72455. /**
  72456. * Gets the current object class name.
  72457. * @return the class name
  72458. */
  72459. getClassName(): string;
  72460. }
  72461. }
  72462. declare module BABYLON {
  72463. /**
  72464. * Represents a gamepad control stick position
  72465. */
  72466. export class StickValues {
  72467. /**
  72468. * The x component of the control stick
  72469. */
  72470. x: number;
  72471. /**
  72472. * The y component of the control stick
  72473. */
  72474. y: number;
  72475. /**
  72476. * Initializes the gamepad x and y control stick values
  72477. * @param x The x component of the gamepad control stick value
  72478. * @param y The y component of the gamepad control stick value
  72479. */
  72480. constructor(
  72481. /**
  72482. * The x component of the control stick
  72483. */
  72484. x: number,
  72485. /**
  72486. * The y component of the control stick
  72487. */
  72488. y: number);
  72489. }
  72490. /**
  72491. * An interface which manages callbacks for gamepad button changes
  72492. */
  72493. export interface GamepadButtonChanges {
  72494. /**
  72495. * Called when a gamepad has been changed
  72496. */
  72497. changed: boolean;
  72498. /**
  72499. * Called when a gamepad press event has been triggered
  72500. */
  72501. pressChanged: boolean;
  72502. /**
  72503. * Called when a touch event has been triggered
  72504. */
  72505. touchChanged: boolean;
  72506. /**
  72507. * Called when a value has changed
  72508. */
  72509. valueChanged: boolean;
  72510. }
  72511. /**
  72512. * Represents a gamepad
  72513. */
  72514. export class Gamepad {
  72515. /**
  72516. * The id of the gamepad
  72517. */
  72518. id: string;
  72519. /**
  72520. * The index of the gamepad
  72521. */
  72522. index: number;
  72523. /**
  72524. * The browser gamepad
  72525. */
  72526. browserGamepad: any;
  72527. /**
  72528. * Specifies what type of gamepad this represents
  72529. */
  72530. type: number;
  72531. private _leftStick;
  72532. private _rightStick;
  72533. /** @hidden */
  72534. _isConnected: boolean;
  72535. private _leftStickAxisX;
  72536. private _leftStickAxisY;
  72537. private _rightStickAxisX;
  72538. private _rightStickAxisY;
  72539. /**
  72540. * Triggered when the left control stick has been changed
  72541. */
  72542. private _onleftstickchanged;
  72543. /**
  72544. * Triggered when the right control stick has been changed
  72545. */
  72546. private _onrightstickchanged;
  72547. /**
  72548. * Represents a gamepad controller
  72549. */
  72550. static GAMEPAD: number;
  72551. /**
  72552. * Represents a generic controller
  72553. */
  72554. static GENERIC: number;
  72555. /**
  72556. * Represents an XBox controller
  72557. */
  72558. static XBOX: number;
  72559. /**
  72560. * Represents a pose-enabled controller
  72561. */
  72562. static POSE_ENABLED: number;
  72563. /**
  72564. * Specifies whether the left control stick should be Y-inverted
  72565. */
  72566. protected _invertLeftStickY: boolean;
  72567. /**
  72568. * Specifies if the gamepad has been connected
  72569. */
  72570. readonly isConnected: boolean;
  72571. /**
  72572. * Initializes the gamepad
  72573. * @param id The id of the gamepad
  72574. * @param index The index of the gamepad
  72575. * @param browserGamepad The browser gamepad
  72576. * @param leftStickX The x component of the left joystick
  72577. * @param leftStickY The y component of the left joystick
  72578. * @param rightStickX The x component of the right joystick
  72579. * @param rightStickY The y component of the right joystick
  72580. */
  72581. constructor(
  72582. /**
  72583. * The id of the gamepad
  72584. */
  72585. id: string,
  72586. /**
  72587. * The index of the gamepad
  72588. */
  72589. index: number,
  72590. /**
  72591. * The browser gamepad
  72592. */
  72593. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72594. /**
  72595. * Callback triggered when the left joystick has changed
  72596. * @param callback
  72597. */
  72598. onleftstickchanged(callback: (values: StickValues) => void): void;
  72599. /**
  72600. * Callback triggered when the right joystick has changed
  72601. * @param callback
  72602. */
  72603. onrightstickchanged(callback: (values: StickValues) => void): void;
  72604. /**
  72605. * Gets the left joystick
  72606. */
  72607. /**
  72608. * Sets the left joystick values
  72609. */
  72610. leftStick: StickValues;
  72611. /**
  72612. * Gets the right joystick
  72613. */
  72614. /**
  72615. * Sets the right joystick value
  72616. */
  72617. rightStick: StickValues;
  72618. /**
  72619. * Updates the gamepad joystick positions
  72620. */
  72621. update(): void;
  72622. /**
  72623. * Disposes the gamepad
  72624. */
  72625. dispose(): void;
  72626. }
  72627. /**
  72628. * Represents a generic gamepad
  72629. */
  72630. export class GenericPad extends Gamepad {
  72631. private _buttons;
  72632. private _onbuttondown;
  72633. private _onbuttonup;
  72634. /**
  72635. * Observable triggered when a button has been pressed
  72636. */
  72637. onButtonDownObservable: Observable<number>;
  72638. /**
  72639. * Observable triggered when a button has been released
  72640. */
  72641. onButtonUpObservable: Observable<number>;
  72642. /**
  72643. * Callback triggered when a button has been pressed
  72644. * @param callback Called when a button has been pressed
  72645. */
  72646. onbuttondown(callback: (buttonPressed: number) => void): void;
  72647. /**
  72648. * Callback triggered when a button has been released
  72649. * @param callback Called when a button has been released
  72650. */
  72651. onbuttonup(callback: (buttonReleased: number) => void): void;
  72652. /**
  72653. * Initializes the generic gamepad
  72654. * @param id The id of the generic gamepad
  72655. * @param index The index of the generic gamepad
  72656. * @param browserGamepad The browser gamepad
  72657. */
  72658. constructor(id: string, index: number, browserGamepad: any);
  72659. private _setButtonValue;
  72660. /**
  72661. * Updates the generic gamepad
  72662. */
  72663. update(): void;
  72664. /**
  72665. * Disposes the generic gamepad
  72666. */
  72667. dispose(): void;
  72668. }
  72669. }
  72670. declare module BABYLON {
  72671. /**
  72672. * Defines the types of pose enabled controllers that are supported
  72673. */
  72674. export enum PoseEnabledControllerType {
  72675. /**
  72676. * HTC Vive
  72677. */
  72678. VIVE = 0,
  72679. /**
  72680. * Oculus Rift
  72681. */
  72682. OCULUS = 1,
  72683. /**
  72684. * Windows mixed reality
  72685. */
  72686. WINDOWS = 2,
  72687. /**
  72688. * Samsung gear VR
  72689. */
  72690. GEAR_VR = 3,
  72691. /**
  72692. * Google Daydream
  72693. */
  72694. DAYDREAM = 4,
  72695. /**
  72696. * Generic
  72697. */
  72698. GENERIC = 5
  72699. }
  72700. /**
  72701. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72702. */
  72703. export interface MutableGamepadButton {
  72704. /**
  72705. * Value of the button/trigger
  72706. */
  72707. value: number;
  72708. /**
  72709. * If the button/trigger is currently touched
  72710. */
  72711. touched: boolean;
  72712. /**
  72713. * If the button/trigger is currently pressed
  72714. */
  72715. pressed: boolean;
  72716. }
  72717. /**
  72718. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72719. * @hidden
  72720. */
  72721. export interface ExtendedGamepadButton extends GamepadButton {
  72722. /**
  72723. * If the button/trigger is currently pressed
  72724. */
  72725. readonly pressed: boolean;
  72726. /**
  72727. * If the button/trigger is currently touched
  72728. */
  72729. readonly touched: boolean;
  72730. /**
  72731. * Value of the button/trigger
  72732. */
  72733. readonly value: number;
  72734. }
  72735. /** @hidden */
  72736. export interface _GamePadFactory {
  72737. /**
  72738. * Returns wether or not the current gamepad can be created for this type of controller.
  72739. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72740. * @returns true if it can be created, otherwise false
  72741. */
  72742. canCreate(gamepadInfo: any): boolean;
  72743. /**
  72744. * Creates a new instance of the Gamepad.
  72745. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72746. * @returns the new gamepad instance
  72747. */
  72748. create(gamepadInfo: any): Gamepad;
  72749. }
  72750. /**
  72751. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72752. */
  72753. export class PoseEnabledControllerHelper {
  72754. /** @hidden */
  72755. static _ControllerFactories: _GamePadFactory[];
  72756. /** @hidden */
  72757. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72758. /**
  72759. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72760. * @param vrGamepad the gamepad to initialized
  72761. * @returns a vr controller of the type the gamepad identified as
  72762. */
  72763. static InitiateController(vrGamepad: any): Gamepad;
  72764. }
  72765. /**
  72766. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72767. */
  72768. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72769. private _deviceRoomPosition;
  72770. private _deviceRoomRotationQuaternion;
  72771. /**
  72772. * The device position in babylon space
  72773. */
  72774. devicePosition: Vector3;
  72775. /**
  72776. * The device rotation in babylon space
  72777. */
  72778. deviceRotationQuaternion: Quaternion;
  72779. /**
  72780. * The scale factor of the device in babylon space
  72781. */
  72782. deviceScaleFactor: number;
  72783. /**
  72784. * (Likely devicePosition should be used instead) The device position in its room space
  72785. */
  72786. position: Vector3;
  72787. /**
  72788. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72789. */
  72790. rotationQuaternion: Quaternion;
  72791. /**
  72792. * The type of controller (Eg. Windows mixed reality)
  72793. */
  72794. controllerType: PoseEnabledControllerType;
  72795. protected _calculatedPosition: Vector3;
  72796. private _calculatedRotation;
  72797. /**
  72798. * The raw pose from the device
  72799. */
  72800. rawPose: DevicePose;
  72801. private _trackPosition;
  72802. private _maxRotationDistFromHeadset;
  72803. private _draggedRoomRotation;
  72804. /**
  72805. * @hidden
  72806. */
  72807. _disableTrackPosition(fixedPosition: Vector3): void;
  72808. /**
  72809. * Internal, the mesh attached to the controller
  72810. * @hidden
  72811. */
  72812. _mesh: Nullable<AbstractMesh>;
  72813. private _poseControlledCamera;
  72814. private _leftHandSystemQuaternion;
  72815. /**
  72816. * Internal, matrix used to convert room space to babylon space
  72817. * @hidden
  72818. */
  72819. _deviceToWorld: Matrix;
  72820. /**
  72821. * Node to be used when casting a ray from the controller
  72822. * @hidden
  72823. */
  72824. _pointingPoseNode: Nullable<TransformNode>;
  72825. /**
  72826. * Name of the child mesh that can be used to cast a ray from the controller
  72827. */
  72828. static readonly POINTING_POSE: string;
  72829. /**
  72830. * Creates a new PoseEnabledController from a gamepad
  72831. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72832. */
  72833. constructor(browserGamepad: any);
  72834. private _workingMatrix;
  72835. /**
  72836. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72837. */
  72838. update(): void;
  72839. /**
  72840. * Updates only the pose device and mesh without doing any button event checking
  72841. */
  72842. protected _updatePoseAndMesh(): void;
  72843. /**
  72844. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72845. * @param poseData raw pose fromthe device
  72846. */
  72847. updateFromDevice(poseData: DevicePose): void;
  72848. /**
  72849. * @hidden
  72850. */
  72851. _meshAttachedObservable: Observable<AbstractMesh>;
  72852. /**
  72853. * Attaches a mesh to the controller
  72854. * @param mesh the mesh to be attached
  72855. */
  72856. attachToMesh(mesh: AbstractMesh): void;
  72857. /**
  72858. * Attaches the controllers mesh to a camera
  72859. * @param camera the camera the mesh should be attached to
  72860. */
  72861. attachToPoseControlledCamera(camera: TargetCamera): void;
  72862. /**
  72863. * Disposes of the controller
  72864. */
  72865. dispose(): void;
  72866. /**
  72867. * The mesh that is attached to the controller
  72868. */
  72869. readonly mesh: Nullable<AbstractMesh>;
  72870. /**
  72871. * Gets the ray of the controller in the direction the controller is pointing
  72872. * @param length the length the resulting ray should be
  72873. * @returns a ray in the direction the controller is pointing
  72874. */
  72875. getForwardRay(length?: number): Ray;
  72876. }
  72877. }
  72878. declare module BABYLON {
  72879. /**
  72880. * Defines the WebVRController object that represents controllers tracked in 3D space
  72881. */
  72882. export abstract class WebVRController extends PoseEnabledController {
  72883. /**
  72884. * Internal, the default controller model for the controller
  72885. */
  72886. protected _defaultModel: AbstractMesh;
  72887. /**
  72888. * Fired when the trigger state has changed
  72889. */
  72890. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72891. /**
  72892. * Fired when the main button state has changed
  72893. */
  72894. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72895. /**
  72896. * Fired when the secondary button state has changed
  72897. */
  72898. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72899. /**
  72900. * Fired when the pad state has changed
  72901. */
  72902. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72903. /**
  72904. * Fired when controllers stick values have changed
  72905. */
  72906. onPadValuesChangedObservable: Observable<StickValues>;
  72907. /**
  72908. * Array of button availible on the controller
  72909. */
  72910. protected _buttons: Array<MutableGamepadButton>;
  72911. private _onButtonStateChange;
  72912. /**
  72913. * Fired when a controller button's state has changed
  72914. * @param callback the callback containing the button that was modified
  72915. */
  72916. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72917. /**
  72918. * X and Y axis corrisponding to the controllers joystick
  72919. */
  72920. pad: StickValues;
  72921. /**
  72922. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72923. */
  72924. hand: string;
  72925. /**
  72926. * The default controller model for the controller
  72927. */
  72928. readonly defaultModel: AbstractMesh;
  72929. /**
  72930. * Creates a new WebVRController from a gamepad
  72931. * @param vrGamepad the gamepad that the WebVRController should be created from
  72932. */
  72933. constructor(vrGamepad: any);
  72934. /**
  72935. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72936. */
  72937. update(): void;
  72938. /**
  72939. * Function to be called when a button is modified
  72940. */
  72941. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72942. /**
  72943. * Loads a mesh and attaches it to the controller
  72944. * @param scene the scene the mesh should be added to
  72945. * @param meshLoaded callback for when the mesh has been loaded
  72946. */
  72947. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72948. private _setButtonValue;
  72949. private _changes;
  72950. private _checkChanges;
  72951. /**
  72952. * Disposes of th webVRCOntroller
  72953. */
  72954. dispose(): void;
  72955. }
  72956. }
  72957. declare module BABYLON {
  72958. /**
  72959. * The HemisphericLight simulates the ambient environment light,
  72960. * so the passed direction is the light reflection direction, not the incoming direction.
  72961. */
  72962. export class HemisphericLight extends Light {
  72963. /**
  72964. * The groundColor is the light in the opposite direction to the one specified during creation.
  72965. * 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.
  72966. */
  72967. groundColor: Color3;
  72968. /**
  72969. * The light reflection direction, not the incoming direction.
  72970. */
  72971. direction: Vector3;
  72972. /**
  72973. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72974. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72975. * The HemisphericLight can't cast shadows.
  72976. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72977. * @param name The friendly name of the light
  72978. * @param direction The direction of the light reflection
  72979. * @param scene The scene the light belongs to
  72980. */
  72981. constructor(name: string, direction: Vector3, scene: Scene);
  72982. protected _buildUniformLayout(): void;
  72983. /**
  72984. * Returns the string "HemisphericLight".
  72985. * @return The class name
  72986. */
  72987. getClassName(): string;
  72988. /**
  72989. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72990. * Returns the updated direction.
  72991. * @param target The target the direction should point to
  72992. * @return The computed direction
  72993. */
  72994. setDirectionToTarget(target: Vector3): Vector3;
  72995. /**
  72996. * Returns the shadow generator associated to the light.
  72997. * @returns Always null for hemispheric lights because it does not support shadows.
  72998. */
  72999. getShadowGenerator(): Nullable<IShadowGenerator>;
  73000. /**
  73001. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  73002. * @param effect The effect to update
  73003. * @param lightIndex The index of the light in the effect to update
  73004. * @returns The hemispheric light
  73005. */
  73006. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  73007. /**
  73008. * Computes the world matrix of the node
  73009. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73010. * @param useWasUpdatedFlag defines a reserved property
  73011. * @returns the world matrix
  73012. */
  73013. computeWorldMatrix(): Matrix;
  73014. /**
  73015. * Returns the integer 3.
  73016. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73017. */
  73018. getTypeID(): number;
  73019. /**
  73020. * Prepares the list of defines specific to the light type.
  73021. * @param defines the list of defines
  73022. * @param lightIndex defines the index of the light for the effect
  73023. */
  73024. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73025. }
  73026. }
  73027. declare module BABYLON {
  73028. /** @hidden */
  73029. export var vrMultiviewToSingleviewPixelShader: {
  73030. name: string;
  73031. shader: string;
  73032. };
  73033. }
  73034. declare module BABYLON {
  73035. /**
  73036. * Renders to multiple views with a single draw call
  73037. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73038. */
  73039. export class MultiviewRenderTarget extends RenderTargetTexture {
  73040. /**
  73041. * Creates a multiview render target
  73042. * @param scene scene used with the render target
  73043. * @param size the size of the render target (used for each view)
  73044. */
  73045. constructor(scene: Scene, size?: number | {
  73046. width: number;
  73047. height: number;
  73048. } | {
  73049. ratio: number;
  73050. });
  73051. /**
  73052. * @hidden
  73053. * @param faceIndex the face index, if its a cube texture
  73054. */
  73055. _bindFrameBuffer(faceIndex?: number): void;
  73056. /**
  73057. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73058. * @returns the view count
  73059. */
  73060. getViewCount(): number;
  73061. }
  73062. }
  73063. declare module BABYLON {
  73064. interface Engine {
  73065. /**
  73066. * Creates a new multiview render target
  73067. * @param width defines the width of the texture
  73068. * @param height defines the height of the texture
  73069. * @returns the created multiview texture
  73070. */
  73071. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73072. /**
  73073. * Binds a multiview framebuffer to be drawn to
  73074. * @param multiviewTexture texture to bind
  73075. */
  73076. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73077. }
  73078. interface Camera {
  73079. /**
  73080. * @hidden
  73081. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  73082. */
  73083. _useMultiviewToSingleView: boolean;
  73084. /**
  73085. * @hidden
  73086. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  73087. */
  73088. _multiviewTexture: Nullable<RenderTargetTexture>;
  73089. /**
  73090. * @hidden
  73091. * ensures the multiview texture of the camera exists and has the specified width/height
  73092. * @param width height to set on the multiview texture
  73093. * @param height width to set on the multiview texture
  73094. */
  73095. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73096. }
  73097. interface Scene {
  73098. /** @hidden */
  73099. _transformMatrixR: Matrix;
  73100. /** @hidden */
  73101. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73102. /** @hidden */
  73103. _createMultiviewUbo(): void;
  73104. /** @hidden */
  73105. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73106. /** @hidden */
  73107. _renderMultiviewToSingleView(camera: Camera): void;
  73108. }
  73109. }
  73110. declare module BABYLON {
  73111. /**
  73112. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73113. * This will not be used for webXR as it supports displaying texture arrays directly
  73114. */
  73115. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73116. /**
  73117. * Initializes a VRMultiviewToSingleview
  73118. * @param name name of the post process
  73119. * @param camera camera to be applied to
  73120. * @param scaleFactor scaling factor to the size of the output texture
  73121. */
  73122. constructor(name: string, camera: Camera, scaleFactor: number);
  73123. }
  73124. }
  73125. declare module BABYLON {
  73126. /**
  73127. * Defines the interface used by display changed events
  73128. */
  73129. interface IDisplayChangedEventArgs {
  73130. /** Gets the vrDisplay object (if any) */
  73131. vrDisplay: Nullable<any>;
  73132. /** Gets a boolean indicating if webVR is supported */
  73133. vrSupported: boolean;
  73134. }
  73135. interface Engine {
  73136. /** @hidden */
  73137. _vrDisplay: any;
  73138. /** @hidden */
  73139. _vrSupported: boolean;
  73140. /** @hidden */
  73141. _oldSize: Size;
  73142. /** @hidden */
  73143. _oldHardwareScaleFactor: number;
  73144. /** @hidden */
  73145. _vrExclusivePointerMode: boolean;
  73146. /** @hidden */
  73147. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73148. /** @hidden */
  73149. _onVRDisplayPointerRestricted: () => void;
  73150. /** @hidden */
  73151. _onVRDisplayPointerUnrestricted: () => void;
  73152. /** @hidden */
  73153. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73154. /** @hidden */
  73155. _onVrDisplayDisconnect: Nullable<() => void>;
  73156. /** @hidden */
  73157. _onVrDisplayPresentChange: Nullable<() => void>;
  73158. /**
  73159. * Observable signaled when VR display mode changes
  73160. */
  73161. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73162. /**
  73163. * Observable signaled when VR request present is complete
  73164. */
  73165. onVRRequestPresentComplete: Observable<boolean>;
  73166. /**
  73167. * Observable signaled when VR request present starts
  73168. */
  73169. onVRRequestPresentStart: Observable<Engine>;
  73170. /**
  73171. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73172. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73173. */
  73174. isInVRExclusivePointerMode: boolean;
  73175. /**
  73176. * Gets a boolean indicating if a webVR device was detected
  73177. * @returns true if a webVR device was detected
  73178. */
  73179. isVRDevicePresent(): boolean;
  73180. /**
  73181. * Gets the current webVR device
  73182. * @returns the current webVR device (or null)
  73183. */
  73184. getVRDevice(): any;
  73185. /**
  73186. * Initializes a webVR display and starts listening to display change events
  73187. * The onVRDisplayChangedObservable will be notified upon these changes
  73188. * @returns A promise containing a VRDisplay and if vr is supported
  73189. */
  73190. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73191. /** @hidden */
  73192. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73193. /**
  73194. * Call this function to switch to webVR mode
  73195. * Will do nothing if webVR is not supported or if there is no webVR device
  73196. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73197. */
  73198. enableVR(): void;
  73199. /** @hidden */
  73200. _onVRFullScreenTriggered(): void;
  73201. }
  73202. }
  73203. declare module BABYLON {
  73204. /**
  73205. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73206. * IMPORTANT!! The data is right-hand data.
  73207. * @export
  73208. * @interface DevicePose
  73209. */
  73210. export interface DevicePose {
  73211. /**
  73212. * The position of the device, values in array are [x,y,z].
  73213. */
  73214. readonly position: Nullable<Float32Array>;
  73215. /**
  73216. * The linearVelocity of the device, values in array are [x,y,z].
  73217. */
  73218. readonly linearVelocity: Nullable<Float32Array>;
  73219. /**
  73220. * The linearAcceleration of the device, values in array are [x,y,z].
  73221. */
  73222. readonly linearAcceleration: Nullable<Float32Array>;
  73223. /**
  73224. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73225. */
  73226. readonly orientation: Nullable<Float32Array>;
  73227. /**
  73228. * The angularVelocity of the device, values in array are [x,y,z].
  73229. */
  73230. readonly angularVelocity: Nullable<Float32Array>;
  73231. /**
  73232. * The angularAcceleration of the device, values in array are [x,y,z].
  73233. */
  73234. readonly angularAcceleration: Nullable<Float32Array>;
  73235. }
  73236. /**
  73237. * Interface representing a pose controlled object in Babylon.
  73238. * A pose controlled object has both regular pose values as well as pose values
  73239. * from an external device such as a VR head mounted display
  73240. */
  73241. export interface PoseControlled {
  73242. /**
  73243. * The position of the object in babylon space.
  73244. */
  73245. position: Vector3;
  73246. /**
  73247. * The rotation quaternion of the object in babylon space.
  73248. */
  73249. rotationQuaternion: Quaternion;
  73250. /**
  73251. * The position of the device in babylon space.
  73252. */
  73253. devicePosition?: Vector3;
  73254. /**
  73255. * The rotation quaternion of the device in babylon space.
  73256. */
  73257. deviceRotationQuaternion: Quaternion;
  73258. /**
  73259. * The raw pose coming from the device.
  73260. */
  73261. rawPose: Nullable<DevicePose>;
  73262. /**
  73263. * The scale of the device to be used when translating from device space to babylon space.
  73264. */
  73265. deviceScaleFactor: number;
  73266. /**
  73267. * Updates the poseControlled values based on the input device pose.
  73268. * @param poseData the pose data to update the object with
  73269. */
  73270. updateFromDevice(poseData: DevicePose): void;
  73271. }
  73272. /**
  73273. * Set of options to customize the webVRCamera
  73274. */
  73275. export interface WebVROptions {
  73276. /**
  73277. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73278. */
  73279. trackPosition?: boolean;
  73280. /**
  73281. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73282. */
  73283. positionScale?: number;
  73284. /**
  73285. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73286. */
  73287. displayName?: string;
  73288. /**
  73289. * Should the native controller meshes be initialized. (default: true)
  73290. */
  73291. controllerMeshes?: boolean;
  73292. /**
  73293. * Creating a default HemiLight only on controllers. (default: true)
  73294. */
  73295. defaultLightingOnControllers?: boolean;
  73296. /**
  73297. * If you don't want to use the default VR button of the helper. (default: false)
  73298. */
  73299. useCustomVRButton?: boolean;
  73300. /**
  73301. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73302. */
  73303. customVRButton?: HTMLButtonElement;
  73304. /**
  73305. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73306. */
  73307. rayLength?: number;
  73308. /**
  73309. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73310. */
  73311. defaultHeight?: number;
  73312. /**
  73313. * If multiview should be used if availible (default: false)
  73314. */
  73315. useMultiview?: boolean;
  73316. }
  73317. /**
  73318. * This represents a WebVR camera.
  73319. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73320. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73321. */
  73322. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73323. private webVROptions;
  73324. /**
  73325. * @hidden
  73326. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73327. */
  73328. _vrDevice: any;
  73329. /**
  73330. * The rawPose of the vrDevice.
  73331. */
  73332. rawPose: Nullable<DevicePose>;
  73333. private _onVREnabled;
  73334. private _specsVersion;
  73335. private _attached;
  73336. private _frameData;
  73337. protected _descendants: Array<Node>;
  73338. private _deviceRoomPosition;
  73339. /** @hidden */
  73340. _deviceRoomRotationQuaternion: Quaternion;
  73341. private _standingMatrix;
  73342. /**
  73343. * Represents device position in babylon space.
  73344. */
  73345. devicePosition: Vector3;
  73346. /**
  73347. * Represents device rotation in babylon space.
  73348. */
  73349. deviceRotationQuaternion: Quaternion;
  73350. /**
  73351. * The scale of the device to be used when translating from device space to babylon space.
  73352. */
  73353. deviceScaleFactor: number;
  73354. private _deviceToWorld;
  73355. private _worldToDevice;
  73356. /**
  73357. * References to the webVR controllers for the vrDevice.
  73358. */
  73359. controllers: Array<WebVRController>;
  73360. /**
  73361. * Emits an event when a controller is attached.
  73362. */
  73363. onControllersAttachedObservable: Observable<WebVRController[]>;
  73364. /**
  73365. * Emits an event when a controller's mesh has been loaded;
  73366. */
  73367. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73368. /**
  73369. * Emits an event when the HMD's pose has been updated.
  73370. */
  73371. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73372. private _poseSet;
  73373. /**
  73374. * If the rig cameras be used as parent instead of this camera.
  73375. */
  73376. rigParenting: boolean;
  73377. private _lightOnControllers;
  73378. private _defaultHeight?;
  73379. /**
  73380. * Instantiates a WebVRFreeCamera.
  73381. * @param name The name of the WebVRFreeCamera
  73382. * @param position The starting anchor position for the camera
  73383. * @param scene The scene the camera belongs to
  73384. * @param webVROptions a set of customizable options for the webVRCamera
  73385. */
  73386. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73387. /**
  73388. * Gets the device distance from the ground in meters.
  73389. * @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.
  73390. */
  73391. deviceDistanceToRoomGround(): number;
  73392. /**
  73393. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73394. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73395. */
  73396. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73397. /**
  73398. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73399. * @returns A promise with a boolean set to if the standing matrix is supported.
  73400. */
  73401. useStandingMatrixAsync(): Promise<boolean>;
  73402. /**
  73403. * Disposes the camera
  73404. */
  73405. dispose(): void;
  73406. /**
  73407. * Gets a vrController by name.
  73408. * @param name The name of the controller to retreive
  73409. * @returns the controller matching the name specified or null if not found
  73410. */
  73411. getControllerByName(name: string): Nullable<WebVRController>;
  73412. private _leftController;
  73413. /**
  73414. * The controller corrisponding to the users left hand.
  73415. */
  73416. readonly leftController: Nullable<WebVRController>;
  73417. private _rightController;
  73418. /**
  73419. * The controller corrisponding to the users right hand.
  73420. */
  73421. readonly rightController: Nullable<WebVRController>;
  73422. /**
  73423. * Casts a ray forward from the vrCamera's gaze.
  73424. * @param length Length of the ray (default: 100)
  73425. * @returns the ray corrisponding to the gaze
  73426. */
  73427. getForwardRay(length?: number): Ray;
  73428. /**
  73429. * @hidden
  73430. * Updates the camera based on device's frame data
  73431. */
  73432. _checkInputs(): void;
  73433. /**
  73434. * Updates the poseControlled values based on the input device pose.
  73435. * @param poseData Pose coming from the device
  73436. */
  73437. updateFromDevice(poseData: DevicePose): void;
  73438. private _htmlElementAttached;
  73439. private _detachIfAttached;
  73440. /**
  73441. * WebVR's attach control will start broadcasting frames to the device.
  73442. * Note that in certain browsers (chrome for example) this function must be called
  73443. * within a user-interaction callback. Example:
  73444. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73445. *
  73446. * @param element html element to attach the vrDevice to
  73447. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73448. */
  73449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73450. /**
  73451. * Detaches the camera from the html element and disables VR
  73452. *
  73453. * @param element html element to detach from
  73454. */
  73455. detachControl(element: HTMLElement): void;
  73456. /**
  73457. * @returns the name of this class
  73458. */
  73459. getClassName(): string;
  73460. /**
  73461. * Calls resetPose on the vrDisplay
  73462. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73463. */
  73464. resetToCurrentRotation(): void;
  73465. /**
  73466. * @hidden
  73467. * Updates the rig cameras (left and right eye)
  73468. */
  73469. _updateRigCameras(): void;
  73470. private _workingVector;
  73471. private _oneVector;
  73472. private _workingMatrix;
  73473. private updateCacheCalled;
  73474. private _correctPositionIfNotTrackPosition;
  73475. /**
  73476. * @hidden
  73477. * Updates the cached values of the camera
  73478. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73479. */
  73480. _updateCache(ignoreParentClass?: boolean): void;
  73481. /**
  73482. * @hidden
  73483. * Get current device position in babylon world
  73484. */
  73485. _computeDevicePosition(): void;
  73486. /**
  73487. * Updates the current device position and rotation in the babylon world
  73488. */
  73489. update(): void;
  73490. /**
  73491. * @hidden
  73492. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73493. * @returns an identity matrix
  73494. */
  73495. _getViewMatrix(): Matrix;
  73496. private _tmpMatrix;
  73497. /**
  73498. * This function is called by the two RIG cameras.
  73499. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73500. * @hidden
  73501. */
  73502. _getWebVRViewMatrix(): Matrix;
  73503. /** @hidden */
  73504. _getWebVRProjectionMatrix(): Matrix;
  73505. private _onGamepadConnectedObserver;
  73506. private _onGamepadDisconnectedObserver;
  73507. private _updateCacheWhenTrackingDisabledObserver;
  73508. /**
  73509. * Initializes the controllers and their meshes
  73510. */
  73511. initControllers(): void;
  73512. }
  73513. }
  73514. declare module BABYLON {
  73515. /**
  73516. * Size options for a post process
  73517. */
  73518. export type PostProcessOptions = {
  73519. width: number;
  73520. height: number;
  73521. };
  73522. /**
  73523. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73524. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73525. */
  73526. export class PostProcess {
  73527. /** Name of the PostProcess. */
  73528. name: string;
  73529. /**
  73530. * Gets or sets the unique id of the post process
  73531. */
  73532. uniqueId: number;
  73533. /**
  73534. * Width of the texture to apply the post process on
  73535. */
  73536. width: number;
  73537. /**
  73538. * Height of the texture to apply the post process on
  73539. */
  73540. height: number;
  73541. /**
  73542. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73543. * @hidden
  73544. */
  73545. _outputTexture: Nullable<InternalTexture>;
  73546. /**
  73547. * Sampling mode used by the shader
  73548. * See https://doc.babylonjs.com/classes/3.1/texture
  73549. */
  73550. renderTargetSamplingMode: number;
  73551. /**
  73552. * Clear color to use when screen clearing
  73553. */
  73554. clearColor: Color4;
  73555. /**
  73556. * If the buffer needs to be cleared before applying the post process. (default: true)
  73557. * Should be set to false if shader will overwrite all previous pixels.
  73558. */
  73559. autoClear: boolean;
  73560. /**
  73561. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73562. */
  73563. alphaMode: number;
  73564. /**
  73565. * Sets the setAlphaBlendConstants of the babylon engine
  73566. */
  73567. alphaConstants: Color4;
  73568. /**
  73569. * Animations to be used for the post processing
  73570. */
  73571. animations: Animation[];
  73572. /**
  73573. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73574. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73575. */
  73576. enablePixelPerfectMode: boolean;
  73577. /**
  73578. * Force the postprocess to be applied without taking in account viewport
  73579. */
  73580. forceFullscreenViewport: boolean;
  73581. /**
  73582. * List of inspectable custom properties (used by the Inspector)
  73583. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73584. */
  73585. inspectableCustomProperties: IInspectable[];
  73586. /**
  73587. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73588. *
  73589. * | Value | Type | Description |
  73590. * | ----- | ----------------------------------- | ----------- |
  73591. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73592. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73593. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73594. *
  73595. */
  73596. scaleMode: number;
  73597. /**
  73598. * Force textures to be a power of two (default: false)
  73599. */
  73600. alwaysForcePOT: boolean;
  73601. private _samples;
  73602. /**
  73603. * Number of sample textures (default: 1)
  73604. */
  73605. samples: number;
  73606. /**
  73607. * Modify the scale of the post process to be the same as the viewport (default: false)
  73608. */
  73609. adaptScaleToCurrentViewport: boolean;
  73610. private _camera;
  73611. private _scene;
  73612. private _engine;
  73613. private _options;
  73614. private _reusable;
  73615. private _textureType;
  73616. /**
  73617. * Smart array of input and output textures for the post process.
  73618. * @hidden
  73619. */
  73620. _textures: SmartArray<InternalTexture>;
  73621. /**
  73622. * The index in _textures that corresponds to the output texture.
  73623. * @hidden
  73624. */
  73625. _currentRenderTextureInd: number;
  73626. private _effect;
  73627. private _samplers;
  73628. private _fragmentUrl;
  73629. private _vertexUrl;
  73630. private _parameters;
  73631. private _scaleRatio;
  73632. protected _indexParameters: any;
  73633. private _shareOutputWithPostProcess;
  73634. private _texelSize;
  73635. private _forcedOutputTexture;
  73636. /**
  73637. * Returns the fragment url or shader name used in the post process.
  73638. * @returns the fragment url or name in the shader store.
  73639. */
  73640. getEffectName(): string;
  73641. /**
  73642. * An event triggered when the postprocess is activated.
  73643. */
  73644. onActivateObservable: Observable<Camera>;
  73645. private _onActivateObserver;
  73646. /**
  73647. * A function that is added to the onActivateObservable
  73648. */
  73649. onActivate: Nullable<(camera: Camera) => void>;
  73650. /**
  73651. * An event triggered when the postprocess changes its size.
  73652. */
  73653. onSizeChangedObservable: Observable<PostProcess>;
  73654. private _onSizeChangedObserver;
  73655. /**
  73656. * A function that is added to the onSizeChangedObservable
  73657. */
  73658. onSizeChanged: (postProcess: PostProcess) => void;
  73659. /**
  73660. * An event triggered when the postprocess applies its effect.
  73661. */
  73662. onApplyObservable: Observable<Effect>;
  73663. private _onApplyObserver;
  73664. /**
  73665. * A function that is added to the onApplyObservable
  73666. */
  73667. onApply: (effect: Effect) => void;
  73668. /**
  73669. * An event triggered before rendering the postprocess
  73670. */
  73671. onBeforeRenderObservable: Observable<Effect>;
  73672. private _onBeforeRenderObserver;
  73673. /**
  73674. * A function that is added to the onBeforeRenderObservable
  73675. */
  73676. onBeforeRender: (effect: Effect) => void;
  73677. /**
  73678. * An event triggered after rendering the postprocess
  73679. */
  73680. onAfterRenderObservable: Observable<Effect>;
  73681. private _onAfterRenderObserver;
  73682. /**
  73683. * A function that is added to the onAfterRenderObservable
  73684. */
  73685. onAfterRender: (efect: Effect) => void;
  73686. /**
  73687. * 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
  73688. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73689. */
  73690. inputTexture: InternalTexture;
  73691. /**
  73692. * Gets the camera which post process is applied to.
  73693. * @returns The camera the post process is applied to.
  73694. */
  73695. getCamera(): Camera;
  73696. /**
  73697. * Gets the texel size of the postprocess.
  73698. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73699. */
  73700. readonly texelSize: Vector2;
  73701. /**
  73702. * Creates a new instance PostProcess
  73703. * @param name The name of the PostProcess.
  73704. * @param fragmentUrl The url of the fragment shader to be used.
  73705. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73706. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73707. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73708. * @param camera The camera to apply the render pass to.
  73709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73710. * @param engine The engine which the post process will be applied. (default: current engine)
  73711. * @param reusable If the post process can be reused on the same frame. (default: false)
  73712. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73713. * @param textureType Type of textures used when performing the post process. (default: 0)
  73714. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73715. * @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
  73716. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73717. */
  73718. constructor(
  73719. /** Name of the PostProcess. */
  73720. 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);
  73721. /**
  73722. * Gets a string idenfifying the name of the class
  73723. * @returns "PostProcess" string
  73724. */
  73725. getClassName(): string;
  73726. /**
  73727. * Gets the engine which this post process belongs to.
  73728. * @returns The engine the post process was enabled with.
  73729. */
  73730. getEngine(): Engine;
  73731. /**
  73732. * The effect that is created when initializing the post process.
  73733. * @returns The created effect corrisponding the the postprocess.
  73734. */
  73735. getEffect(): Effect;
  73736. /**
  73737. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73738. * @param postProcess The post process to share the output with.
  73739. * @returns This post process.
  73740. */
  73741. shareOutputWith(postProcess: PostProcess): PostProcess;
  73742. /**
  73743. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73744. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73745. */
  73746. useOwnOutput(): void;
  73747. /**
  73748. * Updates the effect with the current post process compile time values and recompiles the shader.
  73749. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73750. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73751. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73752. * @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
  73753. * @param onCompiled Called when the shader has been compiled.
  73754. * @param onError Called if there is an error when compiling a shader.
  73755. */
  73756. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73757. /**
  73758. * The post process is reusable if it can be used multiple times within one frame.
  73759. * @returns If the post process is reusable
  73760. */
  73761. isReusable(): boolean;
  73762. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73763. markTextureDirty(): void;
  73764. /**
  73765. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73766. * 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.
  73767. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73768. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73769. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73770. * @returns The target texture that was bound to be written to.
  73771. */
  73772. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73773. /**
  73774. * If the post process is supported.
  73775. */
  73776. readonly isSupported: boolean;
  73777. /**
  73778. * The aspect ratio of the output texture.
  73779. */
  73780. readonly aspectRatio: number;
  73781. /**
  73782. * Get a value indicating if the post-process is ready to be used
  73783. * @returns true if the post-process is ready (shader is compiled)
  73784. */
  73785. isReady(): boolean;
  73786. /**
  73787. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73788. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73789. */
  73790. apply(): Nullable<Effect>;
  73791. private _disposeTextures;
  73792. /**
  73793. * Disposes the post process.
  73794. * @param camera The camera to dispose the post process on.
  73795. */
  73796. dispose(camera?: Camera): void;
  73797. }
  73798. }
  73799. declare module BABYLON {
  73800. /**
  73801. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73802. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73803. */
  73804. export class PostProcessManager {
  73805. private _scene;
  73806. private _indexBuffer;
  73807. private _vertexBuffers;
  73808. /**
  73809. * Creates a new instance PostProcess
  73810. * @param scene The scene that the post process is associated with.
  73811. */
  73812. constructor(scene: Scene);
  73813. private _prepareBuffers;
  73814. private _buildIndexBuffer;
  73815. /**
  73816. * Rebuilds the vertex buffers of the manager.
  73817. * @hidden
  73818. */
  73819. _rebuild(): void;
  73820. /**
  73821. * Prepares a frame to be run through a post process.
  73822. * @param sourceTexture The input texture to the post procesess. (default: null)
  73823. * @param postProcesses An array of post processes to be run. (default: null)
  73824. * @returns True if the post processes were able to be run.
  73825. * @hidden
  73826. */
  73827. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73828. /**
  73829. * Manually render a set of post processes to a texture.
  73830. * @param postProcesses An array of post processes to be run.
  73831. * @param targetTexture The target texture to render to.
  73832. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73833. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73834. * @param lodLevel defines which lod of the texture to render to
  73835. */
  73836. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73837. /**
  73838. * Finalize the result of the output of the postprocesses.
  73839. * @param doNotPresent If true the result will not be displayed to the screen.
  73840. * @param targetTexture The target texture to render to.
  73841. * @param faceIndex The index of the face to bind the target texture to.
  73842. * @param postProcesses The array of post processes to render.
  73843. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73844. * @hidden
  73845. */
  73846. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73847. /**
  73848. * Disposes of the post process manager.
  73849. */
  73850. dispose(): void;
  73851. }
  73852. }
  73853. declare module BABYLON {
  73854. interface AbstractScene {
  73855. /**
  73856. * The list of layers (background and foreground) of the scene
  73857. */
  73858. layers: Array<Layer>;
  73859. }
  73860. /**
  73861. * Defines the layer scene component responsible to manage any layers
  73862. * in a given scene.
  73863. */
  73864. export class LayerSceneComponent implements ISceneComponent {
  73865. /**
  73866. * The component name helpfull to identify the component in the list of scene components.
  73867. */
  73868. readonly name: string;
  73869. /**
  73870. * The scene the component belongs to.
  73871. */
  73872. scene: Scene;
  73873. private _engine;
  73874. /**
  73875. * Creates a new instance of the component for the given scene
  73876. * @param scene Defines the scene to register the component in
  73877. */
  73878. constructor(scene: Scene);
  73879. /**
  73880. * Registers the component in a given scene
  73881. */
  73882. register(): void;
  73883. /**
  73884. * Rebuilds the elements related to this component in case of
  73885. * context lost for instance.
  73886. */
  73887. rebuild(): void;
  73888. /**
  73889. * Disposes the component and the associated ressources.
  73890. */
  73891. dispose(): void;
  73892. private _draw;
  73893. private _drawCameraPredicate;
  73894. private _drawCameraBackground;
  73895. private _drawCameraForeground;
  73896. private _drawRenderTargetPredicate;
  73897. private _drawRenderTargetBackground;
  73898. private _drawRenderTargetForeground;
  73899. }
  73900. }
  73901. declare module BABYLON {
  73902. /** @hidden */
  73903. export var layerPixelShader: {
  73904. name: string;
  73905. shader: string;
  73906. };
  73907. }
  73908. declare module BABYLON {
  73909. /** @hidden */
  73910. export var layerVertexShader: {
  73911. name: string;
  73912. shader: string;
  73913. };
  73914. }
  73915. declare module BABYLON {
  73916. /**
  73917. * This represents a full screen 2d layer.
  73918. * This can be useful to display a picture in the background of your scene for instance.
  73919. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73920. */
  73921. export class Layer {
  73922. /**
  73923. * Define the name of the layer.
  73924. */
  73925. name: string;
  73926. /**
  73927. * Define the texture the layer should display.
  73928. */
  73929. texture: Nullable<Texture>;
  73930. /**
  73931. * Is the layer in background or foreground.
  73932. */
  73933. isBackground: boolean;
  73934. /**
  73935. * Define the color of the layer (instead of texture).
  73936. */
  73937. color: Color4;
  73938. /**
  73939. * Define the scale of the layer in order to zoom in out of the texture.
  73940. */
  73941. scale: Vector2;
  73942. /**
  73943. * Define an offset for the layer in order to shift the texture.
  73944. */
  73945. offset: Vector2;
  73946. /**
  73947. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73948. */
  73949. alphaBlendingMode: number;
  73950. /**
  73951. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73952. * Alpha test will not mix with the background color in case of transparency.
  73953. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73954. */
  73955. alphaTest: boolean;
  73956. /**
  73957. * Define a mask to restrict the layer to only some of the scene cameras.
  73958. */
  73959. layerMask: number;
  73960. /**
  73961. * Define the list of render target the layer is visible into.
  73962. */
  73963. renderTargetTextures: RenderTargetTexture[];
  73964. /**
  73965. * Define if the layer is only used in renderTarget or if it also
  73966. * renders in the main frame buffer of the canvas.
  73967. */
  73968. renderOnlyInRenderTargetTextures: boolean;
  73969. private _scene;
  73970. private _vertexBuffers;
  73971. private _indexBuffer;
  73972. private _effect;
  73973. private _alphaTestEffect;
  73974. /**
  73975. * An event triggered when the layer is disposed.
  73976. */
  73977. onDisposeObservable: Observable<Layer>;
  73978. private _onDisposeObserver;
  73979. /**
  73980. * Back compatibility with callback before the onDisposeObservable existed.
  73981. * The set callback will be triggered when the layer has been disposed.
  73982. */
  73983. onDispose: () => void;
  73984. /**
  73985. * An event triggered before rendering the scene
  73986. */
  73987. onBeforeRenderObservable: Observable<Layer>;
  73988. private _onBeforeRenderObserver;
  73989. /**
  73990. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73991. * The set callback will be triggered just before rendering the layer.
  73992. */
  73993. onBeforeRender: () => void;
  73994. /**
  73995. * An event triggered after rendering the scene
  73996. */
  73997. onAfterRenderObservable: Observable<Layer>;
  73998. private _onAfterRenderObserver;
  73999. /**
  74000. * Back compatibility with callback before the onAfterRenderObservable existed.
  74001. * The set callback will be triggered just after rendering the layer.
  74002. */
  74003. onAfterRender: () => void;
  74004. /**
  74005. * Instantiates a new layer.
  74006. * This represents a full screen 2d layer.
  74007. * This can be useful to display a picture in the background of your scene for instance.
  74008. * @see https://www.babylonjs-playground.com/#08A2BS#1
  74009. * @param name Define the name of the layer in the scene
  74010. * @param imgUrl Define the url of the texture to display in the layer
  74011. * @param scene Define the scene the layer belongs to
  74012. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  74013. * @param color Defines a color for the layer
  74014. */
  74015. constructor(
  74016. /**
  74017. * Define the name of the layer.
  74018. */
  74019. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  74020. private _createIndexBuffer;
  74021. /** @hidden */
  74022. _rebuild(): void;
  74023. /**
  74024. * Renders the layer in the scene.
  74025. */
  74026. render(): void;
  74027. /**
  74028. * Disposes and releases the associated ressources.
  74029. */
  74030. dispose(): void;
  74031. }
  74032. }
  74033. declare module BABYLON {
  74034. interface AbstractScene {
  74035. /**
  74036. * The list of procedural textures added to the scene
  74037. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74038. */
  74039. proceduralTextures: Array<ProceduralTexture>;
  74040. }
  74041. /**
  74042. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74043. * in a given scene.
  74044. */
  74045. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74046. /**
  74047. * The component name helpfull to identify the component in the list of scene components.
  74048. */
  74049. readonly name: string;
  74050. /**
  74051. * The scene the component belongs to.
  74052. */
  74053. scene: Scene;
  74054. /**
  74055. * Creates a new instance of the component for the given scene
  74056. * @param scene Defines the scene to register the component in
  74057. */
  74058. constructor(scene: Scene);
  74059. /**
  74060. * Registers the component in a given scene
  74061. */
  74062. register(): void;
  74063. /**
  74064. * Rebuilds the elements related to this component in case of
  74065. * context lost for instance.
  74066. */
  74067. rebuild(): void;
  74068. /**
  74069. * Disposes the component and the associated ressources.
  74070. */
  74071. dispose(): void;
  74072. private _beforeClear;
  74073. }
  74074. }
  74075. declare module BABYLON {
  74076. interface Engine {
  74077. /**
  74078. * Creates a new render target cube texture
  74079. * @param size defines the size of the texture
  74080. * @param options defines the options used to create the texture
  74081. * @returns a new render target cube texture stored in an InternalTexture
  74082. */
  74083. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74084. }
  74085. }
  74086. declare module BABYLON {
  74087. /** @hidden */
  74088. export var proceduralVertexShader: {
  74089. name: string;
  74090. shader: string;
  74091. };
  74092. }
  74093. declare module BABYLON {
  74094. /**
  74095. * 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.
  74096. * This is the base class of any Procedural texture and contains most of the shareable code.
  74097. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74098. */
  74099. export class ProceduralTexture extends Texture {
  74100. isCube: boolean;
  74101. /**
  74102. * Define if the texture is enabled or not (disabled texture will not render)
  74103. */
  74104. isEnabled: boolean;
  74105. /**
  74106. * Define if the texture must be cleared before rendering (default is true)
  74107. */
  74108. autoClear: boolean;
  74109. /**
  74110. * Callback called when the texture is generated
  74111. */
  74112. onGenerated: () => void;
  74113. /**
  74114. * Event raised when the texture is generated
  74115. */
  74116. onGeneratedObservable: Observable<ProceduralTexture>;
  74117. /** @hidden */
  74118. _generateMipMaps: boolean;
  74119. /** @hidden **/
  74120. _effect: Effect;
  74121. /** @hidden */
  74122. _textures: {
  74123. [key: string]: Texture;
  74124. };
  74125. private _size;
  74126. private _currentRefreshId;
  74127. private _refreshRate;
  74128. private _vertexBuffers;
  74129. private _indexBuffer;
  74130. private _uniforms;
  74131. private _samplers;
  74132. private _fragment;
  74133. private _floats;
  74134. private _ints;
  74135. private _floatsArrays;
  74136. private _colors3;
  74137. private _colors4;
  74138. private _vectors2;
  74139. private _vectors3;
  74140. private _matrices;
  74141. private _fallbackTexture;
  74142. private _fallbackTextureUsed;
  74143. private _engine;
  74144. private _cachedDefines;
  74145. private _contentUpdateId;
  74146. private _contentData;
  74147. /**
  74148. * Instantiates a new procedural texture.
  74149. * 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.
  74150. * This is the base class of any Procedural texture and contains most of the shareable code.
  74151. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74152. * @param name Define the name of the texture
  74153. * @param size Define the size of the texture to create
  74154. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74155. * @param scene Define the scene the texture belongs to
  74156. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74157. * @param generateMipMaps Define if the texture should creates mip maps or not
  74158. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74159. */
  74160. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74161. /**
  74162. * The effect that is created when initializing the post process.
  74163. * @returns The created effect corrisponding the the postprocess.
  74164. */
  74165. getEffect(): Effect;
  74166. /**
  74167. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74168. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74169. */
  74170. getContent(): Nullable<ArrayBufferView>;
  74171. private _createIndexBuffer;
  74172. /** @hidden */
  74173. _rebuild(): void;
  74174. /**
  74175. * Resets the texture in order to recreate its associated resources.
  74176. * This can be called in case of context loss
  74177. */
  74178. reset(): void;
  74179. protected _getDefines(): string;
  74180. /**
  74181. * Is the texture ready to be used ? (rendered at least once)
  74182. * @returns true if ready, otherwise, false.
  74183. */
  74184. isReady(): boolean;
  74185. /**
  74186. * Resets the refresh counter of the texture and start bak from scratch.
  74187. * Could be useful to regenerate the texture if it is setup to render only once.
  74188. */
  74189. resetRefreshCounter(): void;
  74190. /**
  74191. * Set the fragment shader to use in order to render the texture.
  74192. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74193. */
  74194. setFragment(fragment: any): void;
  74195. /**
  74196. * Define the refresh rate of the texture or the rendering frequency.
  74197. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74198. */
  74199. refreshRate: number;
  74200. /** @hidden */
  74201. _shouldRender(): boolean;
  74202. /**
  74203. * Get the size the texture is rendering at.
  74204. * @returns the size (texture is always squared)
  74205. */
  74206. getRenderSize(): number;
  74207. /**
  74208. * Resize the texture to new value.
  74209. * @param size Define the new size the texture should have
  74210. * @param generateMipMaps Define whether the new texture should create mip maps
  74211. */
  74212. resize(size: number, generateMipMaps: boolean): void;
  74213. private _checkUniform;
  74214. /**
  74215. * Set a texture in the shader program used to render.
  74216. * @param name Define the name of the uniform samplers as defined in the shader
  74217. * @param texture Define the texture to bind to this sampler
  74218. * @return the texture itself allowing "fluent" like uniform updates
  74219. */
  74220. setTexture(name: string, texture: Texture): ProceduralTexture;
  74221. /**
  74222. * Set a float in the shader.
  74223. * @param name Define the name of the uniform as defined in the shader
  74224. * @param value Define the value to give to the uniform
  74225. * @return the texture itself allowing "fluent" like uniform updates
  74226. */
  74227. setFloat(name: string, value: number): ProceduralTexture;
  74228. /**
  74229. * Set a int in the shader.
  74230. * @param name Define the name of the uniform as defined in the shader
  74231. * @param value Define the value to give to the uniform
  74232. * @return the texture itself allowing "fluent" like uniform updates
  74233. */
  74234. setInt(name: string, value: number): ProceduralTexture;
  74235. /**
  74236. * Set an array of floats in the shader.
  74237. * @param name Define the name of the uniform as defined in the shader
  74238. * @param value Define the value to give to the uniform
  74239. * @return the texture itself allowing "fluent" like uniform updates
  74240. */
  74241. setFloats(name: string, value: number[]): ProceduralTexture;
  74242. /**
  74243. * Set a vec3 in the shader from a Color3.
  74244. * @param name Define the name of the uniform as defined in the shader
  74245. * @param value Define the value to give to the uniform
  74246. * @return the texture itself allowing "fluent" like uniform updates
  74247. */
  74248. setColor3(name: string, value: Color3): ProceduralTexture;
  74249. /**
  74250. * Set a vec4 in the shader from a Color4.
  74251. * @param name Define the name of the uniform as defined in the shader
  74252. * @param value Define the value to give to the uniform
  74253. * @return the texture itself allowing "fluent" like uniform updates
  74254. */
  74255. setColor4(name: string, value: Color4): ProceduralTexture;
  74256. /**
  74257. * Set a vec2 in the shader from a Vector2.
  74258. * @param name Define the name of the uniform as defined in the shader
  74259. * @param value Define the value to give to the uniform
  74260. * @return the texture itself allowing "fluent" like uniform updates
  74261. */
  74262. setVector2(name: string, value: Vector2): ProceduralTexture;
  74263. /**
  74264. * Set a vec3 in the shader from a Vector3.
  74265. * @param name Define the name of the uniform as defined in the shader
  74266. * @param value Define the value to give to the uniform
  74267. * @return the texture itself allowing "fluent" like uniform updates
  74268. */
  74269. setVector3(name: string, value: Vector3): ProceduralTexture;
  74270. /**
  74271. * Set a mat4 in the shader from a MAtrix.
  74272. * @param name Define the name of the uniform as defined in the shader
  74273. * @param value Define the value to give to the uniform
  74274. * @return the texture itself allowing "fluent" like uniform updates
  74275. */
  74276. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74277. /**
  74278. * Render the texture to its associated render target.
  74279. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74280. */
  74281. render(useCameraPostProcess?: boolean): void;
  74282. /**
  74283. * Clone the texture.
  74284. * @returns the cloned texture
  74285. */
  74286. clone(): ProceduralTexture;
  74287. /**
  74288. * Dispose the texture and release its asoociated resources.
  74289. */
  74290. dispose(): void;
  74291. }
  74292. }
  74293. declare module BABYLON {
  74294. /**
  74295. * This represents the base class for particle system in Babylon.
  74296. * 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.
  74297. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74298. * @example https://doc.babylonjs.com/babylon101/particles
  74299. */
  74300. export class BaseParticleSystem {
  74301. /**
  74302. * Source color is added to the destination color without alpha affecting the result
  74303. */
  74304. static BLENDMODE_ONEONE: number;
  74305. /**
  74306. * Blend current color and particle color using particle’s alpha
  74307. */
  74308. static BLENDMODE_STANDARD: number;
  74309. /**
  74310. * Add current color and particle color multiplied by particle’s alpha
  74311. */
  74312. static BLENDMODE_ADD: number;
  74313. /**
  74314. * Multiply current color with particle color
  74315. */
  74316. static BLENDMODE_MULTIPLY: number;
  74317. /**
  74318. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74319. */
  74320. static BLENDMODE_MULTIPLYADD: number;
  74321. /**
  74322. * List of animations used by the particle system.
  74323. */
  74324. animations: Animation[];
  74325. /**
  74326. * The id of the Particle system.
  74327. */
  74328. id: string;
  74329. /**
  74330. * The friendly name of the Particle system.
  74331. */
  74332. name: string;
  74333. /**
  74334. * The rendering group used by the Particle system to chose when to render.
  74335. */
  74336. renderingGroupId: number;
  74337. /**
  74338. * The emitter represents the Mesh or position we are attaching the particle system to.
  74339. */
  74340. emitter: Nullable<AbstractMesh | Vector3>;
  74341. /**
  74342. * The maximum number of particles to emit per frame
  74343. */
  74344. emitRate: number;
  74345. /**
  74346. * If you want to launch only a few particles at once, that can be done, as well.
  74347. */
  74348. manualEmitCount: number;
  74349. /**
  74350. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74351. */
  74352. updateSpeed: number;
  74353. /**
  74354. * The amount of time the particle system is running (depends of the overall update speed).
  74355. */
  74356. targetStopDuration: number;
  74357. /**
  74358. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74359. */
  74360. disposeOnStop: boolean;
  74361. /**
  74362. * Minimum power of emitting particles.
  74363. */
  74364. minEmitPower: number;
  74365. /**
  74366. * Maximum power of emitting particles.
  74367. */
  74368. maxEmitPower: number;
  74369. /**
  74370. * Minimum life time of emitting particles.
  74371. */
  74372. minLifeTime: number;
  74373. /**
  74374. * Maximum life time of emitting particles.
  74375. */
  74376. maxLifeTime: number;
  74377. /**
  74378. * Minimum Size of emitting particles.
  74379. */
  74380. minSize: number;
  74381. /**
  74382. * Maximum Size of emitting particles.
  74383. */
  74384. maxSize: number;
  74385. /**
  74386. * Minimum scale of emitting particles on X axis.
  74387. */
  74388. minScaleX: number;
  74389. /**
  74390. * Maximum scale of emitting particles on X axis.
  74391. */
  74392. maxScaleX: number;
  74393. /**
  74394. * Minimum scale of emitting particles on Y axis.
  74395. */
  74396. minScaleY: number;
  74397. /**
  74398. * Maximum scale of emitting particles on Y axis.
  74399. */
  74400. maxScaleY: number;
  74401. /**
  74402. * Gets or sets the minimal initial rotation in radians.
  74403. */
  74404. minInitialRotation: number;
  74405. /**
  74406. * Gets or sets the maximal initial rotation in radians.
  74407. */
  74408. maxInitialRotation: number;
  74409. /**
  74410. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74411. */
  74412. minAngularSpeed: number;
  74413. /**
  74414. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74415. */
  74416. maxAngularSpeed: number;
  74417. /**
  74418. * The texture used to render each particle. (this can be a spritesheet)
  74419. */
  74420. particleTexture: Nullable<Texture>;
  74421. /**
  74422. * The layer mask we are rendering the particles through.
  74423. */
  74424. layerMask: number;
  74425. /**
  74426. * This can help using your own shader to render the particle system.
  74427. * The according effect will be created
  74428. */
  74429. customShader: any;
  74430. /**
  74431. * By default particle system starts as soon as they are created. This prevents the
  74432. * automatic start to happen and let you decide when to start emitting particles.
  74433. */
  74434. preventAutoStart: boolean;
  74435. private _noiseTexture;
  74436. /**
  74437. * Gets or sets a texture used to add random noise to particle positions
  74438. */
  74439. noiseTexture: Nullable<ProceduralTexture>;
  74440. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74441. noiseStrength: Vector3;
  74442. /**
  74443. * Callback triggered when the particle animation is ending.
  74444. */
  74445. onAnimationEnd: Nullable<() => void>;
  74446. /**
  74447. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74448. */
  74449. blendMode: number;
  74450. /**
  74451. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74452. * to override the particles.
  74453. */
  74454. forceDepthWrite: boolean;
  74455. /** 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 */
  74456. preWarmCycles: number;
  74457. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74458. preWarmStepOffset: number;
  74459. /**
  74460. * 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)
  74461. */
  74462. spriteCellChangeSpeed: number;
  74463. /**
  74464. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74465. */
  74466. startSpriteCellID: number;
  74467. /**
  74468. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74469. */
  74470. endSpriteCellID: number;
  74471. /**
  74472. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74473. */
  74474. spriteCellWidth: number;
  74475. /**
  74476. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74477. */
  74478. spriteCellHeight: number;
  74479. /**
  74480. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74481. */
  74482. spriteRandomStartCell: boolean;
  74483. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74484. translationPivot: Vector2;
  74485. /** @hidden */
  74486. protected _isAnimationSheetEnabled: boolean;
  74487. /**
  74488. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74489. */
  74490. beginAnimationOnStart: boolean;
  74491. /**
  74492. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74493. */
  74494. beginAnimationFrom: number;
  74495. /**
  74496. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74497. */
  74498. beginAnimationTo: number;
  74499. /**
  74500. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74501. */
  74502. beginAnimationLoop: boolean;
  74503. /**
  74504. * Gets or sets a world offset applied to all particles
  74505. */
  74506. worldOffset: Vector3;
  74507. /**
  74508. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74509. */
  74510. isAnimationSheetEnabled: boolean;
  74511. /**
  74512. * Get hosting scene
  74513. * @returns the scene
  74514. */
  74515. getScene(): Scene;
  74516. /**
  74517. * You can use gravity if you want to give an orientation to your particles.
  74518. */
  74519. gravity: Vector3;
  74520. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74521. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74522. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74523. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74524. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74525. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74526. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74527. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74528. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74529. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74530. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74531. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74532. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74533. /**
  74534. * Defines the delay in milliseconds before starting the system (0 by default)
  74535. */
  74536. startDelay: number;
  74537. /**
  74538. * Gets the current list of drag gradients.
  74539. * You must use addDragGradient and removeDragGradient to udpate this list
  74540. * @returns the list of drag gradients
  74541. */
  74542. getDragGradients(): Nullable<Array<FactorGradient>>;
  74543. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74544. limitVelocityDamping: number;
  74545. /**
  74546. * Gets the current list of limit velocity gradients.
  74547. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74548. * @returns the list of limit velocity gradients
  74549. */
  74550. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74551. /**
  74552. * Gets the current list of color gradients.
  74553. * You must use addColorGradient and removeColorGradient to udpate this list
  74554. * @returns the list of color gradients
  74555. */
  74556. getColorGradients(): Nullable<Array<ColorGradient>>;
  74557. /**
  74558. * Gets the current list of size gradients.
  74559. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74560. * @returns the list of size gradients
  74561. */
  74562. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74563. /**
  74564. * Gets the current list of color remap gradients.
  74565. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74566. * @returns the list of color remap gradients
  74567. */
  74568. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74569. /**
  74570. * Gets the current list of alpha remap gradients.
  74571. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74572. * @returns the list of alpha remap gradients
  74573. */
  74574. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74575. /**
  74576. * Gets the current list of life time gradients.
  74577. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74578. * @returns the list of life time gradients
  74579. */
  74580. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74581. /**
  74582. * Gets the current list of angular speed gradients.
  74583. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74584. * @returns the list of angular speed gradients
  74585. */
  74586. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74587. /**
  74588. * Gets the current list of velocity gradients.
  74589. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74590. * @returns the list of velocity gradients
  74591. */
  74592. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74593. /**
  74594. * Gets the current list of start size gradients.
  74595. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74596. * @returns the list of start size gradients
  74597. */
  74598. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74599. /**
  74600. * Gets the current list of emit rate gradients.
  74601. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74602. * @returns the list of emit rate gradients
  74603. */
  74604. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74605. /**
  74606. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74607. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74608. */
  74609. direction1: Vector3;
  74610. /**
  74611. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74612. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74613. */
  74614. direction2: Vector3;
  74615. /**
  74616. * 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.
  74617. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74618. */
  74619. minEmitBox: Vector3;
  74620. /**
  74621. * 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.
  74622. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74623. */
  74624. maxEmitBox: Vector3;
  74625. /**
  74626. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74627. */
  74628. color1: Color4;
  74629. /**
  74630. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74631. */
  74632. color2: Color4;
  74633. /**
  74634. * Color the particle will have at the end of its lifetime
  74635. */
  74636. colorDead: Color4;
  74637. /**
  74638. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74639. */
  74640. textureMask: Color4;
  74641. /**
  74642. * The particle emitter type defines the emitter used by the particle system.
  74643. * It can be for example box, sphere, or cone...
  74644. */
  74645. particleEmitterType: IParticleEmitterType;
  74646. /** @hidden */
  74647. _isSubEmitter: boolean;
  74648. /**
  74649. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74650. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74651. */
  74652. billboardMode: number;
  74653. protected _isBillboardBased: boolean;
  74654. /**
  74655. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74656. */
  74657. isBillboardBased: boolean;
  74658. /**
  74659. * The scene the particle system belongs to.
  74660. */
  74661. protected _scene: Scene;
  74662. /**
  74663. * Local cache of defines for image processing.
  74664. */
  74665. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74666. /**
  74667. * Default configuration related to image processing available in the standard Material.
  74668. */
  74669. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74670. /**
  74671. * Gets the image processing configuration used either in this material.
  74672. */
  74673. /**
  74674. * Sets the Default image processing configuration used either in the this material.
  74675. *
  74676. * If sets to null, the scene one is in use.
  74677. */
  74678. imageProcessingConfiguration: ImageProcessingConfiguration;
  74679. /**
  74680. * Attaches a new image processing configuration to the Standard Material.
  74681. * @param configuration
  74682. */
  74683. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74684. /** @hidden */
  74685. protected _reset(): void;
  74686. /** @hidden */
  74687. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74688. /**
  74689. * Instantiates a particle system.
  74690. * 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.
  74691. * @param name The name of the particle system
  74692. */
  74693. constructor(name: string);
  74694. /**
  74695. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74696. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74697. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74698. * @returns the emitter
  74699. */
  74700. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74701. /**
  74702. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74703. * @param radius The radius of the hemisphere to emit from
  74704. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74705. * @returns the emitter
  74706. */
  74707. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74708. /**
  74709. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74710. * @param radius The radius of the sphere to emit from
  74711. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74712. * @returns the emitter
  74713. */
  74714. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74715. /**
  74716. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74717. * @param radius The radius of the sphere to emit from
  74718. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74719. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74720. * @returns the emitter
  74721. */
  74722. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74723. /**
  74724. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74725. * @param radius The radius of the emission cylinder
  74726. * @param height The height of the emission cylinder
  74727. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74728. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74729. * @returns the emitter
  74730. */
  74731. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74732. /**
  74733. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74734. * @param radius The radius of the cylinder to emit from
  74735. * @param height The height of the emission cylinder
  74736. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74739. * @returns the emitter
  74740. */
  74741. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74742. /**
  74743. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74744. * @param radius The radius of the cone to emit from
  74745. * @param angle The base angle of the cone
  74746. * @returns the emitter
  74747. */
  74748. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74749. /**
  74750. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74751. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74752. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74753. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74754. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74755. * @returns the emitter
  74756. */
  74757. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74758. }
  74759. }
  74760. declare module BABYLON {
  74761. /**
  74762. * Type of sub emitter
  74763. */
  74764. export enum SubEmitterType {
  74765. /**
  74766. * Attached to the particle over it's lifetime
  74767. */
  74768. ATTACHED = 0,
  74769. /**
  74770. * Created when the particle dies
  74771. */
  74772. END = 1
  74773. }
  74774. /**
  74775. * Sub emitter class used to emit particles from an existing particle
  74776. */
  74777. export class SubEmitter {
  74778. /**
  74779. * the particle system to be used by the sub emitter
  74780. */
  74781. particleSystem: ParticleSystem;
  74782. /**
  74783. * Type of the submitter (Default: END)
  74784. */
  74785. type: SubEmitterType;
  74786. /**
  74787. * 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)
  74788. * Note: This only is supported when using an emitter of type Mesh
  74789. */
  74790. inheritDirection: boolean;
  74791. /**
  74792. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74793. */
  74794. inheritedVelocityAmount: number;
  74795. /**
  74796. * Creates a sub emitter
  74797. * @param particleSystem the particle system to be used by the sub emitter
  74798. */
  74799. constructor(
  74800. /**
  74801. * the particle system to be used by the sub emitter
  74802. */
  74803. particleSystem: ParticleSystem);
  74804. /**
  74805. * Clones the sub emitter
  74806. * @returns the cloned sub emitter
  74807. */
  74808. clone(): SubEmitter;
  74809. /**
  74810. * Serialize current object to a JSON object
  74811. * @returns the serialized object
  74812. */
  74813. serialize(): any;
  74814. /** @hidden */
  74815. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74816. /**
  74817. * Creates a new SubEmitter from a serialized JSON version
  74818. * @param serializationObject defines the JSON object to read from
  74819. * @param scene defines the hosting scene
  74820. * @param rootUrl defines the rootUrl for data loading
  74821. * @returns a new SubEmitter
  74822. */
  74823. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74824. /** Release associated resources */
  74825. dispose(): void;
  74826. }
  74827. }
  74828. declare module BABYLON {
  74829. /** @hidden */
  74830. export var clipPlaneFragmentDeclaration: {
  74831. name: string;
  74832. shader: string;
  74833. };
  74834. }
  74835. declare module BABYLON {
  74836. /** @hidden */
  74837. export var imageProcessingDeclaration: {
  74838. name: string;
  74839. shader: string;
  74840. };
  74841. }
  74842. declare module BABYLON {
  74843. /** @hidden */
  74844. export var imageProcessingFunctions: {
  74845. name: string;
  74846. shader: string;
  74847. };
  74848. }
  74849. declare module BABYLON {
  74850. /** @hidden */
  74851. export var clipPlaneFragment: {
  74852. name: string;
  74853. shader: string;
  74854. };
  74855. }
  74856. declare module BABYLON {
  74857. /** @hidden */
  74858. export var particlesPixelShader: {
  74859. name: string;
  74860. shader: string;
  74861. };
  74862. }
  74863. declare module BABYLON {
  74864. /** @hidden */
  74865. export var clipPlaneVertexDeclaration: {
  74866. name: string;
  74867. shader: string;
  74868. };
  74869. }
  74870. declare module BABYLON {
  74871. /** @hidden */
  74872. export var clipPlaneVertex: {
  74873. name: string;
  74874. shader: string;
  74875. };
  74876. }
  74877. declare module BABYLON {
  74878. /** @hidden */
  74879. export var particlesVertexShader: {
  74880. name: string;
  74881. shader: string;
  74882. };
  74883. }
  74884. declare module BABYLON {
  74885. /**
  74886. * This represents a particle system in Babylon.
  74887. * 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.
  74888. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74889. * @example https://doc.babylonjs.com/babylon101/particles
  74890. */
  74891. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74892. /**
  74893. * Billboard mode will only apply to Y axis
  74894. */
  74895. static readonly BILLBOARDMODE_Y: number;
  74896. /**
  74897. * Billboard mode will apply to all axes
  74898. */
  74899. static readonly BILLBOARDMODE_ALL: number;
  74900. /**
  74901. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74902. */
  74903. static readonly BILLBOARDMODE_STRETCHED: number;
  74904. /**
  74905. * This function can be defined to provide custom update for active particles.
  74906. * This function will be called instead of regular update (age, position, color, etc.).
  74907. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74908. */
  74909. updateFunction: (particles: Particle[]) => void;
  74910. private _emitterWorldMatrix;
  74911. /**
  74912. * This function can be defined to specify initial direction for every new particle.
  74913. * It by default use the emitterType defined function
  74914. */
  74915. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74916. /**
  74917. * This function can be defined to specify initial position for every new particle.
  74918. * It by default use the emitterType defined function
  74919. */
  74920. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74921. /**
  74922. * @hidden
  74923. */
  74924. _inheritedVelocityOffset: Vector3;
  74925. /**
  74926. * An event triggered when the system is disposed
  74927. */
  74928. onDisposeObservable: Observable<ParticleSystem>;
  74929. private _onDisposeObserver;
  74930. /**
  74931. * Sets a callback that will be triggered when the system is disposed
  74932. */
  74933. onDispose: () => void;
  74934. private _particles;
  74935. private _epsilon;
  74936. private _capacity;
  74937. private _stockParticles;
  74938. private _newPartsExcess;
  74939. private _vertexData;
  74940. private _vertexBuffer;
  74941. private _vertexBuffers;
  74942. private _spriteBuffer;
  74943. private _indexBuffer;
  74944. private _effect;
  74945. private _customEffect;
  74946. private _cachedDefines;
  74947. private _scaledColorStep;
  74948. private _colorDiff;
  74949. private _scaledDirection;
  74950. private _scaledGravity;
  74951. private _currentRenderId;
  74952. private _alive;
  74953. private _useInstancing;
  74954. private _started;
  74955. private _stopped;
  74956. private _actualFrame;
  74957. private _scaledUpdateSpeed;
  74958. private _vertexBufferSize;
  74959. /** @hidden */
  74960. _currentEmitRateGradient: Nullable<FactorGradient>;
  74961. /** @hidden */
  74962. _currentEmitRate1: number;
  74963. /** @hidden */
  74964. _currentEmitRate2: number;
  74965. /** @hidden */
  74966. _currentStartSizeGradient: Nullable<FactorGradient>;
  74967. /** @hidden */
  74968. _currentStartSize1: number;
  74969. /** @hidden */
  74970. _currentStartSize2: number;
  74971. private readonly _rawTextureWidth;
  74972. private _rampGradientsTexture;
  74973. private _useRampGradients;
  74974. /** Gets or sets a boolean indicating that ramp gradients must be used
  74975. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74976. */
  74977. useRampGradients: boolean;
  74978. /**
  74979. * 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.
  74980. * 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: [])
  74981. */
  74982. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74983. private _subEmitters;
  74984. /**
  74985. * @hidden
  74986. * If the particle systems emitter should be disposed when the particle system is disposed
  74987. */
  74988. _disposeEmitterOnDispose: boolean;
  74989. /**
  74990. * The current active Sub-systems, this property is used by the root particle system only.
  74991. */
  74992. activeSubSystems: Array<ParticleSystem>;
  74993. private _rootParticleSystem;
  74994. /**
  74995. * Gets the current list of active particles
  74996. */
  74997. readonly particles: Particle[];
  74998. /**
  74999. * Returns the string "ParticleSystem"
  75000. * @returns a string containing the class name
  75001. */
  75002. getClassName(): string;
  75003. /**
  75004. * Instantiates a particle system.
  75005. * 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.
  75006. * @param name The name of the particle system
  75007. * @param capacity The max number of particles alive at the same time
  75008. * @param scene The scene the particle system belongs to
  75009. * @param customEffect a custom effect used to change the way particles are rendered by default
  75010. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75011. * @param epsilon Offset used to render the particles
  75012. */
  75013. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  75014. private _addFactorGradient;
  75015. private _removeFactorGradient;
  75016. /**
  75017. * Adds a new life time gradient
  75018. * @param gradient defines the gradient to use (between 0 and 1)
  75019. * @param factor defines the life time factor to affect to the specified gradient
  75020. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75021. * @returns the current particle system
  75022. */
  75023. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75024. /**
  75025. * Remove a specific life time gradient
  75026. * @param gradient defines the gradient to remove
  75027. * @returns the current particle system
  75028. */
  75029. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75030. /**
  75031. * Adds a new size gradient
  75032. * @param gradient defines the gradient to use (between 0 and 1)
  75033. * @param factor defines the size factor to affect to the specified gradient
  75034. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75035. * @returns the current particle system
  75036. */
  75037. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75038. /**
  75039. * Remove a specific size gradient
  75040. * @param gradient defines the gradient to remove
  75041. * @returns the current particle system
  75042. */
  75043. removeSizeGradient(gradient: number): IParticleSystem;
  75044. /**
  75045. * Adds a new color remap gradient
  75046. * @param gradient defines the gradient to use (between 0 and 1)
  75047. * @param min defines the color remap minimal range
  75048. * @param max defines the color remap maximal range
  75049. * @returns the current particle system
  75050. */
  75051. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75052. /**
  75053. * Remove a specific color remap gradient
  75054. * @param gradient defines the gradient to remove
  75055. * @returns the current particle system
  75056. */
  75057. removeColorRemapGradient(gradient: number): IParticleSystem;
  75058. /**
  75059. * Adds a new alpha remap gradient
  75060. * @param gradient defines the gradient to use (between 0 and 1)
  75061. * @param min defines the alpha remap minimal range
  75062. * @param max defines the alpha remap maximal range
  75063. * @returns the current particle system
  75064. */
  75065. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75066. /**
  75067. * Remove a specific alpha remap gradient
  75068. * @param gradient defines the gradient to remove
  75069. * @returns the current particle system
  75070. */
  75071. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75072. /**
  75073. * Adds a new angular speed gradient
  75074. * @param gradient defines the gradient to use (between 0 and 1)
  75075. * @param factor defines the angular speed to affect to the specified gradient
  75076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75077. * @returns the current particle system
  75078. */
  75079. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75080. /**
  75081. * Remove a specific angular speed gradient
  75082. * @param gradient defines the gradient to remove
  75083. * @returns the current particle system
  75084. */
  75085. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75086. /**
  75087. * Adds a new velocity gradient
  75088. * @param gradient defines the gradient to use (between 0 and 1)
  75089. * @param factor defines the velocity to affect to the specified gradient
  75090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75091. * @returns the current particle system
  75092. */
  75093. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75094. /**
  75095. * Remove a specific velocity gradient
  75096. * @param gradient defines the gradient to remove
  75097. * @returns the current particle system
  75098. */
  75099. removeVelocityGradient(gradient: number): IParticleSystem;
  75100. /**
  75101. * Adds a new limit velocity gradient
  75102. * @param gradient defines the gradient to use (between 0 and 1)
  75103. * @param factor defines the limit velocity value to affect to the specified gradient
  75104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75105. * @returns the current particle system
  75106. */
  75107. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75108. /**
  75109. * Remove a specific limit velocity gradient
  75110. * @param gradient defines the gradient to remove
  75111. * @returns the current particle system
  75112. */
  75113. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75114. /**
  75115. * Adds a new drag gradient
  75116. * @param gradient defines the gradient to use (between 0 and 1)
  75117. * @param factor defines the drag value to affect to the specified gradient
  75118. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75119. * @returns the current particle system
  75120. */
  75121. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75122. /**
  75123. * Remove a specific drag gradient
  75124. * @param gradient defines the gradient to remove
  75125. * @returns the current particle system
  75126. */
  75127. removeDragGradient(gradient: number): IParticleSystem;
  75128. /**
  75129. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75130. * @param gradient defines the gradient to use (between 0 and 1)
  75131. * @param factor defines the emit rate value to affect to the specified gradient
  75132. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75133. * @returns the current particle system
  75134. */
  75135. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75136. /**
  75137. * Remove a specific emit rate gradient
  75138. * @param gradient defines the gradient to remove
  75139. * @returns the current particle system
  75140. */
  75141. removeEmitRateGradient(gradient: number): IParticleSystem;
  75142. /**
  75143. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75144. * @param gradient defines the gradient to use (between 0 and 1)
  75145. * @param factor defines the start size value to affect to the specified gradient
  75146. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75147. * @returns the current particle system
  75148. */
  75149. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75150. /**
  75151. * Remove a specific start size gradient
  75152. * @param gradient defines the gradient to remove
  75153. * @returns the current particle system
  75154. */
  75155. removeStartSizeGradient(gradient: number): IParticleSystem;
  75156. private _createRampGradientTexture;
  75157. /**
  75158. * Gets the current list of ramp gradients.
  75159. * You must use addRampGradient and removeRampGradient to udpate this list
  75160. * @returns the list of ramp gradients
  75161. */
  75162. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75163. /**
  75164. * Adds a new ramp gradient used to remap particle colors
  75165. * @param gradient defines the gradient to use (between 0 and 1)
  75166. * @param color defines the color to affect to the specified gradient
  75167. * @returns the current particle system
  75168. */
  75169. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75170. /**
  75171. * Remove a specific ramp gradient
  75172. * @param gradient defines the gradient to remove
  75173. * @returns the current particle system
  75174. */
  75175. removeRampGradient(gradient: number): ParticleSystem;
  75176. /**
  75177. * Adds a new color gradient
  75178. * @param gradient defines the gradient to use (between 0 and 1)
  75179. * @param color1 defines the color to affect to the specified gradient
  75180. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75181. * @returns this particle system
  75182. */
  75183. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75184. /**
  75185. * Remove a specific color gradient
  75186. * @param gradient defines the gradient to remove
  75187. * @returns this particle system
  75188. */
  75189. removeColorGradient(gradient: number): IParticleSystem;
  75190. private _fetchR;
  75191. protected _reset(): void;
  75192. private _resetEffect;
  75193. private _createVertexBuffers;
  75194. private _createIndexBuffer;
  75195. /**
  75196. * Gets the maximum number of particles active at the same time.
  75197. * @returns The max number of active particles.
  75198. */
  75199. getCapacity(): number;
  75200. /**
  75201. * Gets whether there are still active particles in the system.
  75202. * @returns True if it is alive, otherwise false.
  75203. */
  75204. isAlive(): boolean;
  75205. /**
  75206. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75207. * @returns True if it has been started, otherwise false.
  75208. */
  75209. isStarted(): boolean;
  75210. private _prepareSubEmitterInternalArray;
  75211. /**
  75212. * Starts the particle system and begins to emit
  75213. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75214. */
  75215. start(delay?: number): void;
  75216. /**
  75217. * Stops the particle system.
  75218. * @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.
  75219. */
  75220. stop(stopSubEmitters?: boolean): void;
  75221. /**
  75222. * Remove all active particles
  75223. */
  75224. reset(): void;
  75225. /**
  75226. * @hidden (for internal use only)
  75227. */
  75228. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75229. /**
  75230. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75231. * Its lifetime will start back at 0.
  75232. */
  75233. recycleParticle: (particle: Particle) => void;
  75234. private _stopSubEmitters;
  75235. private _createParticle;
  75236. private _removeFromRoot;
  75237. private _emitFromParticle;
  75238. private _update;
  75239. /** @hidden */
  75240. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75241. /** @hidden */
  75242. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75243. /** @hidden */
  75244. private _getEffect;
  75245. /**
  75246. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75247. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75248. */
  75249. animate(preWarmOnly?: boolean): void;
  75250. private _appendParticleVertices;
  75251. /**
  75252. * Rebuilds the particle system.
  75253. */
  75254. rebuild(): void;
  75255. /**
  75256. * Is this system ready to be used/rendered
  75257. * @return true if the system is ready
  75258. */
  75259. isReady(): boolean;
  75260. private _render;
  75261. /**
  75262. * Renders the particle system in its current state.
  75263. * @returns the current number of particles
  75264. */
  75265. render(): number;
  75266. /**
  75267. * Disposes the particle system and free the associated resources
  75268. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75269. */
  75270. dispose(disposeTexture?: boolean): void;
  75271. /**
  75272. * Clones the particle system.
  75273. * @param name The name of the cloned object
  75274. * @param newEmitter The new emitter to use
  75275. * @returns the cloned particle system
  75276. */
  75277. clone(name: string, newEmitter: any): ParticleSystem;
  75278. /**
  75279. * Serializes the particle system to a JSON object.
  75280. * @returns the JSON object
  75281. */
  75282. serialize(): any;
  75283. /** @hidden */
  75284. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75285. /** @hidden */
  75286. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75287. /**
  75288. * Parses a JSON object to create a particle system.
  75289. * @param parsedParticleSystem The JSON object to parse
  75290. * @param scene The scene to create the particle system in
  75291. * @param rootUrl The root url to use to load external dependencies like texture
  75292. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75293. * @returns the Parsed particle system
  75294. */
  75295. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75296. }
  75297. }
  75298. declare module BABYLON {
  75299. /**
  75300. * A particle represents one of the element emitted by a particle system.
  75301. * This is mainly define by its coordinates, direction, velocity and age.
  75302. */
  75303. export class Particle {
  75304. /**
  75305. * The particle system the particle belongs to.
  75306. */
  75307. particleSystem: ParticleSystem;
  75308. private static _Count;
  75309. /**
  75310. * Unique ID of the particle
  75311. */
  75312. id: number;
  75313. /**
  75314. * The world position of the particle in the scene.
  75315. */
  75316. position: Vector3;
  75317. /**
  75318. * The world direction of the particle in the scene.
  75319. */
  75320. direction: Vector3;
  75321. /**
  75322. * The color of the particle.
  75323. */
  75324. color: Color4;
  75325. /**
  75326. * The color change of the particle per step.
  75327. */
  75328. colorStep: Color4;
  75329. /**
  75330. * Defines how long will the life of the particle be.
  75331. */
  75332. lifeTime: number;
  75333. /**
  75334. * The current age of the particle.
  75335. */
  75336. age: number;
  75337. /**
  75338. * The current size of the particle.
  75339. */
  75340. size: number;
  75341. /**
  75342. * The current scale of the particle.
  75343. */
  75344. scale: Vector2;
  75345. /**
  75346. * The current angle of the particle.
  75347. */
  75348. angle: number;
  75349. /**
  75350. * Defines how fast is the angle changing.
  75351. */
  75352. angularSpeed: number;
  75353. /**
  75354. * Defines the cell index used by the particle to be rendered from a sprite.
  75355. */
  75356. cellIndex: number;
  75357. /**
  75358. * The information required to support color remapping
  75359. */
  75360. remapData: Vector4;
  75361. /** @hidden */
  75362. _randomCellOffset?: number;
  75363. /** @hidden */
  75364. _initialDirection: Nullable<Vector3>;
  75365. /** @hidden */
  75366. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75367. /** @hidden */
  75368. _initialStartSpriteCellID: number;
  75369. /** @hidden */
  75370. _initialEndSpriteCellID: number;
  75371. /** @hidden */
  75372. _currentColorGradient: Nullable<ColorGradient>;
  75373. /** @hidden */
  75374. _currentColor1: Color4;
  75375. /** @hidden */
  75376. _currentColor2: Color4;
  75377. /** @hidden */
  75378. _currentSizeGradient: Nullable<FactorGradient>;
  75379. /** @hidden */
  75380. _currentSize1: number;
  75381. /** @hidden */
  75382. _currentSize2: number;
  75383. /** @hidden */
  75384. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75385. /** @hidden */
  75386. _currentAngularSpeed1: number;
  75387. /** @hidden */
  75388. _currentAngularSpeed2: number;
  75389. /** @hidden */
  75390. _currentVelocityGradient: Nullable<FactorGradient>;
  75391. /** @hidden */
  75392. _currentVelocity1: number;
  75393. /** @hidden */
  75394. _currentVelocity2: number;
  75395. /** @hidden */
  75396. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75397. /** @hidden */
  75398. _currentLimitVelocity1: number;
  75399. /** @hidden */
  75400. _currentLimitVelocity2: number;
  75401. /** @hidden */
  75402. _currentDragGradient: Nullable<FactorGradient>;
  75403. /** @hidden */
  75404. _currentDrag1: number;
  75405. /** @hidden */
  75406. _currentDrag2: number;
  75407. /** @hidden */
  75408. _randomNoiseCoordinates1: Vector3;
  75409. /** @hidden */
  75410. _randomNoiseCoordinates2: Vector3;
  75411. /**
  75412. * Creates a new instance Particle
  75413. * @param particleSystem the particle system the particle belongs to
  75414. */
  75415. constructor(
  75416. /**
  75417. * The particle system the particle belongs to.
  75418. */
  75419. particleSystem: ParticleSystem);
  75420. private updateCellInfoFromSystem;
  75421. /**
  75422. * Defines how the sprite cell index is updated for the particle
  75423. */
  75424. updateCellIndex(): void;
  75425. /** @hidden */
  75426. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75427. /** @hidden */
  75428. _inheritParticleInfoToSubEmitters(): void;
  75429. /** @hidden */
  75430. _reset(): void;
  75431. /**
  75432. * Copy the properties of particle to another one.
  75433. * @param other the particle to copy the information to.
  75434. */
  75435. copyTo(other: Particle): void;
  75436. }
  75437. }
  75438. declare module BABYLON {
  75439. /**
  75440. * Particle emitter represents a volume emitting particles.
  75441. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75442. */
  75443. export interface IParticleEmitterType {
  75444. /**
  75445. * Called by the particle System when the direction is computed for the created particle.
  75446. * @param worldMatrix is the world matrix of the particle system
  75447. * @param directionToUpdate is the direction vector to update with the result
  75448. * @param particle is the particle we are computed the direction for
  75449. */
  75450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75451. /**
  75452. * Called by the particle System when the position is computed for the created particle.
  75453. * @param worldMatrix is the world matrix of the particle system
  75454. * @param positionToUpdate is the position vector to update with the result
  75455. * @param particle is the particle we are computed the position for
  75456. */
  75457. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75458. /**
  75459. * Clones the current emitter and returns a copy of it
  75460. * @returns the new emitter
  75461. */
  75462. clone(): IParticleEmitterType;
  75463. /**
  75464. * Called by the GPUParticleSystem to setup the update shader
  75465. * @param effect defines the update shader
  75466. */
  75467. applyToShader(effect: Effect): void;
  75468. /**
  75469. * Returns a string to use to update the GPU particles update shader
  75470. * @returns the effect defines string
  75471. */
  75472. getEffectDefines(): string;
  75473. /**
  75474. * Returns a string representing the class name
  75475. * @returns a string containing the class name
  75476. */
  75477. getClassName(): string;
  75478. /**
  75479. * Serializes the particle system to a JSON object.
  75480. * @returns the JSON object
  75481. */
  75482. serialize(): any;
  75483. /**
  75484. * Parse properties from a JSON object
  75485. * @param serializationObject defines the JSON object
  75486. */
  75487. parse(serializationObject: any): void;
  75488. }
  75489. }
  75490. declare module BABYLON {
  75491. /**
  75492. * Particle emitter emitting particles from the inside of a box.
  75493. * It emits the particles randomly between 2 given directions.
  75494. */
  75495. export class BoxParticleEmitter implements IParticleEmitterType {
  75496. /**
  75497. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75498. */
  75499. direction1: Vector3;
  75500. /**
  75501. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75502. */
  75503. direction2: Vector3;
  75504. /**
  75505. * 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.
  75506. */
  75507. minEmitBox: Vector3;
  75508. /**
  75509. * 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.
  75510. */
  75511. maxEmitBox: Vector3;
  75512. /**
  75513. * Creates a new instance BoxParticleEmitter
  75514. */
  75515. constructor();
  75516. /**
  75517. * Called by the particle System when the direction is computed for the created particle.
  75518. * @param worldMatrix is the world matrix of the particle system
  75519. * @param directionToUpdate is the direction vector to update with the result
  75520. * @param particle is the particle we are computed the direction for
  75521. */
  75522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75523. /**
  75524. * Called by the particle System when the position is computed for the created particle.
  75525. * @param worldMatrix is the world matrix of the particle system
  75526. * @param positionToUpdate is the position vector to update with the result
  75527. * @param particle is the particle we are computed the position for
  75528. */
  75529. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75530. /**
  75531. * Clones the current emitter and returns a copy of it
  75532. * @returns the new emitter
  75533. */
  75534. clone(): BoxParticleEmitter;
  75535. /**
  75536. * Called by the GPUParticleSystem to setup the update shader
  75537. * @param effect defines the update shader
  75538. */
  75539. applyToShader(effect: Effect): void;
  75540. /**
  75541. * Returns a string to use to update the GPU particles update shader
  75542. * @returns a string containng the defines string
  75543. */
  75544. getEffectDefines(): string;
  75545. /**
  75546. * Returns the string "BoxParticleEmitter"
  75547. * @returns a string containing the class name
  75548. */
  75549. getClassName(): string;
  75550. /**
  75551. * Serializes the particle system to a JSON object.
  75552. * @returns the JSON object
  75553. */
  75554. serialize(): any;
  75555. /**
  75556. * Parse properties from a JSON object
  75557. * @param serializationObject defines the JSON object
  75558. */
  75559. parse(serializationObject: any): void;
  75560. }
  75561. }
  75562. declare module BABYLON {
  75563. /**
  75564. * Particle emitter emitting particles from the inside of a cone.
  75565. * It emits the particles alongside the cone volume from the base to the particle.
  75566. * The emission direction might be randomized.
  75567. */
  75568. export class ConeParticleEmitter implements IParticleEmitterType {
  75569. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75570. directionRandomizer: number;
  75571. private _radius;
  75572. private _angle;
  75573. private _height;
  75574. /**
  75575. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75576. */
  75577. radiusRange: number;
  75578. /**
  75579. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75580. */
  75581. heightRange: number;
  75582. /**
  75583. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75584. */
  75585. emitFromSpawnPointOnly: boolean;
  75586. /**
  75587. * Gets or sets the radius of the emission cone
  75588. */
  75589. radius: number;
  75590. /**
  75591. * Gets or sets the angle of the emission cone
  75592. */
  75593. angle: number;
  75594. private _buildHeight;
  75595. /**
  75596. * Creates a new instance ConeParticleEmitter
  75597. * @param radius the radius of the emission cone (1 by default)
  75598. * @param angle the cone base angle (PI by default)
  75599. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75600. */
  75601. constructor(radius?: number, angle?: number,
  75602. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75603. directionRandomizer?: number);
  75604. /**
  75605. * Called by the particle System when the direction is computed for the created particle.
  75606. * @param worldMatrix is the world matrix of the particle system
  75607. * @param directionToUpdate is the direction vector to update with the result
  75608. * @param particle is the particle we are computed the direction for
  75609. */
  75610. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75611. /**
  75612. * Called by the particle System when the position is computed for the created particle.
  75613. * @param worldMatrix is the world matrix of the particle system
  75614. * @param positionToUpdate is the position vector to update with the result
  75615. * @param particle is the particle we are computed the position for
  75616. */
  75617. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75618. /**
  75619. * Clones the current emitter and returns a copy of it
  75620. * @returns the new emitter
  75621. */
  75622. clone(): ConeParticleEmitter;
  75623. /**
  75624. * Called by the GPUParticleSystem to setup the update shader
  75625. * @param effect defines the update shader
  75626. */
  75627. applyToShader(effect: Effect): void;
  75628. /**
  75629. * Returns a string to use to update the GPU particles update shader
  75630. * @returns a string containng the defines string
  75631. */
  75632. getEffectDefines(): string;
  75633. /**
  75634. * Returns the string "ConeParticleEmitter"
  75635. * @returns a string containing the class name
  75636. */
  75637. getClassName(): string;
  75638. /**
  75639. * Serializes the particle system to a JSON object.
  75640. * @returns the JSON object
  75641. */
  75642. serialize(): any;
  75643. /**
  75644. * Parse properties from a JSON object
  75645. * @param serializationObject defines the JSON object
  75646. */
  75647. parse(serializationObject: any): void;
  75648. }
  75649. }
  75650. declare module BABYLON {
  75651. /**
  75652. * Particle emitter emitting particles from the inside of a cylinder.
  75653. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75654. */
  75655. export class CylinderParticleEmitter implements IParticleEmitterType {
  75656. /**
  75657. * The radius of the emission cylinder.
  75658. */
  75659. radius: number;
  75660. /**
  75661. * The height of the emission cylinder.
  75662. */
  75663. height: number;
  75664. /**
  75665. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75666. */
  75667. radiusRange: number;
  75668. /**
  75669. * How much to randomize the particle direction [0-1].
  75670. */
  75671. directionRandomizer: number;
  75672. /**
  75673. * Creates a new instance CylinderParticleEmitter
  75674. * @param radius the radius of the emission cylinder (1 by default)
  75675. * @param height the height of the emission cylinder (1 by default)
  75676. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75677. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75678. */
  75679. constructor(
  75680. /**
  75681. * The radius of the emission cylinder.
  75682. */
  75683. radius?: number,
  75684. /**
  75685. * The height of the emission cylinder.
  75686. */
  75687. height?: number,
  75688. /**
  75689. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75690. */
  75691. radiusRange?: number,
  75692. /**
  75693. * How much to randomize the particle direction [0-1].
  75694. */
  75695. directionRandomizer?: number);
  75696. /**
  75697. * Called by the particle System when the direction is computed for the created particle.
  75698. * @param worldMatrix is the world matrix of the particle system
  75699. * @param directionToUpdate is the direction vector to update with the result
  75700. * @param particle is the particle we are computed the direction for
  75701. */
  75702. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75703. /**
  75704. * Called by the particle System when the position is computed for the created particle.
  75705. * @param worldMatrix is the world matrix of the particle system
  75706. * @param positionToUpdate is the position vector to update with the result
  75707. * @param particle is the particle we are computed the position for
  75708. */
  75709. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75710. /**
  75711. * Clones the current emitter and returns a copy of it
  75712. * @returns the new emitter
  75713. */
  75714. clone(): CylinderParticleEmitter;
  75715. /**
  75716. * Called by the GPUParticleSystem to setup the update shader
  75717. * @param effect defines the update shader
  75718. */
  75719. applyToShader(effect: Effect): void;
  75720. /**
  75721. * Returns a string to use to update the GPU particles update shader
  75722. * @returns a string containng the defines string
  75723. */
  75724. getEffectDefines(): string;
  75725. /**
  75726. * Returns the string "CylinderParticleEmitter"
  75727. * @returns a string containing the class name
  75728. */
  75729. getClassName(): string;
  75730. /**
  75731. * Serializes the particle system to a JSON object.
  75732. * @returns the JSON object
  75733. */
  75734. serialize(): any;
  75735. /**
  75736. * Parse properties from a JSON object
  75737. * @param serializationObject defines the JSON object
  75738. */
  75739. parse(serializationObject: any): void;
  75740. }
  75741. /**
  75742. * Particle emitter emitting particles from the inside of a cylinder.
  75743. * It emits the particles randomly between two vectors.
  75744. */
  75745. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75746. /**
  75747. * The min limit of the emission direction.
  75748. */
  75749. direction1: Vector3;
  75750. /**
  75751. * The max limit of the emission direction.
  75752. */
  75753. direction2: Vector3;
  75754. /**
  75755. * Creates a new instance CylinderDirectedParticleEmitter
  75756. * @param radius the radius of the emission cylinder (1 by default)
  75757. * @param height the height of the emission cylinder (1 by default)
  75758. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75759. * @param direction1 the min limit of the emission direction (up vector by default)
  75760. * @param direction2 the max limit of the emission direction (up vector by default)
  75761. */
  75762. constructor(radius?: number, height?: number, radiusRange?: number,
  75763. /**
  75764. * The min limit of the emission direction.
  75765. */
  75766. direction1?: Vector3,
  75767. /**
  75768. * The max limit of the emission direction.
  75769. */
  75770. direction2?: Vector3);
  75771. /**
  75772. * Called by the particle System when the direction is computed for the created particle.
  75773. * @param worldMatrix is the world matrix of the particle system
  75774. * @param directionToUpdate is the direction vector to update with the result
  75775. * @param particle is the particle we are computed the direction for
  75776. */
  75777. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75778. /**
  75779. * Clones the current emitter and returns a copy of it
  75780. * @returns the new emitter
  75781. */
  75782. clone(): CylinderDirectedParticleEmitter;
  75783. /**
  75784. * Called by the GPUParticleSystem to setup the update shader
  75785. * @param effect defines the update shader
  75786. */
  75787. applyToShader(effect: Effect): void;
  75788. /**
  75789. * Returns a string to use to update the GPU particles update shader
  75790. * @returns a string containng the defines string
  75791. */
  75792. getEffectDefines(): string;
  75793. /**
  75794. * Returns the string "CylinderDirectedParticleEmitter"
  75795. * @returns a string containing the class name
  75796. */
  75797. getClassName(): string;
  75798. /**
  75799. * Serializes the particle system to a JSON object.
  75800. * @returns the JSON object
  75801. */
  75802. serialize(): any;
  75803. /**
  75804. * Parse properties from a JSON object
  75805. * @param serializationObject defines the JSON object
  75806. */
  75807. parse(serializationObject: any): void;
  75808. }
  75809. }
  75810. declare module BABYLON {
  75811. /**
  75812. * Particle emitter emitting particles from the inside of a hemisphere.
  75813. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75814. */
  75815. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75816. /**
  75817. * The radius of the emission hemisphere.
  75818. */
  75819. radius: number;
  75820. /**
  75821. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75822. */
  75823. radiusRange: number;
  75824. /**
  75825. * How much to randomize the particle direction [0-1].
  75826. */
  75827. directionRandomizer: number;
  75828. /**
  75829. * Creates a new instance HemisphericParticleEmitter
  75830. * @param radius the radius of the emission hemisphere (1 by default)
  75831. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75832. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75833. */
  75834. constructor(
  75835. /**
  75836. * The radius of the emission hemisphere.
  75837. */
  75838. radius?: number,
  75839. /**
  75840. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75841. */
  75842. radiusRange?: number,
  75843. /**
  75844. * How much to randomize the particle direction [0-1].
  75845. */
  75846. directionRandomizer?: number);
  75847. /**
  75848. * Called by the particle System when the direction is computed for the created particle.
  75849. * @param worldMatrix is the world matrix of the particle system
  75850. * @param directionToUpdate is the direction vector to update with the result
  75851. * @param particle is the particle we are computed the direction for
  75852. */
  75853. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75854. /**
  75855. * Called by the particle System when the position is computed for the created particle.
  75856. * @param worldMatrix is the world matrix of the particle system
  75857. * @param positionToUpdate is the position vector to update with the result
  75858. * @param particle is the particle we are computed the position for
  75859. */
  75860. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75861. /**
  75862. * Clones the current emitter and returns a copy of it
  75863. * @returns the new emitter
  75864. */
  75865. clone(): HemisphericParticleEmitter;
  75866. /**
  75867. * Called by the GPUParticleSystem to setup the update shader
  75868. * @param effect defines the update shader
  75869. */
  75870. applyToShader(effect: Effect): void;
  75871. /**
  75872. * Returns a string to use to update the GPU particles update shader
  75873. * @returns a string containng the defines string
  75874. */
  75875. getEffectDefines(): string;
  75876. /**
  75877. * Returns the string "HemisphericParticleEmitter"
  75878. * @returns a string containing the class name
  75879. */
  75880. getClassName(): string;
  75881. /**
  75882. * Serializes the particle system to a JSON object.
  75883. * @returns the JSON object
  75884. */
  75885. serialize(): any;
  75886. /**
  75887. * Parse properties from a JSON object
  75888. * @param serializationObject defines the JSON object
  75889. */
  75890. parse(serializationObject: any): void;
  75891. }
  75892. }
  75893. declare module BABYLON {
  75894. /**
  75895. * Particle emitter emitting particles from a point.
  75896. * It emits the particles randomly between 2 given directions.
  75897. */
  75898. export class PointParticleEmitter implements IParticleEmitterType {
  75899. /**
  75900. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75901. */
  75902. direction1: Vector3;
  75903. /**
  75904. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75905. */
  75906. direction2: Vector3;
  75907. /**
  75908. * Creates a new instance PointParticleEmitter
  75909. */
  75910. constructor();
  75911. /**
  75912. * Called by the particle System when the direction is computed for the created particle.
  75913. * @param worldMatrix is the world matrix of the particle system
  75914. * @param directionToUpdate is the direction vector to update with the result
  75915. * @param particle is the particle we are computed the direction for
  75916. */
  75917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75918. /**
  75919. * Called by the particle System when the position is computed for the created particle.
  75920. * @param worldMatrix is the world matrix of the particle system
  75921. * @param positionToUpdate is the position vector to update with the result
  75922. * @param particle is the particle we are computed the position for
  75923. */
  75924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75925. /**
  75926. * Clones the current emitter and returns a copy of it
  75927. * @returns the new emitter
  75928. */
  75929. clone(): PointParticleEmitter;
  75930. /**
  75931. * Called by the GPUParticleSystem to setup the update shader
  75932. * @param effect defines the update shader
  75933. */
  75934. applyToShader(effect: Effect): void;
  75935. /**
  75936. * Returns a string to use to update the GPU particles update shader
  75937. * @returns a string containng the defines string
  75938. */
  75939. getEffectDefines(): string;
  75940. /**
  75941. * Returns the string "PointParticleEmitter"
  75942. * @returns a string containing the class name
  75943. */
  75944. getClassName(): string;
  75945. /**
  75946. * Serializes the particle system to a JSON object.
  75947. * @returns the JSON object
  75948. */
  75949. serialize(): any;
  75950. /**
  75951. * Parse properties from a JSON object
  75952. * @param serializationObject defines the JSON object
  75953. */
  75954. parse(serializationObject: any): void;
  75955. }
  75956. }
  75957. declare module BABYLON {
  75958. /**
  75959. * Particle emitter emitting particles from the inside of a sphere.
  75960. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75961. */
  75962. export class SphereParticleEmitter implements IParticleEmitterType {
  75963. /**
  75964. * The radius of the emission sphere.
  75965. */
  75966. radius: number;
  75967. /**
  75968. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75969. */
  75970. radiusRange: number;
  75971. /**
  75972. * How much to randomize the particle direction [0-1].
  75973. */
  75974. directionRandomizer: number;
  75975. /**
  75976. * Creates a new instance SphereParticleEmitter
  75977. * @param radius the radius of the emission sphere (1 by default)
  75978. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75979. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75980. */
  75981. constructor(
  75982. /**
  75983. * The radius of the emission sphere.
  75984. */
  75985. radius?: number,
  75986. /**
  75987. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75988. */
  75989. radiusRange?: number,
  75990. /**
  75991. * How much to randomize the particle direction [0-1].
  75992. */
  75993. directionRandomizer?: number);
  75994. /**
  75995. * Called by the particle System when the direction is computed for the created particle.
  75996. * @param worldMatrix is the world matrix of the particle system
  75997. * @param directionToUpdate is the direction vector to update with the result
  75998. * @param particle is the particle we are computed the direction for
  75999. */
  76000. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76001. /**
  76002. * Called by the particle System when the position is computed for the created particle.
  76003. * @param worldMatrix is the world matrix of the particle system
  76004. * @param positionToUpdate is the position vector to update with the result
  76005. * @param particle is the particle we are computed the position for
  76006. */
  76007. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  76008. /**
  76009. * Clones the current emitter and returns a copy of it
  76010. * @returns the new emitter
  76011. */
  76012. clone(): SphereParticleEmitter;
  76013. /**
  76014. * Called by the GPUParticleSystem to setup the update shader
  76015. * @param effect defines the update shader
  76016. */
  76017. applyToShader(effect: Effect): void;
  76018. /**
  76019. * Returns a string to use to update the GPU particles update shader
  76020. * @returns a string containng the defines string
  76021. */
  76022. getEffectDefines(): string;
  76023. /**
  76024. * Returns the string "SphereParticleEmitter"
  76025. * @returns a string containing the class name
  76026. */
  76027. getClassName(): string;
  76028. /**
  76029. * Serializes the particle system to a JSON object.
  76030. * @returns the JSON object
  76031. */
  76032. serialize(): any;
  76033. /**
  76034. * Parse properties from a JSON object
  76035. * @param serializationObject defines the JSON object
  76036. */
  76037. parse(serializationObject: any): void;
  76038. }
  76039. /**
  76040. * Particle emitter emitting particles from the inside of a sphere.
  76041. * It emits the particles randomly between two vectors.
  76042. */
  76043. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76044. /**
  76045. * The min limit of the emission direction.
  76046. */
  76047. direction1: Vector3;
  76048. /**
  76049. * The max limit of the emission direction.
  76050. */
  76051. direction2: Vector3;
  76052. /**
  76053. * Creates a new instance SphereDirectedParticleEmitter
  76054. * @param radius the radius of the emission sphere (1 by default)
  76055. * @param direction1 the min limit of the emission direction (up vector by default)
  76056. * @param direction2 the max limit of the emission direction (up vector by default)
  76057. */
  76058. constructor(radius?: number,
  76059. /**
  76060. * The min limit of the emission direction.
  76061. */
  76062. direction1?: Vector3,
  76063. /**
  76064. * The max limit of the emission direction.
  76065. */
  76066. direction2?: Vector3);
  76067. /**
  76068. * Called by the particle System when the direction is computed for the created particle.
  76069. * @param worldMatrix is the world matrix of the particle system
  76070. * @param directionToUpdate is the direction vector to update with the result
  76071. * @param particle is the particle we are computed the direction for
  76072. */
  76073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76074. /**
  76075. * Clones the current emitter and returns a copy of it
  76076. * @returns the new emitter
  76077. */
  76078. clone(): SphereDirectedParticleEmitter;
  76079. /**
  76080. * Called by the GPUParticleSystem to setup the update shader
  76081. * @param effect defines the update shader
  76082. */
  76083. applyToShader(effect: Effect): void;
  76084. /**
  76085. * Returns a string to use to update the GPU particles update shader
  76086. * @returns a string containng the defines string
  76087. */
  76088. getEffectDefines(): string;
  76089. /**
  76090. * Returns the string "SphereDirectedParticleEmitter"
  76091. * @returns a string containing the class name
  76092. */
  76093. getClassName(): string;
  76094. /**
  76095. * Serializes the particle system to a JSON object.
  76096. * @returns the JSON object
  76097. */
  76098. serialize(): any;
  76099. /**
  76100. * Parse properties from a JSON object
  76101. * @param serializationObject defines the JSON object
  76102. */
  76103. parse(serializationObject: any): void;
  76104. }
  76105. }
  76106. declare module BABYLON {
  76107. /**
  76108. * Interface representing a particle system in Babylon.js.
  76109. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76110. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76111. */
  76112. export interface IParticleSystem {
  76113. /**
  76114. * List of animations used by the particle system.
  76115. */
  76116. animations: Animation[];
  76117. /**
  76118. * The id of the Particle system.
  76119. */
  76120. id: string;
  76121. /**
  76122. * The name of the Particle system.
  76123. */
  76124. name: string;
  76125. /**
  76126. * The emitter represents the Mesh or position we are attaching the particle system to.
  76127. */
  76128. emitter: Nullable<AbstractMesh | Vector3>;
  76129. /**
  76130. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76131. */
  76132. isBillboardBased: boolean;
  76133. /**
  76134. * The rendering group used by the Particle system to chose when to render.
  76135. */
  76136. renderingGroupId: number;
  76137. /**
  76138. * The layer mask we are rendering the particles through.
  76139. */
  76140. layerMask: number;
  76141. /**
  76142. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76143. */
  76144. updateSpeed: number;
  76145. /**
  76146. * The amount of time the particle system is running (depends of the overall update speed).
  76147. */
  76148. targetStopDuration: number;
  76149. /**
  76150. * The texture used to render each particle. (this can be a spritesheet)
  76151. */
  76152. particleTexture: Nullable<Texture>;
  76153. /**
  76154. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76155. */
  76156. blendMode: number;
  76157. /**
  76158. * Minimum life time of emitting particles.
  76159. */
  76160. minLifeTime: number;
  76161. /**
  76162. * Maximum life time of emitting particles.
  76163. */
  76164. maxLifeTime: number;
  76165. /**
  76166. * Minimum Size of emitting particles.
  76167. */
  76168. minSize: number;
  76169. /**
  76170. * Maximum Size of emitting particles.
  76171. */
  76172. maxSize: number;
  76173. /**
  76174. * Minimum scale of emitting particles on X axis.
  76175. */
  76176. minScaleX: number;
  76177. /**
  76178. * Maximum scale of emitting particles on X axis.
  76179. */
  76180. maxScaleX: number;
  76181. /**
  76182. * Minimum scale of emitting particles on Y axis.
  76183. */
  76184. minScaleY: number;
  76185. /**
  76186. * Maximum scale of emitting particles on Y axis.
  76187. */
  76188. maxScaleY: number;
  76189. /**
  76190. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76191. */
  76192. color1: Color4;
  76193. /**
  76194. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76195. */
  76196. color2: Color4;
  76197. /**
  76198. * Color the particle will have at the end of its lifetime.
  76199. */
  76200. colorDead: Color4;
  76201. /**
  76202. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76203. */
  76204. emitRate: number;
  76205. /**
  76206. * You can use gravity if you want to give an orientation to your particles.
  76207. */
  76208. gravity: Vector3;
  76209. /**
  76210. * Minimum power of emitting particles.
  76211. */
  76212. minEmitPower: number;
  76213. /**
  76214. * Maximum power of emitting particles.
  76215. */
  76216. maxEmitPower: number;
  76217. /**
  76218. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76219. */
  76220. minAngularSpeed: number;
  76221. /**
  76222. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76223. */
  76224. maxAngularSpeed: number;
  76225. /**
  76226. * Gets or sets the minimal initial rotation in radians.
  76227. */
  76228. minInitialRotation: number;
  76229. /**
  76230. * Gets or sets the maximal initial rotation in radians.
  76231. */
  76232. maxInitialRotation: number;
  76233. /**
  76234. * The particle emitter type defines the emitter used by the particle system.
  76235. * It can be for example box, sphere, or cone...
  76236. */
  76237. particleEmitterType: Nullable<IParticleEmitterType>;
  76238. /**
  76239. * Defines the delay in milliseconds before starting the system (0 by default)
  76240. */
  76241. startDelay: number;
  76242. /**
  76243. * 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
  76244. */
  76245. preWarmCycles: number;
  76246. /**
  76247. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76248. */
  76249. preWarmStepOffset: number;
  76250. /**
  76251. * 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)
  76252. */
  76253. spriteCellChangeSpeed: number;
  76254. /**
  76255. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76256. */
  76257. startSpriteCellID: number;
  76258. /**
  76259. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76260. */
  76261. endSpriteCellID: number;
  76262. /**
  76263. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76264. */
  76265. spriteCellWidth: number;
  76266. /**
  76267. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76268. */
  76269. spriteCellHeight: number;
  76270. /**
  76271. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76272. */
  76273. spriteRandomStartCell: boolean;
  76274. /**
  76275. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76276. */
  76277. isAnimationSheetEnabled: boolean;
  76278. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76279. translationPivot: Vector2;
  76280. /**
  76281. * Gets or sets a texture used to add random noise to particle positions
  76282. */
  76283. noiseTexture: Nullable<BaseTexture>;
  76284. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76285. noiseStrength: Vector3;
  76286. /**
  76287. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76288. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76289. */
  76290. billboardMode: number;
  76291. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76292. limitVelocityDamping: number;
  76293. /**
  76294. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76295. */
  76296. beginAnimationOnStart: boolean;
  76297. /**
  76298. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76299. */
  76300. beginAnimationFrom: number;
  76301. /**
  76302. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76303. */
  76304. beginAnimationTo: number;
  76305. /**
  76306. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76307. */
  76308. beginAnimationLoop: boolean;
  76309. /**
  76310. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76311. */
  76312. disposeOnStop: boolean;
  76313. /**
  76314. * Gets the maximum number of particles active at the same time.
  76315. * @returns The max number of active particles.
  76316. */
  76317. getCapacity(): number;
  76318. /**
  76319. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76320. * @returns True if it has been started, otherwise false.
  76321. */
  76322. isStarted(): boolean;
  76323. /**
  76324. * Animates the particle system for this frame.
  76325. */
  76326. animate(): void;
  76327. /**
  76328. * Renders the particle system in its current state.
  76329. * @returns the current number of particles
  76330. */
  76331. render(): number;
  76332. /**
  76333. * Dispose the particle system and frees its associated resources.
  76334. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76335. */
  76336. dispose(disposeTexture?: boolean): void;
  76337. /**
  76338. * Clones the particle system.
  76339. * @param name The name of the cloned object
  76340. * @param newEmitter The new emitter to use
  76341. * @returns the cloned particle system
  76342. */
  76343. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76344. /**
  76345. * Serializes the particle system to a JSON object.
  76346. * @returns the JSON object
  76347. */
  76348. serialize(): any;
  76349. /**
  76350. * Rebuild the particle system
  76351. */
  76352. rebuild(): void;
  76353. /**
  76354. * Starts the particle system and begins to emit
  76355. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76356. */
  76357. start(delay?: number): void;
  76358. /**
  76359. * Stops the particle system.
  76360. */
  76361. stop(): void;
  76362. /**
  76363. * Remove all active particles
  76364. */
  76365. reset(): void;
  76366. /**
  76367. * Is this system ready to be used/rendered
  76368. * @return true if the system is ready
  76369. */
  76370. isReady(): boolean;
  76371. /**
  76372. * Adds a new color gradient
  76373. * @param gradient defines the gradient to use (between 0 and 1)
  76374. * @param color1 defines the color to affect to the specified gradient
  76375. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76376. * @returns the current particle system
  76377. */
  76378. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76379. /**
  76380. * Remove a specific color gradient
  76381. * @param gradient defines the gradient to remove
  76382. * @returns the current particle system
  76383. */
  76384. removeColorGradient(gradient: number): IParticleSystem;
  76385. /**
  76386. * Adds a new size gradient
  76387. * @param gradient defines the gradient to use (between 0 and 1)
  76388. * @param factor defines the size factor to affect to the specified gradient
  76389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76390. * @returns the current particle system
  76391. */
  76392. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76393. /**
  76394. * Remove a specific size gradient
  76395. * @param gradient defines the gradient to remove
  76396. * @returns the current particle system
  76397. */
  76398. removeSizeGradient(gradient: number): IParticleSystem;
  76399. /**
  76400. * Gets the current list of color gradients.
  76401. * You must use addColorGradient and removeColorGradient to udpate this list
  76402. * @returns the list of color gradients
  76403. */
  76404. getColorGradients(): Nullable<Array<ColorGradient>>;
  76405. /**
  76406. * Gets the current list of size gradients.
  76407. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76408. * @returns the list of size gradients
  76409. */
  76410. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76411. /**
  76412. * Gets the current list of angular speed gradients.
  76413. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76414. * @returns the list of angular speed gradients
  76415. */
  76416. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76417. /**
  76418. * Adds a new angular speed gradient
  76419. * @param gradient defines the gradient to use (between 0 and 1)
  76420. * @param factor defines the angular speed to affect to the specified gradient
  76421. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76422. * @returns the current particle system
  76423. */
  76424. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76425. /**
  76426. * Remove a specific angular speed gradient
  76427. * @param gradient defines the gradient to remove
  76428. * @returns the current particle system
  76429. */
  76430. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76431. /**
  76432. * Gets the current list of velocity gradients.
  76433. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76434. * @returns the list of velocity gradients
  76435. */
  76436. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76437. /**
  76438. * Adds a new velocity gradient
  76439. * @param gradient defines the gradient to use (between 0 and 1)
  76440. * @param factor defines the velocity to affect to the specified gradient
  76441. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76442. * @returns the current particle system
  76443. */
  76444. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76445. /**
  76446. * Remove a specific velocity gradient
  76447. * @param gradient defines the gradient to remove
  76448. * @returns the current particle system
  76449. */
  76450. removeVelocityGradient(gradient: number): IParticleSystem;
  76451. /**
  76452. * Gets the current list of limit velocity gradients.
  76453. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76454. * @returns the list of limit velocity gradients
  76455. */
  76456. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76457. /**
  76458. * Adds a new limit velocity gradient
  76459. * @param gradient defines the gradient to use (between 0 and 1)
  76460. * @param factor defines the limit velocity to affect to the specified gradient
  76461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76462. * @returns the current particle system
  76463. */
  76464. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76465. /**
  76466. * Remove a specific limit velocity gradient
  76467. * @param gradient defines the gradient to remove
  76468. * @returns the current particle system
  76469. */
  76470. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76471. /**
  76472. * Adds a new drag gradient
  76473. * @param gradient defines the gradient to use (between 0 and 1)
  76474. * @param factor defines the drag to affect to the specified gradient
  76475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76476. * @returns the current particle system
  76477. */
  76478. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76479. /**
  76480. * Remove a specific drag gradient
  76481. * @param gradient defines the gradient to remove
  76482. * @returns the current particle system
  76483. */
  76484. removeDragGradient(gradient: number): IParticleSystem;
  76485. /**
  76486. * Gets the current list of drag gradients.
  76487. * You must use addDragGradient and removeDragGradient to udpate this list
  76488. * @returns the list of drag gradients
  76489. */
  76490. getDragGradients(): Nullable<Array<FactorGradient>>;
  76491. /**
  76492. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76493. * @param gradient defines the gradient to use (between 0 and 1)
  76494. * @param factor defines the emit rate to affect to the specified gradient
  76495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76496. * @returns the current particle system
  76497. */
  76498. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76499. /**
  76500. * Remove a specific emit rate gradient
  76501. * @param gradient defines the gradient to remove
  76502. * @returns the current particle system
  76503. */
  76504. removeEmitRateGradient(gradient: number): IParticleSystem;
  76505. /**
  76506. * Gets the current list of emit rate gradients.
  76507. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76508. * @returns the list of emit rate gradients
  76509. */
  76510. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76511. /**
  76512. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76513. * @param gradient defines the gradient to use (between 0 and 1)
  76514. * @param factor defines the start size to affect to the specified gradient
  76515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76516. * @returns the current particle system
  76517. */
  76518. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76519. /**
  76520. * Remove a specific start size gradient
  76521. * @param gradient defines the gradient to remove
  76522. * @returns the current particle system
  76523. */
  76524. removeStartSizeGradient(gradient: number): IParticleSystem;
  76525. /**
  76526. * Gets the current list of start size gradients.
  76527. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76528. * @returns the list of start size gradients
  76529. */
  76530. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76531. /**
  76532. * Adds a new life time gradient
  76533. * @param gradient defines the gradient to use (between 0 and 1)
  76534. * @param factor defines the life time factor to affect to the specified gradient
  76535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76536. * @returns the current particle system
  76537. */
  76538. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76539. /**
  76540. * Remove a specific life time gradient
  76541. * @param gradient defines the gradient to remove
  76542. * @returns the current particle system
  76543. */
  76544. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76545. /**
  76546. * Gets the current list of life time gradients.
  76547. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76548. * @returns the list of life time gradients
  76549. */
  76550. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76551. /**
  76552. * Gets the current list of color gradients.
  76553. * You must use addColorGradient and removeColorGradient to udpate this list
  76554. * @returns the list of color gradients
  76555. */
  76556. getColorGradients(): Nullable<Array<ColorGradient>>;
  76557. /**
  76558. * Adds a new ramp gradient used to remap particle colors
  76559. * @param gradient defines the gradient to use (between 0 and 1)
  76560. * @param color defines the color to affect to the specified gradient
  76561. * @returns the current particle system
  76562. */
  76563. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76564. /**
  76565. * Gets the current list of ramp gradients.
  76566. * You must use addRampGradient and removeRampGradient to udpate this list
  76567. * @returns the list of ramp gradients
  76568. */
  76569. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76570. /** Gets or sets a boolean indicating that ramp gradients must be used
  76571. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76572. */
  76573. useRampGradients: boolean;
  76574. /**
  76575. * Adds a new color remap gradient
  76576. * @param gradient defines the gradient to use (between 0 and 1)
  76577. * @param min defines the color remap minimal range
  76578. * @param max defines the color remap maximal range
  76579. * @returns the current particle system
  76580. */
  76581. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76582. /**
  76583. * Gets the current list of color remap gradients.
  76584. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76585. * @returns the list of color remap gradients
  76586. */
  76587. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76588. /**
  76589. * Adds a new alpha remap gradient
  76590. * @param gradient defines the gradient to use (between 0 and 1)
  76591. * @param min defines the alpha remap minimal range
  76592. * @param max defines the alpha remap maximal range
  76593. * @returns the current particle system
  76594. */
  76595. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76596. /**
  76597. * Gets the current list of alpha remap gradients.
  76598. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76599. * @returns the list of alpha remap gradients
  76600. */
  76601. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76602. /**
  76603. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76604. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76605. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76606. * @returns the emitter
  76607. */
  76608. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76609. /**
  76610. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76611. * @param radius The radius of the hemisphere to emit from
  76612. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76613. * @returns the emitter
  76614. */
  76615. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76616. /**
  76617. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76618. * @param radius The radius of the sphere to emit from
  76619. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76620. * @returns the emitter
  76621. */
  76622. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76623. /**
  76624. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76625. * @param radius The radius of the sphere to emit from
  76626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76628. * @returns the emitter
  76629. */
  76630. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76631. /**
  76632. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76633. * @param radius The radius of the emission cylinder
  76634. * @param height The height of the emission cylinder
  76635. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76636. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76637. * @returns the emitter
  76638. */
  76639. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76640. /**
  76641. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76642. * @param radius The radius of the cylinder to emit from
  76643. * @param height The height of the emission cylinder
  76644. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76645. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76646. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76647. * @returns the emitter
  76648. */
  76649. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76650. /**
  76651. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76652. * @param radius The radius of the cone to emit from
  76653. * @param angle The base angle of the cone
  76654. * @returns the emitter
  76655. */
  76656. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76657. /**
  76658. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76659. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76660. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76661. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76662. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76663. * @returns the emitter
  76664. */
  76665. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76666. /**
  76667. * Get hosting scene
  76668. * @returns the scene
  76669. */
  76670. getScene(): Scene;
  76671. }
  76672. }
  76673. declare module BABYLON {
  76674. /**
  76675. * Creates an instance based on a source mesh.
  76676. */
  76677. export class InstancedMesh extends AbstractMesh {
  76678. private _sourceMesh;
  76679. private _currentLOD;
  76680. /** @hidden */
  76681. _indexInSourceMeshInstanceArray: number;
  76682. constructor(name: string, source: Mesh);
  76683. /**
  76684. * Returns the string "InstancedMesh".
  76685. */
  76686. getClassName(): string;
  76687. /** Gets the list of lights affecting that mesh */
  76688. readonly lightSources: Light[];
  76689. _resyncLightSources(): void;
  76690. _resyncLighSource(light: Light): void;
  76691. _removeLightSource(light: Light): void;
  76692. /**
  76693. * If the source mesh receives shadows
  76694. */
  76695. readonly receiveShadows: boolean;
  76696. /**
  76697. * The material of the source mesh
  76698. */
  76699. readonly material: Nullable<Material>;
  76700. /**
  76701. * Visibility of the source mesh
  76702. */
  76703. readonly visibility: number;
  76704. /**
  76705. * Skeleton of the source mesh
  76706. */
  76707. readonly skeleton: Nullable<Skeleton>;
  76708. /**
  76709. * Rendering ground id of the source mesh
  76710. */
  76711. renderingGroupId: number;
  76712. /**
  76713. * Returns the total number of vertices (integer).
  76714. */
  76715. getTotalVertices(): number;
  76716. /**
  76717. * Returns a positive integer : the total number of indices in this mesh geometry.
  76718. * @returns the numner of indices or zero if the mesh has no geometry.
  76719. */
  76720. getTotalIndices(): number;
  76721. /**
  76722. * The source mesh of the instance
  76723. */
  76724. readonly sourceMesh: Mesh;
  76725. /**
  76726. * Is this node ready to be used/rendered
  76727. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76728. * @return {boolean} is it ready
  76729. */
  76730. isReady(completeCheck?: boolean): boolean;
  76731. /**
  76732. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76733. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76734. * @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.
  76735. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76736. */
  76737. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76738. /**
  76739. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76740. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76741. * The `data` are either a numeric array either a Float32Array.
  76742. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76743. * 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).
  76744. * Note that a new underlying VertexBuffer object is created each call.
  76745. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76746. *
  76747. * Possible `kind` values :
  76748. * - VertexBuffer.PositionKind
  76749. * - VertexBuffer.UVKind
  76750. * - VertexBuffer.UV2Kind
  76751. * - VertexBuffer.UV3Kind
  76752. * - VertexBuffer.UV4Kind
  76753. * - VertexBuffer.UV5Kind
  76754. * - VertexBuffer.UV6Kind
  76755. * - VertexBuffer.ColorKind
  76756. * - VertexBuffer.MatricesIndicesKind
  76757. * - VertexBuffer.MatricesIndicesExtraKind
  76758. * - VertexBuffer.MatricesWeightsKind
  76759. * - VertexBuffer.MatricesWeightsExtraKind
  76760. *
  76761. * Returns the Mesh.
  76762. */
  76763. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76764. /**
  76765. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76766. * If the mesh has no geometry, it is simply returned as it is.
  76767. * The `data` are either a numeric array either a Float32Array.
  76768. * No new underlying VertexBuffer object is created.
  76769. * 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.
  76770. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76771. *
  76772. * Possible `kind` values :
  76773. * - VertexBuffer.PositionKind
  76774. * - VertexBuffer.UVKind
  76775. * - VertexBuffer.UV2Kind
  76776. * - VertexBuffer.UV3Kind
  76777. * - VertexBuffer.UV4Kind
  76778. * - VertexBuffer.UV5Kind
  76779. * - VertexBuffer.UV6Kind
  76780. * - VertexBuffer.ColorKind
  76781. * - VertexBuffer.MatricesIndicesKind
  76782. * - VertexBuffer.MatricesIndicesExtraKind
  76783. * - VertexBuffer.MatricesWeightsKind
  76784. * - VertexBuffer.MatricesWeightsExtraKind
  76785. *
  76786. * Returns the Mesh.
  76787. */
  76788. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76789. /**
  76790. * Sets the mesh indices.
  76791. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76792. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76793. * This method creates a new index buffer each call.
  76794. * Returns the Mesh.
  76795. */
  76796. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76797. /**
  76798. * Boolean : True if the mesh owns the requested kind of data.
  76799. */
  76800. isVerticesDataPresent(kind: string): boolean;
  76801. /**
  76802. * Returns an array of indices (IndicesArray).
  76803. */
  76804. getIndices(): Nullable<IndicesArray>;
  76805. readonly _positions: Nullable<Vector3[]>;
  76806. /**
  76807. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76808. * This means the mesh underlying bounding box and sphere are recomputed.
  76809. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76810. * @returns the current mesh
  76811. */
  76812. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76813. /** @hidden */
  76814. _preActivate(): InstancedMesh;
  76815. /** @hidden */
  76816. _activate(renderId: number): boolean;
  76817. /** @hidden */
  76818. _postActivate(): void;
  76819. getWorldMatrix(): Matrix;
  76820. readonly isAnInstance: boolean;
  76821. /**
  76822. * Returns the current associated LOD AbstractMesh.
  76823. */
  76824. getLOD(camera: Camera): AbstractMesh;
  76825. /** @hidden */
  76826. _syncSubMeshes(): InstancedMesh;
  76827. /** @hidden */
  76828. _generatePointsArray(): boolean;
  76829. /**
  76830. * Creates a new InstancedMesh from the current mesh.
  76831. * - name (string) : the cloned mesh name
  76832. * - newParent (optional Node) : the optional Node to parent the clone to.
  76833. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76834. *
  76835. * Returns the clone.
  76836. */
  76837. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76838. /**
  76839. * Disposes the InstancedMesh.
  76840. * Returns nothing.
  76841. */
  76842. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76843. }
  76844. }
  76845. declare module BABYLON {
  76846. /**
  76847. * Defines the options associated with the creation of a shader material.
  76848. */
  76849. export interface IShaderMaterialOptions {
  76850. /**
  76851. * Does the material work in alpha blend mode
  76852. */
  76853. needAlphaBlending: boolean;
  76854. /**
  76855. * Does the material work in alpha test mode
  76856. */
  76857. needAlphaTesting: boolean;
  76858. /**
  76859. * The list of attribute names used in the shader
  76860. */
  76861. attributes: string[];
  76862. /**
  76863. * The list of unifrom names used in the shader
  76864. */
  76865. uniforms: string[];
  76866. /**
  76867. * The list of UBO names used in the shader
  76868. */
  76869. uniformBuffers: string[];
  76870. /**
  76871. * The list of sampler names used in the shader
  76872. */
  76873. samplers: string[];
  76874. /**
  76875. * The list of defines used in the shader
  76876. */
  76877. defines: string[];
  76878. }
  76879. /**
  76880. * 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.
  76881. *
  76882. * This returned material effects how the mesh will look based on the code in the shaders.
  76883. *
  76884. * @see http://doc.babylonjs.com/how_to/shader_material
  76885. */
  76886. export class ShaderMaterial extends Material {
  76887. private _shaderPath;
  76888. private _options;
  76889. private _textures;
  76890. private _textureArrays;
  76891. private _floats;
  76892. private _ints;
  76893. private _floatsArrays;
  76894. private _colors3;
  76895. private _colors3Arrays;
  76896. private _colors4;
  76897. private _vectors2;
  76898. private _vectors3;
  76899. private _vectors4;
  76900. private _matrices;
  76901. private _matrices3x3;
  76902. private _matrices2x2;
  76903. private _vectors2Arrays;
  76904. private _vectors3Arrays;
  76905. private _cachedWorldViewMatrix;
  76906. private _renderId;
  76907. /**
  76908. * Instantiate a new shader material.
  76909. * 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.
  76910. * This returned material effects how the mesh will look based on the code in the shaders.
  76911. * @see http://doc.babylonjs.com/how_to/shader_material
  76912. * @param name Define the name of the material in the scene
  76913. * @param scene Define the scene the material belongs to
  76914. * @param shaderPath Defines the route to the shader code in one of three ways:
  76915. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76916. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76917. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76918. * @param options Define the options used to create the shader
  76919. */
  76920. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76921. /**
  76922. * Gets the options used to compile the shader.
  76923. * They can be modified to trigger a new compilation
  76924. */
  76925. readonly options: IShaderMaterialOptions;
  76926. /**
  76927. * Gets the current class name of the material e.g. "ShaderMaterial"
  76928. * Mainly use in serialization.
  76929. * @returns the class name
  76930. */
  76931. getClassName(): string;
  76932. /**
  76933. * Specifies if the material will require alpha blending
  76934. * @returns a boolean specifying if alpha blending is needed
  76935. */
  76936. needAlphaBlending(): boolean;
  76937. /**
  76938. * Specifies if this material should be rendered in alpha test mode
  76939. * @returns a boolean specifying if an alpha test is needed.
  76940. */
  76941. needAlphaTesting(): boolean;
  76942. private _checkUniform;
  76943. /**
  76944. * Set a texture in the shader.
  76945. * @param name Define the name of the uniform samplers as defined in the shader
  76946. * @param texture Define the texture to bind to this sampler
  76947. * @return the material itself allowing "fluent" like uniform updates
  76948. */
  76949. setTexture(name: string, texture: Texture): ShaderMaterial;
  76950. /**
  76951. * Set a texture array in the shader.
  76952. * @param name Define the name of the uniform sampler array as defined in the shader
  76953. * @param textures Define the list of textures to bind to this sampler
  76954. * @return the material itself allowing "fluent" like uniform updates
  76955. */
  76956. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76957. /**
  76958. * Set a float in the shader.
  76959. * @param name Define the name of the uniform as defined in the shader
  76960. * @param value Define the value to give to the uniform
  76961. * @return the material itself allowing "fluent" like uniform updates
  76962. */
  76963. setFloat(name: string, value: number): ShaderMaterial;
  76964. /**
  76965. * Set a int in the shader.
  76966. * @param name Define the name of the uniform as defined in the shader
  76967. * @param value Define the value to give to the uniform
  76968. * @return the material itself allowing "fluent" like uniform updates
  76969. */
  76970. setInt(name: string, value: number): ShaderMaterial;
  76971. /**
  76972. * Set an array of floats in the shader.
  76973. * @param name Define the name of the uniform as defined in the shader
  76974. * @param value Define the value to give to the uniform
  76975. * @return the material itself allowing "fluent" like uniform updates
  76976. */
  76977. setFloats(name: string, value: number[]): ShaderMaterial;
  76978. /**
  76979. * Set a vec3 in the shader from a Color3.
  76980. * @param name Define the name of the uniform as defined in the shader
  76981. * @param value Define the value to give to the uniform
  76982. * @return the material itself allowing "fluent" like uniform updates
  76983. */
  76984. setColor3(name: string, value: Color3): ShaderMaterial;
  76985. /**
  76986. * Set a vec3 array in the shader from a Color3 array.
  76987. * @param name Define the name of the uniform as defined in the shader
  76988. * @param value Define the value to give to the uniform
  76989. * @return the material itself allowing "fluent" like uniform updates
  76990. */
  76991. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76992. /**
  76993. * Set a vec4 in the shader from a Color4.
  76994. * @param name Define the name of the uniform as defined in the shader
  76995. * @param value Define the value to give to the uniform
  76996. * @return the material itself allowing "fluent" like uniform updates
  76997. */
  76998. setColor4(name: string, value: Color4): ShaderMaterial;
  76999. /**
  77000. * Set a vec2 in the shader from a Vector2.
  77001. * @param name Define the name of the uniform as defined in the shader
  77002. * @param value Define the value to give to the uniform
  77003. * @return the material itself allowing "fluent" like uniform updates
  77004. */
  77005. setVector2(name: string, value: Vector2): ShaderMaterial;
  77006. /**
  77007. * Set a vec3 in the shader from a Vector3.
  77008. * @param name Define the name of the uniform as defined in the shader
  77009. * @param value Define the value to give to the uniform
  77010. * @return the material itself allowing "fluent" like uniform updates
  77011. */
  77012. setVector3(name: string, value: Vector3): ShaderMaterial;
  77013. /**
  77014. * Set a vec4 in the shader from a Vector4.
  77015. * @param name Define the name of the uniform as defined in the shader
  77016. * @param value Define the value to give to the uniform
  77017. * @return the material itself allowing "fluent" like uniform updates
  77018. */
  77019. setVector4(name: string, value: Vector4): ShaderMaterial;
  77020. /**
  77021. * Set a mat4 in the shader from a Matrix.
  77022. * @param name Define the name of the uniform as defined in the shader
  77023. * @param value Define the value to give to the uniform
  77024. * @return the material itself allowing "fluent" like uniform updates
  77025. */
  77026. setMatrix(name: string, value: Matrix): ShaderMaterial;
  77027. /**
  77028. * Set a mat3 in the shader from a Float32Array.
  77029. * @param name Define the name of the uniform as defined in the shader
  77030. * @param value Define the value to give to the uniform
  77031. * @return the material itself allowing "fluent" like uniform updates
  77032. */
  77033. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  77034. /**
  77035. * Set a mat2 in the shader from a Float32Array.
  77036. * @param name Define the name of the uniform as defined in the shader
  77037. * @param value Define the value to give to the uniform
  77038. * @return the material itself allowing "fluent" like uniform updates
  77039. */
  77040. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77041. /**
  77042. * Set a vec2 array in the shader from a number array.
  77043. * @param name Define the name of the uniform as defined in the shader
  77044. * @param value Define the value to give to the uniform
  77045. * @return the material itself allowing "fluent" like uniform updates
  77046. */
  77047. setArray2(name: string, value: number[]): ShaderMaterial;
  77048. /**
  77049. * Set a vec3 array in the shader from a number array.
  77050. * @param name Define the name of the uniform as defined in the shader
  77051. * @param value Define the value to give to the uniform
  77052. * @return the material itself allowing "fluent" like uniform updates
  77053. */
  77054. setArray3(name: string, value: number[]): ShaderMaterial;
  77055. private _checkCache;
  77056. /**
  77057. * Specifies that the submesh is ready to be used
  77058. * @param mesh defines the mesh to check
  77059. * @param subMesh defines which submesh to check
  77060. * @param useInstances specifies that instances should be used
  77061. * @returns a boolean indicating that the submesh is ready or not
  77062. */
  77063. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77064. /**
  77065. * Checks if the material is ready to render the requested mesh
  77066. * @param mesh Define the mesh to render
  77067. * @param useInstances Define whether or not the material is used with instances
  77068. * @returns true if ready, otherwise false
  77069. */
  77070. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77071. /**
  77072. * Binds the world matrix to the material
  77073. * @param world defines the world transformation matrix
  77074. */
  77075. bindOnlyWorldMatrix(world: Matrix): void;
  77076. /**
  77077. * Binds the material to the mesh
  77078. * @param world defines the world transformation matrix
  77079. * @param mesh defines the mesh to bind the material to
  77080. */
  77081. bind(world: Matrix, mesh?: Mesh): void;
  77082. /**
  77083. * Gets the active textures from the material
  77084. * @returns an array of textures
  77085. */
  77086. getActiveTextures(): BaseTexture[];
  77087. /**
  77088. * Specifies if the material uses a texture
  77089. * @param texture defines the texture to check against the material
  77090. * @returns a boolean specifying if the material uses the texture
  77091. */
  77092. hasTexture(texture: BaseTexture): boolean;
  77093. /**
  77094. * Makes a duplicate of the material, and gives it a new name
  77095. * @param name defines the new name for the duplicated material
  77096. * @returns the cloned material
  77097. */
  77098. clone(name: string): ShaderMaterial;
  77099. /**
  77100. * Disposes the material
  77101. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77102. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77103. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77104. */
  77105. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77106. /**
  77107. * Serializes this material in a JSON representation
  77108. * @returns the serialized material object
  77109. */
  77110. serialize(): any;
  77111. /**
  77112. * Creates a shader material from parsed shader material data
  77113. * @param source defines the JSON represnetation of the material
  77114. * @param scene defines the hosting scene
  77115. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77116. * @returns a new material
  77117. */
  77118. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77119. }
  77120. }
  77121. declare module BABYLON {
  77122. /** @hidden */
  77123. export var colorPixelShader: {
  77124. name: string;
  77125. shader: string;
  77126. };
  77127. }
  77128. declare module BABYLON {
  77129. /** @hidden */
  77130. export var colorVertexShader: {
  77131. name: string;
  77132. shader: string;
  77133. };
  77134. }
  77135. declare module BABYLON {
  77136. /**
  77137. * Line mesh
  77138. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77139. */
  77140. export class LinesMesh extends Mesh {
  77141. /**
  77142. * If vertex color should be applied to the mesh
  77143. */
  77144. useVertexColor?: boolean | undefined;
  77145. /**
  77146. * If vertex alpha should be applied to the mesh
  77147. */
  77148. useVertexAlpha?: boolean | undefined;
  77149. /**
  77150. * Color of the line (Default: White)
  77151. */
  77152. color: Color3;
  77153. /**
  77154. * Alpha of the line (Default: 1)
  77155. */
  77156. alpha: number;
  77157. /**
  77158. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77159. * This margin is expressed in world space coordinates, so its value may vary.
  77160. * Default value is 0.1
  77161. */
  77162. intersectionThreshold: number;
  77163. private _colorShader;
  77164. /**
  77165. * Creates a new LinesMesh
  77166. * @param name defines the name
  77167. * @param scene defines the hosting scene
  77168. * @param parent defines the parent mesh if any
  77169. * @param source defines the optional source LinesMesh used to clone data from
  77170. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77171. * When false, achieved by calling a clone(), also passing False.
  77172. * This will make creation of children, recursive.
  77173. * @param useVertexColor defines if this LinesMesh supports vertex color
  77174. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77175. */
  77176. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77177. /**
  77178. * If vertex color should be applied to the mesh
  77179. */
  77180. useVertexColor?: boolean | undefined,
  77181. /**
  77182. * If vertex alpha should be applied to the mesh
  77183. */
  77184. useVertexAlpha?: boolean | undefined);
  77185. private _addClipPlaneDefine;
  77186. private _removeClipPlaneDefine;
  77187. isReady(): boolean;
  77188. /**
  77189. * Returns the string "LineMesh"
  77190. */
  77191. getClassName(): string;
  77192. /**
  77193. * @hidden
  77194. */
  77195. /**
  77196. * @hidden
  77197. */
  77198. material: Material;
  77199. /**
  77200. * @hidden
  77201. */
  77202. readonly checkCollisions: boolean;
  77203. /** @hidden */
  77204. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77205. /** @hidden */
  77206. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77207. /**
  77208. * Disposes of the line mesh
  77209. * @param doNotRecurse If children should be disposed
  77210. */
  77211. dispose(doNotRecurse?: boolean): void;
  77212. /**
  77213. * Returns a new LineMesh object cloned from the current one.
  77214. */
  77215. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77216. /**
  77217. * Creates a new InstancedLinesMesh object from the mesh model.
  77218. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77219. * @param name defines the name of the new instance
  77220. * @returns a new InstancedLinesMesh
  77221. */
  77222. createInstance(name: string): InstancedLinesMesh;
  77223. }
  77224. /**
  77225. * Creates an instance based on a source LinesMesh
  77226. */
  77227. export class InstancedLinesMesh extends InstancedMesh {
  77228. /**
  77229. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77230. * This margin is expressed in world space coordinates, so its value may vary.
  77231. * Initilized with the intersectionThreshold value of the source LinesMesh
  77232. */
  77233. intersectionThreshold: number;
  77234. constructor(name: string, source: LinesMesh);
  77235. /**
  77236. * Returns the string "InstancedLinesMesh".
  77237. */
  77238. getClassName(): string;
  77239. }
  77240. }
  77241. declare module BABYLON {
  77242. /** @hidden */
  77243. export var linePixelShader: {
  77244. name: string;
  77245. shader: string;
  77246. };
  77247. }
  77248. declare module BABYLON {
  77249. /** @hidden */
  77250. export var lineVertexShader: {
  77251. name: string;
  77252. shader: string;
  77253. };
  77254. }
  77255. declare module BABYLON {
  77256. interface AbstractMesh {
  77257. /**
  77258. * Disables the mesh edge rendering mode
  77259. * @returns the currentAbstractMesh
  77260. */
  77261. disableEdgesRendering(): AbstractMesh;
  77262. /**
  77263. * Enables the edge rendering mode on the mesh.
  77264. * This mode makes the mesh edges visible
  77265. * @param epsilon defines the maximal distance between two angles to detect a face
  77266. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77267. * @returns the currentAbstractMesh
  77268. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77269. */
  77270. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77271. /**
  77272. * Gets the edgesRenderer associated with the mesh
  77273. */
  77274. edgesRenderer: Nullable<EdgesRenderer>;
  77275. }
  77276. interface LinesMesh {
  77277. /**
  77278. * Enables the edge rendering mode on the mesh.
  77279. * This mode makes the mesh edges visible
  77280. * @param epsilon defines the maximal distance between two angles to detect a face
  77281. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77282. * @returns the currentAbstractMesh
  77283. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77284. */
  77285. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77286. }
  77287. interface InstancedLinesMesh {
  77288. /**
  77289. * Enables the edge rendering mode on the mesh.
  77290. * This mode makes the mesh edges visible
  77291. * @param epsilon defines the maximal distance between two angles to detect a face
  77292. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77293. * @returns the current InstancedLinesMesh
  77294. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77295. */
  77296. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77297. }
  77298. /**
  77299. * Defines the minimum contract an Edges renderer should follow.
  77300. */
  77301. export interface IEdgesRenderer extends IDisposable {
  77302. /**
  77303. * Gets or sets a boolean indicating if the edgesRenderer is active
  77304. */
  77305. isEnabled: boolean;
  77306. /**
  77307. * Renders the edges of the attached mesh,
  77308. */
  77309. render(): void;
  77310. /**
  77311. * Checks wether or not the edges renderer is ready to render.
  77312. * @return true if ready, otherwise false.
  77313. */
  77314. isReady(): boolean;
  77315. }
  77316. /**
  77317. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77318. */
  77319. export class EdgesRenderer implements IEdgesRenderer {
  77320. /**
  77321. * Define the size of the edges with an orthographic camera
  77322. */
  77323. edgesWidthScalerForOrthographic: number;
  77324. /**
  77325. * Define the size of the edges with a perspective camera
  77326. */
  77327. edgesWidthScalerForPerspective: number;
  77328. protected _source: AbstractMesh;
  77329. protected _linesPositions: number[];
  77330. protected _linesNormals: number[];
  77331. protected _linesIndices: number[];
  77332. protected _epsilon: number;
  77333. protected _indicesCount: number;
  77334. protected _lineShader: ShaderMaterial;
  77335. protected _ib: DataBuffer;
  77336. protected _buffers: {
  77337. [key: string]: Nullable<VertexBuffer>;
  77338. };
  77339. protected _checkVerticesInsteadOfIndices: boolean;
  77340. private _meshRebuildObserver;
  77341. private _meshDisposeObserver;
  77342. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77343. isEnabled: boolean;
  77344. /**
  77345. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77346. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77347. * @param source Mesh used to create edges
  77348. * @param epsilon sum of angles in adjacency to check for edge
  77349. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77350. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77351. */
  77352. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77353. protected _prepareRessources(): void;
  77354. /** @hidden */
  77355. _rebuild(): void;
  77356. /**
  77357. * Releases the required resources for the edges renderer
  77358. */
  77359. dispose(): void;
  77360. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77361. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77362. /**
  77363. * Checks if the pair of p0 and p1 is en edge
  77364. * @param faceIndex
  77365. * @param edge
  77366. * @param faceNormals
  77367. * @param p0
  77368. * @param p1
  77369. * @private
  77370. */
  77371. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77372. /**
  77373. * push line into the position, normal and index buffer
  77374. * @protected
  77375. */
  77376. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77377. /**
  77378. * Generates lines edges from adjacencjes
  77379. * @private
  77380. */
  77381. _generateEdgesLines(): void;
  77382. /**
  77383. * Checks wether or not the edges renderer is ready to render.
  77384. * @return true if ready, otherwise false.
  77385. */
  77386. isReady(): boolean;
  77387. /**
  77388. * Renders the edges of the attached mesh,
  77389. */
  77390. render(): void;
  77391. }
  77392. /**
  77393. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77394. */
  77395. export class LineEdgesRenderer extends EdgesRenderer {
  77396. /**
  77397. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77398. * @param source LineMesh used to generate edges
  77399. * @param epsilon not important (specified angle for edge detection)
  77400. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77401. */
  77402. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77403. /**
  77404. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77405. */
  77406. _generateEdgesLines(): void;
  77407. }
  77408. }
  77409. declare module BABYLON {
  77410. /**
  77411. * This represents the object necessary to create a rendering group.
  77412. * This is exclusively used and created by the rendering manager.
  77413. * To modify the behavior, you use the available helpers in your scene or meshes.
  77414. * @hidden
  77415. */
  77416. export class RenderingGroup {
  77417. index: number;
  77418. private _scene;
  77419. private _opaqueSubMeshes;
  77420. private _transparentSubMeshes;
  77421. private _alphaTestSubMeshes;
  77422. private _depthOnlySubMeshes;
  77423. private _particleSystems;
  77424. private _spriteManagers;
  77425. private _opaqueSortCompareFn;
  77426. private _alphaTestSortCompareFn;
  77427. private _transparentSortCompareFn;
  77428. private _renderOpaque;
  77429. private _renderAlphaTest;
  77430. private _renderTransparent;
  77431. /** @hidden */
  77432. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77433. onBeforeTransparentRendering: () => void;
  77434. /**
  77435. * Set the opaque sort comparison function.
  77436. * If null the sub meshes will be render in the order they were created
  77437. */
  77438. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77439. /**
  77440. * Set the alpha test sort comparison function.
  77441. * If null the sub meshes will be render in the order they were created
  77442. */
  77443. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77444. /**
  77445. * Set the transparent sort comparison function.
  77446. * If null the sub meshes will be render in the order they were created
  77447. */
  77448. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77449. /**
  77450. * Creates a new rendering group.
  77451. * @param index The rendering group index
  77452. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77453. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77454. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77455. */
  77456. 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>);
  77457. /**
  77458. * Render all the sub meshes contained in the group.
  77459. * @param customRenderFunction Used to override the default render behaviour of the group.
  77460. * @returns true if rendered some submeshes.
  77461. */
  77462. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77463. /**
  77464. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77465. * @param subMeshes The submeshes to render
  77466. */
  77467. private renderOpaqueSorted;
  77468. /**
  77469. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77470. * @param subMeshes The submeshes to render
  77471. */
  77472. private renderAlphaTestSorted;
  77473. /**
  77474. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77475. * @param subMeshes The submeshes to render
  77476. */
  77477. private renderTransparentSorted;
  77478. /**
  77479. * Renders the submeshes in a specified order.
  77480. * @param subMeshes The submeshes to sort before render
  77481. * @param sortCompareFn The comparison function use to sort
  77482. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77483. * @param transparent Specifies to activate blending if true
  77484. */
  77485. private static renderSorted;
  77486. /**
  77487. * Renders the submeshes in the order they were dispatched (no sort applied).
  77488. * @param subMeshes The submeshes to render
  77489. */
  77490. private static renderUnsorted;
  77491. /**
  77492. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77493. * are rendered back to front if in the same alpha index.
  77494. *
  77495. * @param a The first submesh
  77496. * @param b The second submesh
  77497. * @returns The result of the comparison
  77498. */
  77499. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77500. /**
  77501. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77502. * are rendered back to front.
  77503. *
  77504. * @param a The first submesh
  77505. * @param b The second submesh
  77506. * @returns The result of the comparison
  77507. */
  77508. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77509. /**
  77510. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77511. * are rendered front to back (prevent overdraw).
  77512. *
  77513. * @param a The first submesh
  77514. * @param b The second submesh
  77515. * @returns The result of the comparison
  77516. */
  77517. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77518. /**
  77519. * Resets the different lists of submeshes to prepare a new frame.
  77520. */
  77521. prepare(): void;
  77522. dispose(): void;
  77523. /**
  77524. * Inserts the submesh in its correct queue depending on its material.
  77525. * @param subMesh The submesh to dispatch
  77526. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77527. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77528. */
  77529. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77530. dispatchSprites(spriteManager: ISpriteManager): void;
  77531. dispatchParticles(particleSystem: IParticleSystem): void;
  77532. private _renderParticles;
  77533. private _renderSprites;
  77534. }
  77535. }
  77536. declare module BABYLON {
  77537. /**
  77538. * Interface describing the different options available in the rendering manager
  77539. * regarding Auto Clear between groups.
  77540. */
  77541. export interface IRenderingManagerAutoClearSetup {
  77542. /**
  77543. * Defines whether or not autoclear is enable.
  77544. */
  77545. autoClear: boolean;
  77546. /**
  77547. * Defines whether or not to autoclear the depth buffer.
  77548. */
  77549. depth: boolean;
  77550. /**
  77551. * Defines whether or not to autoclear the stencil buffer.
  77552. */
  77553. stencil: boolean;
  77554. }
  77555. /**
  77556. * This class is used by the onRenderingGroupObservable
  77557. */
  77558. export class RenderingGroupInfo {
  77559. /**
  77560. * The Scene that being rendered
  77561. */
  77562. scene: Scene;
  77563. /**
  77564. * The camera currently used for the rendering pass
  77565. */
  77566. camera: Nullable<Camera>;
  77567. /**
  77568. * The ID of the renderingGroup being processed
  77569. */
  77570. renderingGroupId: number;
  77571. }
  77572. /**
  77573. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77574. * It is enable to manage the different groups as well as the different necessary sort functions.
  77575. * This should not be used directly aside of the few static configurations
  77576. */
  77577. export class RenderingManager {
  77578. /**
  77579. * The max id used for rendering groups (not included)
  77580. */
  77581. static MAX_RENDERINGGROUPS: number;
  77582. /**
  77583. * The min id used for rendering groups (included)
  77584. */
  77585. static MIN_RENDERINGGROUPS: number;
  77586. /**
  77587. * Used to globally prevent autoclearing scenes.
  77588. */
  77589. static AUTOCLEAR: boolean;
  77590. /**
  77591. * @hidden
  77592. */
  77593. _useSceneAutoClearSetup: boolean;
  77594. private _scene;
  77595. private _renderingGroups;
  77596. private _depthStencilBufferAlreadyCleaned;
  77597. private _autoClearDepthStencil;
  77598. private _customOpaqueSortCompareFn;
  77599. private _customAlphaTestSortCompareFn;
  77600. private _customTransparentSortCompareFn;
  77601. private _renderingGroupInfo;
  77602. /**
  77603. * Instantiates a new rendering group for a particular scene
  77604. * @param scene Defines the scene the groups belongs to
  77605. */
  77606. constructor(scene: Scene);
  77607. private _clearDepthStencilBuffer;
  77608. /**
  77609. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77610. * @hidden
  77611. */
  77612. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77613. /**
  77614. * Resets the different information of the group to prepare a new frame
  77615. * @hidden
  77616. */
  77617. reset(): void;
  77618. /**
  77619. * Dispose and release the group and its associated resources.
  77620. * @hidden
  77621. */
  77622. dispose(): void;
  77623. /**
  77624. * Clear the info related to rendering groups preventing retention points during dispose.
  77625. */
  77626. freeRenderingGroups(): void;
  77627. private _prepareRenderingGroup;
  77628. /**
  77629. * Add a sprite manager to the rendering manager in order to render it this frame.
  77630. * @param spriteManager Define the sprite manager to render
  77631. */
  77632. dispatchSprites(spriteManager: ISpriteManager): void;
  77633. /**
  77634. * Add a particle system to the rendering manager in order to render it this frame.
  77635. * @param particleSystem Define the particle system to render
  77636. */
  77637. dispatchParticles(particleSystem: IParticleSystem): void;
  77638. /**
  77639. * Add a submesh to the manager in order to render it this frame
  77640. * @param subMesh The submesh to dispatch
  77641. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77642. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77643. */
  77644. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77645. /**
  77646. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77647. * This allowed control for front to back rendering or reversly depending of the special needs.
  77648. *
  77649. * @param renderingGroupId The rendering group id corresponding to its index
  77650. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77651. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77652. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77653. */
  77654. 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;
  77655. /**
  77656. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77657. *
  77658. * @param renderingGroupId The rendering group id corresponding to its index
  77659. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77660. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77661. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77662. */
  77663. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77664. /**
  77665. * Gets the current auto clear configuration for one rendering group of the rendering
  77666. * manager.
  77667. * @param index the rendering group index to get the information for
  77668. * @returns The auto clear setup for the requested rendering group
  77669. */
  77670. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77671. }
  77672. }
  77673. declare module BABYLON {
  77674. /**
  77675. * This Helps creating a texture that will be created from a camera in your scene.
  77676. * It is basically a dynamic texture that could be used to create special effects for instance.
  77677. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77678. */
  77679. export class RenderTargetTexture extends Texture {
  77680. isCube: boolean;
  77681. /**
  77682. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77683. */
  77684. static readonly REFRESHRATE_RENDER_ONCE: number;
  77685. /**
  77686. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77687. */
  77688. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77689. /**
  77690. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77691. * the central point of your effect and can save a lot of performances.
  77692. */
  77693. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77694. /**
  77695. * Use this predicate to dynamically define the list of mesh you want to render.
  77696. * If set, the renderList property will be overwritten.
  77697. */
  77698. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77699. private _renderList;
  77700. /**
  77701. * Use this list to define the list of mesh you want to render.
  77702. */
  77703. renderList: Nullable<Array<AbstractMesh>>;
  77704. private _hookArray;
  77705. /**
  77706. * Define if particles should be rendered in your texture.
  77707. */
  77708. renderParticles: boolean;
  77709. /**
  77710. * Define if sprites should be rendered in your texture.
  77711. */
  77712. renderSprites: boolean;
  77713. /**
  77714. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77715. */
  77716. coordinatesMode: number;
  77717. /**
  77718. * Define the camera used to render the texture.
  77719. */
  77720. activeCamera: Nullable<Camera>;
  77721. /**
  77722. * Override the render function of the texture with your own one.
  77723. */
  77724. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77725. /**
  77726. * Define if camera post processes should be use while rendering the texture.
  77727. */
  77728. useCameraPostProcesses: boolean;
  77729. /**
  77730. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77731. */
  77732. ignoreCameraViewport: boolean;
  77733. private _postProcessManager;
  77734. private _postProcesses;
  77735. private _resizeObserver;
  77736. /**
  77737. * An event triggered when the texture is unbind.
  77738. */
  77739. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77740. /**
  77741. * An event triggered when the texture is unbind.
  77742. */
  77743. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77744. private _onAfterUnbindObserver;
  77745. /**
  77746. * Set a after unbind callback in the texture.
  77747. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77748. */
  77749. onAfterUnbind: () => void;
  77750. /**
  77751. * An event triggered before rendering the texture
  77752. */
  77753. onBeforeRenderObservable: Observable<number>;
  77754. private _onBeforeRenderObserver;
  77755. /**
  77756. * Set a before render callback in the texture.
  77757. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77758. */
  77759. onBeforeRender: (faceIndex: number) => void;
  77760. /**
  77761. * An event triggered after rendering the texture
  77762. */
  77763. onAfterRenderObservable: Observable<number>;
  77764. private _onAfterRenderObserver;
  77765. /**
  77766. * Set a after render callback in the texture.
  77767. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77768. */
  77769. onAfterRender: (faceIndex: number) => void;
  77770. /**
  77771. * An event triggered after the texture clear
  77772. */
  77773. onClearObservable: Observable<Engine>;
  77774. private _onClearObserver;
  77775. /**
  77776. * Set a clear callback in the texture.
  77777. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77778. */
  77779. onClear: (Engine: Engine) => void;
  77780. /**
  77781. * Define the clear color of the Render Target if it should be different from the scene.
  77782. */
  77783. clearColor: Color4;
  77784. protected _size: number | {
  77785. width: number;
  77786. height: number;
  77787. };
  77788. protected _initialSizeParameter: number | {
  77789. width: number;
  77790. height: number;
  77791. } | {
  77792. ratio: number;
  77793. };
  77794. protected _sizeRatio: Nullable<number>;
  77795. /** @hidden */
  77796. _generateMipMaps: boolean;
  77797. protected _renderingManager: RenderingManager;
  77798. /** @hidden */
  77799. _waitingRenderList: string[];
  77800. protected _doNotChangeAspectRatio: boolean;
  77801. protected _currentRefreshId: number;
  77802. protected _refreshRate: number;
  77803. protected _textureMatrix: Matrix;
  77804. protected _samples: number;
  77805. protected _renderTargetOptions: RenderTargetCreationOptions;
  77806. /**
  77807. * Gets render target creation options that were used.
  77808. */
  77809. readonly renderTargetOptions: RenderTargetCreationOptions;
  77810. protected _engine: Engine;
  77811. protected _onRatioRescale(): void;
  77812. /**
  77813. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77814. * It must define where the camera used to render the texture is set
  77815. */
  77816. boundingBoxPosition: Vector3;
  77817. private _boundingBoxSize;
  77818. /**
  77819. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77820. * When defined, the cubemap will switch to local mode
  77821. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77822. * @example https://www.babylonjs-playground.com/#RNASML
  77823. */
  77824. boundingBoxSize: Vector3;
  77825. /**
  77826. * In case the RTT has been created with a depth texture, get the associated
  77827. * depth texture.
  77828. * Otherwise, return null.
  77829. */
  77830. depthStencilTexture: Nullable<InternalTexture>;
  77831. /**
  77832. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77833. * or used a shadow, depth texture...
  77834. * @param name The friendly name of the texture
  77835. * @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)
  77836. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77837. * @param generateMipMaps True if mip maps need to be generated after render.
  77838. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77839. * @param type The type of the buffer in the RTT (int, half float, float...)
  77840. * @param isCube True if a cube texture needs to be created
  77841. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77842. * @param generateDepthBuffer True to generate a depth buffer
  77843. * @param generateStencilBuffer True to generate a stencil buffer
  77844. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77845. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77846. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77847. */
  77848. constructor(name: string, size: number | {
  77849. width: number;
  77850. height: number;
  77851. } | {
  77852. ratio: number;
  77853. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77854. /**
  77855. * Creates a depth stencil texture.
  77856. * This is only available in WebGL 2 or with the depth texture extension available.
  77857. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77858. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77859. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77860. */
  77861. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77862. private _processSizeParameter;
  77863. /**
  77864. * Define the number of samples to use in case of MSAA.
  77865. * It defaults to one meaning no MSAA has been enabled.
  77866. */
  77867. samples: number;
  77868. /**
  77869. * Resets the refresh counter of the texture and start bak from scratch.
  77870. * Could be useful to regenerate the texture if it is setup to render only once.
  77871. */
  77872. resetRefreshCounter(): void;
  77873. /**
  77874. * Define the refresh rate of the texture or the rendering frequency.
  77875. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77876. */
  77877. refreshRate: number;
  77878. /**
  77879. * Adds a post process to the render target rendering passes.
  77880. * @param postProcess define the post process to add
  77881. */
  77882. addPostProcess(postProcess: PostProcess): void;
  77883. /**
  77884. * Clear all the post processes attached to the render target
  77885. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77886. */
  77887. clearPostProcesses(dispose?: boolean): void;
  77888. /**
  77889. * Remove one of the post process from the list of attached post processes to the texture
  77890. * @param postProcess define the post process to remove from the list
  77891. */
  77892. removePostProcess(postProcess: PostProcess): void;
  77893. /** @hidden */
  77894. _shouldRender(): boolean;
  77895. /**
  77896. * Gets the actual render size of the texture.
  77897. * @returns the width of the render size
  77898. */
  77899. getRenderSize(): number;
  77900. /**
  77901. * Gets the actual render width of the texture.
  77902. * @returns the width of the render size
  77903. */
  77904. getRenderWidth(): number;
  77905. /**
  77906. * Gets the actual render height of the texture.
  77907. * @returns the height of the render size
  77908. */
  77909. getRenderHeight(): number;
  77910. /**
  77911. * Get if the texture can be rescaled or not.
  77912. */
  77913. readonly canRescale: boolean;
  77914. /**
  77915. * Resize the texture using a ratio.
  77916. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77917. */
  77918. scale(ratio: number): void;
  77919. /**
  77920. * Get the texture reflection matrix used to rotate/transform the reflection.
  77921. * @returns the reflection matrix
  77922. */
  77923. getReflectionTextureMatrix(): Matrix;
  77924. /**
  77925. * Resize the texture to a new desired size.
  77926. * Be carrefull as it will recreate all the data in the new texture.
  77927. * @param size Define the new size. It can be:
  77928. * - a number for squared texture,
  77929. * - an object containing { width: number, height: number }
  77930. * - or an object containing a ratio { ratio: number }
  77931. */
  77932. resize(size: number | {
  77933. width: number;
  77934. height: number;
  77935. } | {
  77936. ratio: number;
  77937. }): void;
  77938. /**
  77939. * Renders all the objects from the render list into the texture.
  77940. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77941. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77942. */
  77943. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77944. private _bestReflectionRenderTargetDimension;
  77945. /**
  77946. * @hidden
  77947. * @param faceIndex face index to bind to if this is a cubetexture
  77948. */
  77949. _bindFrameBuffer(faceIndex?: number): void;
  77950. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77951. private renderToTarget;
  77952. /**
  77953. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77954. * This allowed control for front to back rendering or reversly depending of the special needs.
  77955. *
  77956. * @param renderingGroupId The rendering group id corresponding to its index
  77957. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77958. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77959. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77960. */
  77961. 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;
  77962. /**
  77963. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77964. *
  77965. * @param renderingGroupId The rendering group id corresponding to its index
  77966. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77967. */
  77968. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77969. /**
  77970. * Clones the texture.
  77971. * @returns the cloned texture
  77972. */
  77973. clone(): RenderTargetTexture;
  77974. /**
  77975. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77976. * @returns The JSON representation of the texture
  77977. */
  77978. serialize(): any;
  77979. /**
  77980. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77981. */
  77982. disposeFramebufferObjects(): void;
  77983. /**
  77984. * Dispose the texture and release its associated resources.
  77985. */
  77986. dispose(): void;
  77987. /** @hidden */
  77988. _rebuild(): void;
  77989. /**
  77990. * Clear the info related to rendering groups preventing retention point in material dispose.
  77991. */
  77992. freeRenderingGroups(): void;
  77993. /**
  77994. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77995. * @returns the view count
  77996. */
  77997. getViewCount(): number;
  77998. }
  77999. }
  78000. declare module BABYLON {
  78001. /**
  78002. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78003. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78004. * You can then easily use it as a reflectionTexture on a flat surface.
  78005. * In case the surface is not a plane, please consider relying on reflection probes.
  78006. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78007. */
  78008. export class MirrorTexture extends RenderTargetTexture {
  78009. private scene;
  78010. /**
  78011. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  78012. * 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.
  78013. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78014. */
  78015. mirrorPlane: Plane;
  78016. /**
  78017. * Define the blur ratio used to blur the reflection if needed.
  78018. */
  78019. blurRatio: number;
  78020. /**
  78021. * Define the adaptive blur kernel used to blur the reflection if needed.
  78022. * This will autocompute the closest best match for the `blurKernel`
  78023. */
  78024. adaptiveBlurKernel: number;
  78025. /**
  78026. * Define the blur kernel used to blur the reflection if needed.
  78027. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78028. */
  78029. blurKernel: number;
  78030. /**
  78031. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78032. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78033. */
  78034. blurKernelX: number;
  78035. /**
  78036. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78037. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78038. */
  78039. blurKernelY: number;
  78040. private _autoComputeBlurKernel;
  78041. protected _onRatioRescale(): void;
  78042. private _updateGammaSpace;
  78043. private _imageProcessingConfigChangeObserver;
  78044. private _transformMatrix;
  78045. private _mirrorMatrix;
  78046. private _savedViewMatrix;
  78047. private _blurX;
  78048. private _blurY;
  78049. private _adaptiveBlurKernel;
  78050. private _blurKernelX;
  78051. private _blurKernelY;
  78052. private _blurRatio;
  78053. /**
  78054. * Instantiates a Mirror Texture.
  78055. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78056. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78057. * You can then easily use it as a reflectionTexture on a flat surface.
  78058. * In case the surface is not a plane, please consider relying on reflection probes.
  78059. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78060. * @param name
  78061. * @param size
  78062. * @param scene
  78063. * @param generateMipMaps
  78064. * @param type
  78065. * @param samplingMode
  78066. * @param generateDepthBuffer
  78067. */
  78068. constructor(name: string, size: number | {
  78069. width: number;
  78070. height: number;
  78071. } | {
  78072. ratio: number;
  78073. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78074. private _preparePostProcesses;
  78075. /**
  78076. * Clone the mirror texture.
  78077. * @returns the cloned texture
  78078. */
  78079. clone(): MirrorTexture;
  78080. /**
  78081. * Serialize the texture to a JSON representation you could use in Parse later on
  78082. * @returns the serialized JSON representation
  78083. */
  78084. serialize(): any;
  78085. /**
  78086. * Dispose the texture and release its associated resources.
  78087. */
  78088. dispose(): void;
  78089. }
  78090. }
  78091. declare module BABYLON {
  78092. /**
  78093. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78094. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78095. */
  78096. export class Texture extends BaseTexture {
  78097. /** @hidden */
  78098. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78099. /** @hidden */
  78100. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78101. /** @hidden */
  78102. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78103. /** nearest is mag = nearest and min = nearest and mip = linear */
  78104. static readonly NEAREST_SAMPLINGMODE: number;
  78105. /** nearest is mag = nearest and min = nearest and mip = linear */
  78106. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78107. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78108. static readonly BILINEAR_SAMPLINGMODE: number;
  78109. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78110. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78111. /** Trilinear is mag = linear and min = linear and mip = linear */
  78112. static readonly TRILINEAR_SAMPLINGMODE: number;
  78113. /** Trilinear is mag = linear and min = linear and mip = linear */
  78114. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78115. /** mag = nearest and min = nearest and mip = nearest */
  78116. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78117. /** mag = nearest and min = linear and mip = nearest */
  78118. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78119. /** mag = nearest and min = linear and mip = linear */
  78120. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78121. /** mag = nearest and min = linear and mip = none */
  78122. static readonly NEAREST_LINEAR: number;
  78123. /** mag = nearest and min = nearest and mip = none */
  78124. static readonly NEAREST_NEAREST: number;
  78125. /** mag = linear and min = nearest and mip = nearest */
  78126. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78127. /** mag = linear and min = nearest and mip = linear */
  78128. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78129. /** mag = linear and min = linear and mip = none */
  78130. static readonly LINEAR_LINEAR: number;
  78131. /** mag = linear and min = nearest and mip = none */
  78132. static readonly LINEAR_NEAREST: number;
  78133. /** Explicit coordinates mode */
  78134. static readonly EXPLICIT_MODE: number;
  78135. /** Spherical coordinates mode */
  78136. static readonly SPHERICAL_MODE: number;
  78137. /** Planar coordinates mode */
  78138. static readonly PLANAR_MODE: number;
  78139. /** Cubic coordinates mode */
  78140. static readonly CUBIC_MODE: number;
  78141. /** Projection coordinates mode */
  78142. static readonly PROJECTION_MODE: number;
  78143. /** Inverse Cubic coordinates mode */
  78144. static readonly SKYBOX_MODE: number;
  78145. /** Inverse Cubic coordinates mode */
  78146. static readonly INVCUBIC_MODE: number;
  78147. /** Equirectangular coordinates mode */
  78148. static readonly EQUIRECTANGULAR_MODE: number;
  78149. /** Equirectangular Fixed coordinates mode */
  78150. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78151. /** Equirectangular Fixed Mirrored coordinates mode */
  78152. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78153. /** Texture is not repeating outside of 0..1 UVs */
  78154. static readonly CLAMP_ADDRESSMODE: number;
  78155. /** Texture is repeating outside of 0..1 UVs */
  78156. static readonly WRAP_ADDRESSMODE: number;
  78157. /** Texture is repeating and mirrored */
  78158. static readonly MIRROR_ADDRESSMODE: number;
  78159. /**
  78160. * 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
  78161. */
  78162. static UseSerializedUrlIfAny: boolean;
  78163. /**
  78164. * Define the url of the texture.
  78165. */
  78166. url: Nullable<string>;
  78167. /**
  78168. * Define an offset on the texture to offset the u coordinates of the UVs
  78169. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78170. */
  78171. uOffset: number;
  78172. /**
  78173. * Define an offset on the texture to offset the v coordinates of the UVs
  78174. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78175. */
  78176. vOffset: number;
  78177. /**
  78178. * Define an offset on the texture to scale the u coordinates of the UVs
  78179. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78180. */
  78181. uScale: number;
  78182. /**
  78183. * Define an offset on the texture to scale the v coordinates of the UVs
  78184. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78185. */
  78186. vScale: number;
  78187. /**
  78188. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78189. * @see http://doc.babylonjs.com/how_to/more_materials
  78190. */
  78191. uAng: number;
  78192. /**
  78193. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78194. * @see http://doc.babylonjs.com/how_to/more_materials
  78195. */
  78196. vAng: number;
  78197. /**
  78198. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78199. * @see http://doc.babylonjs.com/how_to/more_materials
  78200. */
  78201. wAng: number;
  78202. /**
  78203. * Defines the center of rotation (U)
  78204. */
  78205. uRotationCenter: number;
  78206. /**
  78207. * Defines the center of rotation (V)
  78208. */
  78209. vRotationCenter: number;
  78210. /**
  78211. * Defines the center of rotation (W)
  78212. */
  78213. wRotationCenter: number;
  78214. /**
  78215. * Are mip maps generated for this texture or not.
  78216. */
  78217. readonly noMipmap: boolean;
  78218. /**
  78219. * List of inspectable custom properties (used by the Inspector)
  78220. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78221. */
  78222. inspectableCustomProperties: Nullable<IInspectable[]>;
  78223. private _noMipmap;
  78224. /** @hidden */
  78225. _invertY: boolean;
  78226. private _rowGenerationMatrix;
  78227. private _cachedTextureMatrix;
  78228. private _projectionModeMatrix;
  78229. private _t0;
  78230. private _t1;
  78231. private _t2;
  78232. private _cachedUOffset;
  78233. private _cachedVOffset;
  78234. private _cachedUScale;
  78235. private _cachedVScale;
  78236. private _cachedUAng;
  78237. private _cachedVAng;
  78238. private _cachedWAng;
  78239. private _cachedProjectionMatrixId;
  78240. private _cachedCoordinatesMode;
  78241. /** @hidden */
  78242. protected _initialSamplingMode: number;
  78243. /** @hidden */
  78244. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78245. private _deleteBuffer;
  78246. protected _format: Nullable<number>;
  78247. private _delayedOnLoad;
  78248. private _delayedOnError;
  78249. /**
  78250. * Observable triggered once the texture has been loaded.
  78251. */
  78252. onLoadObservable: Observable<Texture>;
  78253. protected _isBlocking: boolean;
  78254. /**
  78255. * Is the texture preventing material to render while loading.
  78256. * If false, a default texture will be used instead of the loading one during the preparation step.
  78257. */
  78258. isBlocking: boolean;
  78259. /**
  78260. * Get the current sampling mode associated with the texture.
  78261. */
  78262. readonly samplingMode: number;
  78263. /**
  78264. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78265. */
  78266. readonly invertY: boolean;
  78267. /**
  78268. * Instantiates a new texture.
  78269. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78270. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78271. * @param url define the url of the picture to load as a texture
  78272. * @param scene define the scene the texture will belong to
  78273. * @param noMipmap define if the texture will require mip maps or not
  78274. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78275. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78276. * @param onLoad define a callback triggered when the texture has been loaded
  78277. * @param onError define a callback triggered when an error occurred during the loading session
  78278. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78279. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78280. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78281. */
  78282. 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);
  78283. /**
  78284. * Update the url (and optional buffer) of this texture if url was null during construction.
  78285. * @param url the url of the texture
  78286. * @param buffer the buffer of the texture (defaults to null)
  78287. * @param onLoad callback called when the texture is loaded (defaults to null)
  78288. */
  78289. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78290. /**
  78291. * Finish the loading sequence of a texture flagged as delayed load.
  78292. * @hidden
  78293. */
  78294. delayLoad(): void;
  78295. private _prepareRowForTextureGeneration;
  78296. /**
  78297. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78298. * @returns the transform matrix of the texture.
  78299. */
  78300. getTextureMatrix(): Matrix;
  78301. /**
  78302. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78303. * @returns The reflection texture transform
  78304. */
  78305. getReflectionTextureMatrix(): Matrix;
  78306. /**
  78307. * Clones the texture.
  78308. * @returns the cloned texture
  78309. */
  78310. clone(): Texture;
  78311. /**
  78312. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78313. * @returns The JSON representation of the texture
  78314. */
  78315. serialize(): any;
  78316. /**
  78317. * Get the current class name of the texture useful for serialization or dynamic coding.
  78318. * @returns "Texture"
  78319. */
  78320. getClassName(): string;
  78321. /**
  78322. * Dispose the texture and release its associated resources.
  78323. */
  78324. dispose(): void;
  78325. /**
  78326. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78327. * @param parsedTexture Define the JSON representation of the texture
  78328. * @param scene Define the scene the parsed texture should be instantiated in
  78329. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78330. * @returns The parsed texture if successful
  78331. */
  78332. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78333. /**
  78334. * Creates a texture from its base 64 representation.
  78335. * @param data Define the base64 payload without the data: prefix
  78336. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78337. * @param scene Define the scene the texture should belong to
  78338. * @param noMipmap Forces the texture to not create mip map information if true
  78339. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78340. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78341. * @param onLoad define a callback triggered when the texture has been loaded
  78342. * @param onError define a callback triggered when an error occurred during the loading session
  78343. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78344. * @returns the created texture
  78345. */
  78346. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78347. /**
  78348. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78349. * @param data Define the base64 payload without the data: prefix
  78350. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78351. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78352. * @param scene Define the scene the texture should belong to
  78353. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78354. * @param noMipmap Forces the texture to not create mip map information if true
  78355. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78356. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78357. * @param onLoad define a callback triggered when the texture has been loaded
  78358. * @param onError define a callback triggered when an error occurred during the loading session
  78359. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78360. * @returns the created texture
  78361. */
  78362. 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;
  78363. }
  78364. }
  78365. declare module BABYLON {
  78366. interface Engine {
  78367. /**
  78368. * Creates a raw texture
  78369. * @param data defines the data to store in the texture
  78370. * @param width defines the width of the texture
  78371. * @param height defines the height of the texture
  78372. * @param format defines the format of the data
  78373. * @param generateMipMaps defines if the engine should generate the mip levels
  78374. * @param invertY defines if data must be stored with Y axis inverted
  78375. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78376. * @param compression defines the compression used (null by default)
  78377. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78378. * @returns the raw texture inside an InternalTexture
  78379. */
  78380. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78381. /**
  78382. * Update a raw texture
  78383. * @param texture defines the texture to update
  78384. * @param data defines the data to store in the texture
  78385. * @param format defines the format of the data
  78386. * @param invertY defines if data must be stored with Y axis inverted
  78387. */
  78388. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78389. /**
  78390. * Update a raw texture
  78391. * @param texture defines the texture to update
  78392. * @param data defines the data to store in the texture
  78393. * @param format defines the format of the data
  78394. * @param invertY defines if data must be stored with Y axis inverted
  78395. * @param compression defines the compression used (null by default)
  78396. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78397. */
  78398. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78399. /**
  78400. * Creates a new raw cube texture
  78401. * @param data defines the array of data to use to create each face
  78402. * @param size defines the size of the textures
  78403. * @param format defines the format of the data
  78404. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78405. * @param generateMipMaps defines if the engine should generate the mip levels
  78406. * @param invertY defines if data must be stored with Y axis inverted
  78407. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78408. * @param compression defines the compression used (null by default)
  78409. * @returns the cube texture as an InternalTexture
  78410. */
  78411. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78412. /**
  78413. * Update a raw cube texture
  78414. * @param texture defines the texture to udpdate
  78415. * @param data defines the data to store
  78416. * @param format defines the data format
  78417. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78418. * @param invertY defines if data must be stored with Y axis inverted
  78419. */
  78420. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78421. /**
  78422. * Update a raw cube texture
  78423. * @param texture defines the texture to udpdate
  78424. * @param data defines the data to store
  78425. * @param format defines the data format
  78426. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78427. * @param invertY defines if data must be stored with Y axis inverted
  78428. * @param compression defines the compression used (null by default)
  78429. */
  78430. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78431. /**
  78432. * Update a raw cube texture
  78433. * @param texture defines the texture to udpdate
  78434. * @param data defines the data to store
  78435. * @param format defines the data format
  78436. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78437. * @param invertY defines if data must be stored with Y axis inverted
  78438. * @param compression defines the compression used (null by default)
  78439. * @param level defines which level of the texture to update
  78440. */
  78441. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78442. /**
  78443. * Creates a new raw cube texture from a specified url
  78444. * @param url defines the url where the data is located
  78445. * @param scene defines the current scene
  78446. * @param size defines the size of the textures
  78447. * @param format defines the format of the data
  78448. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78449. * @param noMipmap defines if the engine should avoid generating the mip levels
  78450. * @param callback defines a callback used to extract texture data from loaded data
  78451. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78452. * @param onLoad defines a callback called when texture is loaded
  78453. * @param onError defines a callback called if there is an error
  78454. * @returns the cube texture as an InternalTexture
  78455. */
  78456. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  78457. /**
  78458. * Creates a new raw cube texture from a specified url
  78459. * @param url defines the url where the data is located
  78460. * @param scene defines the current scene
  78461. * @param size defines the size of the textures
  78462. * @param format defines the format of the data
  78463. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78464. * @param noMipmap defines if the engine should avoid generating the mip levels
  78465. * @param callback defines a callback used to extract texture data from loaded data
  78466. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78467. * @param onLoad defines a callback called when texture is loaded
  78468. * @param onError defines a callback called if there is an error
  78469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78470. * @param invertY defines if data must be stored with Y axis inverted
  78471. * @returns the cube texture as an InternalTexture
  78472. */
  78473. 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;
  78474. /**
  78475. * Creates a new raw 3D texture
  78476. * @param data defines the data used to create the texture
  78477. * @param width defines the width of the texture
  78478. * @param height defines the height of the texture
  78479. * @param depth defines the depth of the texture
  78480. * @param format defines the format of the texture
  78481. * @param generateMipMaps defines if the engine must generate mip levels
  78482. * @param invertY defines if data must be stored with Y axis inverted
  78483. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78484. * @param compression defines the compressed used (can be null)
  78485. * @param textureType defines the compressed used (can be null)
  78486. * @returns a new raw 3D texture (stored in an InternalTexture)
  78487. */
  78488. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78489. /**
  78490. * Update a raw 3D texture
  78491. * @param texture defines the texture to update
  78492. * @param data defines the data to store
  78493. * @param format defines the data format
  78494. * @param invertY defines if data must be stored with Y axis inverted
  78495. */
  78496. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78497. /**
  78498. * Update a raw 3D texture
  78499. * @param texture defines the texture to update
  78500. * @param data defines the data to store
  78501. * @param format defines the data format
  78502. * @param invertY defines if data must be stored with Y axis inverted
  78503. * @param compression defines the used compression (can be null)
  78504. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78505. */
  78506. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78507. }
  78508. }
  78509. declare module BABYLON {
  78510. /**
  78511. * Raw texture can help creating a texture directly from an array of data.
  78512. * This can be super useful if you either get the data from an uncompressed source or
  78513. * if you wish to create your texture pixel by pixel.
  78514. */
  78515. export class RawTexture extends Texture {
  78516. /**
  78517. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78518. */
  78519. format: number;
  78520. private _engine;
  78521. /**
  78522. * Instantiates a new RawTexture.
  78523. * Raw texture can help creating a texture directly from an array of data.
  78524. * This can be super useful if you either get the data from an uncompressed source or
  78525. * if you wish to create your texture pixel by pixel.
  78526. * @param data define the array of data to use to create the texture
  78527. * @param width define the width of the texture
  78528. * @param height define the height of the texture
  78529. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78530. * @param scene define the scene the texture belongs to
  78531. * @param generateMipMaps define whether mip maps should be generated or not
  78532. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78533. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78534. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78535. */
  78536. constructor(data: ArrayBufferView, width: number, height: number,
  78537. /**
  78538. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78539. */
  78540. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78541. /**
  78542. * Updates the texture underlying data.
  78543. * @param data Define the new data of the texture
  78544. */
  78545. update(data: ArrayBufferView): void;
  78546. /**
  78547. * Creates a luminance texture from some data.
  78548. * @param data Define the texture data
  78549. * @param width Define the width of the texture
  78550. * @param height Define the height of the texture
  78551. * @param scene Define the scene the texture belongs to
  78552. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78553. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78554. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78555. * @returns the luminance texture
  78556. */
  78557. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78558. /**
  78559. * Creates a luminance alpha texture from some data.
  78560. * @param data Define the texture data
  78561. * @param width Define the width of the texture
  78562. * @param height Define the height of the texture
  78563. * @param scene Define the scene the texture belongs to
  78564. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78565. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78566. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78567. * @returns the luminance alpha texture
  78568. */
  78569. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78570. /**
  78571. * Creates an alpha texture from some data.
  78572. * @param data Define the texture data
  78573. * @param width Define the width of the texture
  78574. * @param height Define the height of the texture
  78575. * @param scene Define the scene the texture belongs to
  78576. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78577. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78578. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78579. * @returns the alpha texture
  78580. */
  78581. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78582. /**
  78583. * Creates a RGB texture from some data.
  78584. * @param data Define the texture data
  78585. * @param width Define the width of the texture
  78586. * @param height Define the height of the texture
  78587. * @param scene Define the scene the texture belongs to
  78588. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78589. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78590. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78591. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78592. * @returns the RGB alpha texture
  78593. */
  78594. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78595. /**
  78596. * Creates a RGBA texture from some data.
  78597. * @param data Define the texture data
  78598. * @param width Define the width of the texture
  78599. * @param height Define the height of the texture
  78600. * @param scene Define the scene the texture belongs to
  78601. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78602. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78603. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78604. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78605. * @returns the RGBA texture
  78606. */
  78607. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78608. /**
  78609. * Creates a R texture from some data.
  78610. * @param data Define the texture data
  78611. * @param width Define the width of the texture
  78612. * @param height Define the height of the texture
  78613. * @param scene Define the scene the texture belongs to
  78614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78617. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78618. * @returns the R texture
  78619. */
  78620. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78621. }
  78622. }
  78623. declare module BABYLON {
  78624. /**
  78625. * Defines a runtime animation
  78626. */
  78627. export class RuntimeAnimation {
  78628. private _events;
  78629. /**
  78630. * The current frame of the runtime animation
  78631. */
  78632. private _currentFrame;
  78633. /**
  78634. * The animation used by the runtime animation
  78635. */
  78636. private _animation;
  78637. /**
  78638. * The target of the runtime animation
  78639. */
  78640. private _target;
  78641. /**
  78642. * The initiating animatable
  78643. */
  78644. private _host;
  78645. /**
  78646. * The original value of the runtime animation
  78647. */
  78648. private _originalValue;
  78649. /**
  78650. * The original blend value of the runtime animation
  78651. */
  78652. private _originalBlendValue;
  78653. /**
  78654. * The offsets cache of the runtime animation
  78655. */
  78656. private _offsetsCache;
  78657. /**
  78658. * The high limits cache of the runtime animation
  78659. */
  78660. private _highLimitsCache;
  78661. /**
  78662. * Specifies if the runtime animation has been stopped
  78663. */
  78664. private _stopped;
  78665. /**
  78666. * The blending factor of the runtime animation
  78667. */
  78668. private _blendingFactor;
  78669. /**
  78670. * The BabylonJS scene
  78671. */
  78672. private _scene;
  78673. /**
  78674. * The current value of the runtime animation
  78675. */
  78676. private _currentValue;
  78677. /** @hidden */
  78678. _animationState: _IAnimationState;
  78679. /**
  78680. * The active target of the runtime animation
  78681. */
  78682. private _activeTargets;
  78683. private _currentActiveTarget;
  78684. private _directTarget;
  78685. /**
  78686. * The target path of the runtime animation
  78687. */
  78688. private _targetPath;
  78689. /**
  78690. * The weight of the runtime animation
  78691. */
  78692. private _weight;
  78693. /**
  78694. * The ratio offset of the runtime animation
  78695. */
  78696. private _ratioOffset;
  78697. /**
  78698. * The previous delay of the runtime animation
  78699. */
  78700. private _previousDelay;
  78701. /**
  78702. * The previous ratio of the runtime animation
  78703. */
  78704. private _previousRatio;
  78705. private _enableBlending;
  78706. private _keys;
  78707. private _minFrame;
  78708. private _maxFrame;
  78709. private _minValue;
  78710. private _maxValue;
  78711. private _targetIsArray;
  78712. /**
  78713. * Gets the current frame of the runtime animation
  78714. */
  78715. readonly currentFrame: number;
  78716. /**
  78717. * Gets the weight of the runtime animation
  78718. */
  78719. readonly weight: number;
  78720. /**
  78721. * Gets the current value of the runtime animation
  78722. */
  78723. readonly currentValue: any;
  78724. /**
  78725. * Gets the target path of the runtime animation
  78726. */
  78727. readonly targetPath: string;
  78728. /**
  78729. * Gets the actual target of the runtime animation
  78730. */
  78731. readonly target: any;
  78732. /** @hidden */
  78733. _onLoop: () => void;
  78734. /**
  78735. * Create a new RuntimeAnimation object
  78736. * @param target defines the target of the animation
  78737. * @param animation defines the source animation object
  78738. * @param scene defines the hosting scene
  78739. * @param host defines the initiating Animatable
  78740. */
  78741. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78742. private _preparePath;
  78743. /**
  78744. * Gets the animation from the runtime animation
  78745. */
  78746. readonly animation: Animation;
  78747. /**
  78748. * Resets the runtime animation to the beginning
  78749. * @param restoreOriginal defines whether to restore the target property to the original value
  78750. */
  78751. reset(restoreOriginal?: boolean): void;
  78752. /**
  78753. * Specifies if the runtime animation is stopped
  78754. * @returns Boolean specifying if the runtime animation is stopped
  78755. */
  78756. isStopped(): boolean;
  78757. /**
  78758. * Disposes of the runtime animation
  78759. */
  78760. dispose(): void;
  78761. /**
  78762. * Apply the interpolated value to the target
  78763. * @param currentValue defines the value computed by the animation
  78764. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78765. */
  78766. setValue(currentValue: any, weight: number): void;
  78767. private _getOriginalValues;
  78768. private _setValue;
  78769. /**
  78770. * Gets the loop pmode of the runtime animation
  78771. * @returns Loop Mode
  78772. */
  78773. private _getCorrectLoopMode;
  78774. /**
  78775. * Move the current animation to a given frame
  78776. * @param frame defines the frame to move to
  78777. */
  78778. goToFrame(frame: number): void;
  78779. /**
  78780. * @hidden Internal use only
  78781. */
  78782. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78783. /**
  78784. * Execute the current animation
  78785. * @param delay defines the delay to add to the current frame
  78786. * @param from defines the lower bound of the animation range
  78787. * @param to defines the upper bound of the animation range
  78788. * @param loop defines if the current animation must loop
  78789. * @param speedRatio defines the current speed ratio
  78790. * @param weight defines the weight of the animation (default is -1 so no weight)
  78791. * @param onLoop optional callback called when animation loops
  78792. * @returns a boolean indicating if the animation is running
  78793. */
  78794. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78795. }
  78796. }
  78797. declare module BABYLON {
  78798. /**
  78799. * Class used to store an actual running animation
  78800. */
  78801. export class Animatable {
  78802. /** defines the target object */
  78803. target: any;
  78804. /** defines the starting frame number (default is 0) */
  78805. fromFrame: number;
  78806. /** defines the ending frame number (default is 100) */
  78807. toFrame: number;
  78808. /** defines if the animation must loop (default is false) */
  78809. loopAnimation: boolean;
  78810. /** defines a callback to call when animation ends if it is not looping */
  78811. onAnimationEnd?: (() => void) | null | undefined;
  78812. /** defines a callback to call when animation loops */
  78813. onAnimationLoop?: (() => void) | null | undefined;
  78814. private _localDelayOffset;
  78815. private _pausedDelay;
  78816. private _runtimeAnimations;
  78817. private _paused;
  78818. private _scene;
  78819. private _speedRatio;
  78820. private _weight;
  78821. private _syncRoot;
  78822. /**
  78823. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78824. * This will only apply for non looping animation (default is true)
  78825. */
  78826. disposeOnEnd: boolean;
  78827. /**
  78828. * Gets a boolean indicating if the animation has started
  78829. */
  78830. animationStarted: boolean;
  78831. /**
  78832. * Observer raised when the animation ends
  78833. */
  78834. onAnimationEndObservable: Observable<Animatable>;
  78835. /**
  78836. * Observer raised when the animation loops
  78837. */
  78838. onAnimationLoopObservable: Observable<Animatable>;
  78839. /**
  78840. * Gets the root Animatable used to synchronize and normalize animations
  78841. */
  78842. readonly syncRoot: Nullable<Animatable>;
  78843. /**
  78844. * Gets the current frame of the first RuntimeAnimation
  78845. * Used to synchronize Animatables
  78846. */
  78847. readonly masterFrame: number;
  78848. /**
  78849. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78850. */
  78851. weight: number;
  78852. /**
  78853. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78854. */
  78855. speedRatio: number;
  78856. /**
  78857. * Creates a new Animatable
  78858. * @param scene defines the hosting scene
  78859. * @param target defines the target object
  78860. * @param fromFrame defines the starting frame number (default is 0)
  78861. * @param toFrame defines the ending frame number (default is 100)
  78862. * @param loopAnimation defines if the animation must loop (default is false)
  78863. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78864. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78865. * @param animations defines a group of animation to add to the new Animatable
  78866. * @param onAnimationLoop defines a callback to call when animation loops
  78867. */
  78868. constructor(scene: Scene,
  78869. /** defines the target object */
  78870. target: any,
  78871. /** defines the starting frame number (default is 0) */
  78872. fromFrame?: number,
  78873. /** defines the ending frame number (default is 100) */
  78874. toFrame?: number,
  78875. /** defines if the animation must loop (default is false) */
  78876. loopAnimation?: boolean, speedRatio?: number,
  78877. /** defines a callback to call when animation ends if it is not looping */
  78878. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78879. /** defines a callback to call when animation loops */
  78880. onAnimationLoop?: (() => void) | null | undefined);
  78881. /**
  78882. * Synchronize and normalize current Animatable with a source Animatable
  78883. * This is useful when using animation weights and when animations are not of the same length
  78884. * @param root defines the root Animatable to synchronize with
  78885. * @returns the current Animatable
  78886. */
  78887. syncWith(root: Animatable): Animatable;
  78888. /**
  78889. * Gets the list of runtime animations
  78890. * @returns an array of RuntimeAnimation
  78891. */
  78892. getAnimations(): RuntimeAnimation[];
  78893. /**
  78894. * Adds more animations to the current animatable
  78895. * @param target defines the target of the animations
  78896. * @param animations defines the new animations to add
  78897. */
  78898. appendAnimations(target: any, animations: Animation[]): void;
  78899. /**
  78900. * Gets the source animation for a specific property
  78901. * @param property defines the propertyu to look for
  78902. * @returns null or the source animation for the given property
  78903. */
  78904. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78905. /**
  78906. * Gets the runtime animation for a specific property
  78907. * @param property defines the propertyu to look for
  78908. * @returns null or the runtime animation for the given property
  78909. */
  78910. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78911. /**
  78912. * Resets the animatable to its original state
  78913. */
  78914. reset(): void;
  78915. /**
  78916. * Allows the animatable to blend with current running animations
  78917. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78918. * @param blendingSpeed defines the blending speed to use
  78919. */
  78920. enableBlending(blendingSpeed: number): void;
  78921. /**
  78922. * Disable animation blending
  78923. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78924. */
  78925. disableBlending(): void;
  78926. /**
  78927. * Jump directly to a given frame
  78928. * @param frame defines the frame to jump to
  78929. */
  78930. goToFrame(frame: number): void;
  78931. /**
  78932. * Pause the animation
  78933. */
  78934. pause(): void;
  78935. /**
  78936. * Restart the animation
  78937. */
  78938. restart(): void;
  78939. private _raiseOnAnimationEnd;
  78940. /**
  78941. * Stop and delete the current animation
  78942. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78943. * @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)
  78944. */
  78945. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78946. /**
  78947. * Wait asynchronously for the animation to end
  78948. * @returns a promise which will be fullfilled when the animation ends
  78949. */
  78950. waitAsync(): Promise<Animatable>;
  78951. /** @hidden */
  78952. _animate(delay: number): boolean;
  78953. }
  78954. interface Scene {
  78955. /** @hidden */
  78956. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78957. /** @hidden */
  78958. _processLateAnimationBindingsForMatrices(holder: {
  78959. totalWeight: number;
  78960. animations: RuntimeAnimation[];
  78961. originalValue: Matrix;
  78962. }): any;
  78963. /** @hidden */
  78964. _processLateAnimationBindingsForQuaternions(holder: {
  78965. totalWeight: number;
  78966. animations: RuntimeAnimation[];
  78967. originalValue: Quaternion;
  78968. }, refQuaternion: Quaternion): Quaternion;
  78969. /** @hidden */
  78970. _processLateAnimationBindings(): void;
  78971. /**
  78972. * Will start the animation sequence of a given target
  78973. * @param target defines the target
  78974. * @param from defines from which frame should animation start
  78975. * @param to defines until which frame should animation run.
  78976. * @param weight defines the weight to apply to the animation (1.0 by default)
  78977. * @param loop defines if the animation loops
  78978. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78979. * @param onAnimationEnd defines the function to be executed when the animation ends
  78980. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78981. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78982. * @param onAnimationLoop defines the callback to call when an animation loops
  78983. * @returns the animatable object created for this animation
  78984. */
  78985. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78986. /**
  78987. * Will start the animation sequence of a given target
  78988. * @param target defines the target
  78989. * @param from defines from which frame should animation start
  78990. * @param to defines until which frame should animation run.
  78991. * @param loop defines if the animation loops
  78992. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78993. * @param onAnimationEnd defines the function to be executed when the animation ends
  78994. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78995. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78996. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78997. * @param onAnimationLoop defines the callback to call when an animation loops
  78998. * @returns the animatable object created for this animation
  78999. */
  79000. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79001. /**
  79002. * Will start the animation sequence of a given target and its hierarchy
  79003. * @param target defines the target
  79004. * @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.
  79005. * @param from defines from which frame should animation start
  79006. * @param to defines until which frame should animation run.
  79007. * @param loop defines if the animation loops
  79008. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79009. * @param onAnimationEnd defines the function to be executed when the animation ends
  79010. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79011. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79012. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79013. * @param onAnimationLoop defines the callback to call when an animation loops
  79014. * @returns the list of created animatables
  79015. */
  79016. 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[];
  79017. /**
  79018. * Begin a new animation on a given node
  79019. * @param target defines the target where the animation will take place
  79020. * @param animations defines the list of animations to start
  79021. * @param from defines the initial value
  79022. * @param to defines the final value
  79023. * @param loop defines if you want animation to loop (off by default)
  79024. * @param speedRatio defines the speed ratio to apply to all animations
  79025. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79026. * @param onAnimationLoop defines the callback to call when an animation loops
  79027. * @returns the list of created animatables
  79028. */
  79029. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79030. /**
  79031. * Begin a new animation on a given node and its hierarchy
  79032. * @param target defines the root node where the animation will take place
  79033. * @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.
  79034. * @param animations defines the list of animations to start
  79035. * @param from defines the initial value
  79036. * @param to defines the final value
  79037. * @param loop defines if you want animation to loop (off by default)
  79038. * @param speedRatio defines the speed ratio to apply to all animations
  79039. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79040. * @param onAnimationLoop defines the callback to call when an animation loops
  79041. * @returns the list of animatables created for all nodes
  79042. */
  79043. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79044. /**
  79045. * Gets the animatable associated with a specific target
  79046. * @param target defines the target of the animatable
  79047. * @returns the required animatable if found
  79048. */
  79049. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79050. /**
  79051. * Gets all animatables associated with a given target
  79052. * @param target defines the target to look animatables for
  79053. * @returns an array of Animatables
  79054. */
  79055. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79056. /**
  79057. * Stops and removes all animations that have been applied to the scene
  79058. */
  79059. stopAllAnimations(): void;
  79060. }
  79061. interface Bone {
  79062. /**
  79063. * Copy an animation range from another bone
  79064. * @param source defines the source bone
  79065. * @param rangeName defines the range name to copy
  79066. * @param frameOffset defines the frame offset
  79067. * @param rescaleAsRequired defines if rescaling must be applied if required
  79068. * @param skelDimensionsRatio defines the scaling ratio
  79069. * @returns true if operation was successful
  79070. */
  79071. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79072. }
  79073. }
  79074. declare module BABYLON {
  79075. /**
  79076. * Class used to handle skinning animations
  79077. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79078. */
  79079. export class Skeleton implements IAnimatable {
  79080. /** defines the skeleton name */
  79081. name: string;
  79082. /** defines the skeleton Id */
  79083. id: string;
  79084. /**
  79085. * Defines the list of child bones
  79086. */
  79087. bones: Bone[];
  79088. /**
  79089. * Defines an estimate of the dimension of the skeleton at rest
  79090. */
  79091. dimensionsAtRest: Vector3;
  79092. /**
  79093. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79094. */
  79095. needInitialSkinMatrix: boolean;
  79096. /**
  79097. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79098. */
  79099. overrideMesh: Nullable<AbstractMesh>;
  79100. /**
  79101. * Gets the list of animations attached to this skeleton
  79102. */
  79103. animations: Array<Animation>;
  79104. private _scene;
  79105. private _isDirty;
  79106. private _transformMatrices;
  79107. private _transformMatrixTexture;
  79108. private _meshesWithPoseMatrix;
  79109. private _animatables;
  79110. private _identity;
  79111. private _synchronizedWithMesh;
  79112. private _ranges;
  79113. private _lastAbsoluteTransformsUpdateId;
  79114. private _canUseTextureForBones;
  79115. private _uniqueId;
  79116. /** @hidden */
  79117. _numBonesWithLinkedTransformNode: number;
  79118. /** @hidden */
  79119. _hasWaitingData: Nullable<boolean>;
  79120. /**
  79121. * Specifies if the skeleton should be serialized
  79122. */
  79123. doNotSerialize: boolean;
  79124. private _useTextureToStoreBoneMatrices;
  79125. /**
  79126. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79127. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79128. */
  79129. useTextureToStoreBoneMatrices: boolean;
  79130. private _animationPropertiesOverride;
  79131. /**
  79132. * Gets or sets the animation properties override
  79133. */
  79134. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79135. /**
  79136. * List of inspectable custom properties (used by the Inspector)
  79137. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79138. */
  79139. inspectableCustomProperties: IInspectable[];
  79140. /**
  79141. * An observable triggered before computing the skeleton's matrices
  79142. */
  79143. onBeforeComputeObservable: Observable<Skeleton>;
  79144. /**
  79145. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79146. */
  79147. readonly isUsingTextureForMatrices: boolean;
  79148. /**
  79149. * Gets the unique ID of this skeleton
  79150. */
  79151. readonly uniqueId: number;
  79152. /**
  79153. * Creates a new skeleton
  79154. * @param name defines the skeleton name
  79155. * @param id defines the skeleton Id
  79156. * @param scene defines the hosting scene
  79157. */
  79158. constructor(
  79159. /** defines the skeleton name */
  79160. name: string,
  79161. /** defines the skeleton Id */
  79162. id: string, scene: Scene);
  79163. /**
  79164. * Gets the current object class name.
  79165. * @return the class name
  79166. */
  79167. getClassName(): string;
  79168. /**
  79169. * Returns an array containing the root bones
  79170. * @returns an array containing the root bones
  79171. */
  79172. getChildren(): Array<Bone>;
  79173. /**
  79174. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79175. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79176. * @returns a Float32Array containing matrices data
  79177. */
  79178. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79179. /**
  79180. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79181. * @returns a raw texture containing the data
  79182. */
  79183. getTransformMatrixTexture(): Nullable<RawTexture>;
  79184. /**
  79185. * Gets the current hosting scene
  79186. * @returns a scene object
  79187. */
  79188. getScene(): Scene;
  79189. /**
  79190. * Gets a string representing the current skeleton data
  79191. * @param fullDetails defines a boolean indicating if we want a verbose version
  79192. * @returns a string representing the current skeleton data
  79193. */
  79194. toString(fullDetails?: boolean): string;
  79195. /**
  79196. * Get bone's index searching by name
  79197. * @param name defines bone's name to search for
  79198. * @return the indice of the bone. Returns -1 if not found
  79199. */
  79200. getBoneIndexByName(name: string): number;
  79201. /**
  79202. * Creater a new animation range
  79203. * @param name defines the name of the range
  79204. * @param from defines the start key
  79205. * @param to defines the end key
  79206. */
  79207. createAnimationRange(name: string, from: number, to: number): void;
  79208. /**
  79209. * Delete a specific animation range
  79210. * @param name defines the name of the range
  79211. * @param deleteFrames defines if frames must be removed as well
  79212. */
  79213. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79214. /**
  79215. * Gets a specific animation range
  79216. * @param name defines the name of the range to look for
  79217. * @returns the requested animation range or null if not found
  79218. */
  79219. getAnimationRange(name: string): Nullable<AnimationRange>;
  79220. /**
  79221. * Gets the list of all animation ranges defined on this skeleton
  79222. * @returns an array
  79223. */
  79224. getAnimationRanges(): Nullable<AnimationRange>[];
  79225. /**
  79226. * Copy animation range from a source skeleton.
  79227. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79228. * @param source defines the source skeleton
  79229. * @param name defines the name of the range to copy
  79230. * @param rescaleAsRequired defines if rescaling must be applied if required
  79231. * @returns true if operation was successful
  79232. */
  79233. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79234. /**
  79235. * Forces the skeleton to go to rest pose
  79236. */
  79237. returnToRest(): void;
  79238. private _getHighestAnimationFrame;
  79239. /**
  79240. * Begin a specific animation range
  79241. * @param name defines the name of the range to start
  79242. * @param loop defines if looping must be turned on (false by default)
  79243. * @param speedRatio defines the speed ratio to apply (1 by default)
  79244. * @param onAnimationEnd defines a callback which will be called when animation will end
  79245. * @returns a new animatable
  79246. */
  79247. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79248. /** @hidden */
  79249. _markAsDirty(): void;
  79250. /** @hidden */
  79251. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79252. /** @hidden */
  79253. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79254. private _computeTransformMatrices;
  79255. /**
  79256. * Build all resources required to render a skeleton
  79257. */
  79258. prepare(): void;
  79259. /**
  79260. * Gets the list of animatables currently running for this skeleton
  79261. * @returns an array of animatables
  79262. */
  79263. getAnimatables(): IAnimatable[];
  79264. /**
  79265. * Clone the current skeleton
  79266. * @param name defines the name of the new skeleton
  79267. * @param id defines the id of the new skeleton
  79268. * @returns the new skeleton
  79269. */
  79270. clone(name: string, id: string): Skeleton;
  79271. /**
  79272. * Enable animation blending for this skeleton
  79273. * @param blendingSpeed defines the blending speed to apply
  79274. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79275. */
  79276. enableBlending(blendingSpeed?: number): void;
  79277. /**
  79278. * Releases all resources associated with the current skeleton
  79279. */
  79280. dispose(): void;
  79281. /**
  79282. * Serialize the skeleton in a JSON object
  79283. * @returns a JSON object
  79284. */
  79285. serialize(): any;
  79286. /**
  79287. * Creates a new skeleton from serialized data
  79288. * @param parsedSkeleton defines the serialized data
  79289. * @param scene defines the hosting scene
  79290. * @returns a new skeleton
  79291. */
  79292. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79293. /**
  79294. * Compute all node absolute transforms
  79295. * @param forceUpdate defines if computation must be done even if cache is up to date
  79296. */
  79297. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79298. /**
  79299. * Gets the root pose matrix
  79300. * @returns a matrix
  79301. */
  79302. getPoseMatrix(): Nullable<Matrix>;
  79303. /**
  79304. * Sorts bones per internal index
  79305. */
  79306. sortBones(): void;
  79307. private _sortBones;
  79308. }
  79309. }
  79310. declare module BABYLON {
  79311. /**
  79312. * Defines a target to use with MorphTargetManager
  79313. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79314. */
  79315. export class MorphTarget implements IAnimatable {
  79316. /** defines the name of the target */
  79317. name: string;
  79318. /**
  79319. * Gets or sets the list of animations
  79320. */
  79321. animations: Animation[];
  79322. private _scene;
  79323. private _positions;
  79324. private _normals;
  79325. private _tangents;
  79326. private _influence;
  79327. /**
  79328. * Observable raised when the influence changes
  79329. */
  79330. onInfluenceChanged: Observable<boolean>;
  79331. /** @hidden */
  79332. _onDataLayoutChanged: Observable<void>;
  79333. /**
  79334. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79335. */
  79336. influence: number;
  79337. /**
  79338. * Gets or sets the id of the morph Target
  79339. */
  79340. id: string;
  79341. private _animationPropertiesOverride;
  79342. /**
  79343. * Gets or sets the animation properties override
  79344. */
  79345. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79346. /**
  79347. * Creates a new MorphTarget
  79348. * @param name defines the name of the target
  79349. * @param influence defines the influence to use
  79350. * @param scene defines the scene the morphtarget belongs to
  79351. */
  79352. constructor(
  79353. /** defines the name of the target */
  79354. name: string, influence?: number, scene?: Nullable<Scene>);
  79355. /**
  79356. * Gets a boolean defining if the target contains position data
  79357. */
  79358. readonly hasPositions: boolean;
  79359. /**
  79360. * Gets a boolean defining if the target contains normal data
  79361. */
  79362. readonly hasNormals: boolean;
  79363. /**
  79364. * Gets a boolean defining if the target contains tangent data
  79365. */
  79366. readonly hasTangents: boolean;
  79367. /**
  79368. * Affects position data to this target
  79369. * @param data defines the position data to use
  79370. */
  79371. setPositions(data: Nullable<FloatArray>): void;
  79372. /**
  79373. * Gets the position data stored in this target
  79374. * @returns a FloatArray containing the position data (or null if not present)
  79375. */
  79376. getPositions(): Nullable<FloatArray>;
  79377. /**
  79378. * Affects normal data to this target
  79379. * @param data defines the normal data to use
  79380. */
  79381. setNormals(data: Nullable<FloatArray>): void;
  79382. /**
  79383. * Gets the normal data stored in this target
  79384. * @returns a FloatArray containing the normal data (or null if not present)
  79385. */
  79386. getNormals(): Nullable<FloatArray>;
  79387. /**
  79388. * Affects tangent data to this target
  79389. * @param data defines the tangent data to use
  79390. */
  79391. setTangents(data: Nullable<FloatArray>): void;
  79392. /**
  79393. * Gets the tangent data stored in this target
  79394. * @returns a FloatArray containing the tangent data (or null if not present)
  79395. */
  79396. getTangents(): Nullable<FloatArray>;
  79397. /**
  79398. * Serializes the current target into a Serialization object
  79399. * @returns the serialized object
  79400. */
  79401. serialize(): any;
  79402. /**
  79403. * Returns the string "MorphTarget"
  79404. * @returns "MorphTarget"
  79405. */
  79406. getClassName(): string;
  79407. /**
  79408. * Creates a new target from serialized data
  79409. * @param serializationObject defines the serialized data to use
  79410. * @returns a new MorphTarget
  79411. */
  79412. static Parse(serializationObject: any): MorphTarget;
  79413. /**
  79414. * Creates a MorphTarget from mesh data
  79415. * @param mesh defines the source mesh
  79416. * @param name defines the name to use for the new target
  79417. * @param influence defines the influence to attach to the target
  79418. * @returns a new MorphTarget
  79419. */
  79420. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79421. }
  79422. }
  79423. declare module BABYLON {
  79424. /**
  79425. * This class is used to deform meshes using morphing between different targets
  79426. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79427. */
  79428. export class MorphTargetManager {
  79429. private _targets;
  79430. private _targetInfluenceChangedObservers;
  79431. private _targetDataLayoutChangedObservers;
  79432. private _activeTargets;
  79433. private _scene;
  79434. private _influences;
  79435. private _supportsNormals;
  79436. private _supportsTangents;
  79437. private _vertexCount;
  79438. private _uniqueId;
  79439. private _tempInfluences;
  79440. /**
  79441. * Creates a new MorphTargetManager
  79442. * @param scene defines the current scene
  79443. */
  79444. constructor(scene?: Nullable<Scene>);
  79445. /**
  79446. * Gets the unique ID of this manager
  79447. */
  79448. readonly uniqueId: number;
  79449. /**
  79450. * Gets the number of vertices handled by this manager
  79451. */
  79452. readonly vertexCount: number;
  79453. /**
  79454. * Gets a boolean indicating if this manager supports morphing of normals
  79455. */
  79456. readonly supportsNormals: boolean;
  79457. /**
  79458. * Gets a boolean indicating if this manager supports morphing of tangents
  79459. */
  79460. readonly supportsTangents: boolean;
  79461. /**
  79462. * Gets the number of targets stored in this manager
  79463. */
  79464. readonly numTargets: number;
  79465. /**
  79466. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79467. */
  79468. readonly numInfluencers: number;
  79469. /**
  79470. * Gets the list of influences (one per target)
  79471. */
  79472. readonly influences: Float32Array;
  79473. /**
  79474. * Gets the active target at specified index. An active target is a target with an influence > 0
  79475. * @param index defines the index to check
  79476. * @returns the requested target
  79477. */
  79478. getActiveTarget(index: number): MorphTarget;
  79479. /**
  79480. * Gets the target at specified index
  79481. * @param index defines the index to check
  79482. * @returns the requested target
  79483. */
  79484. getTarget(index: number): MorphTarget;
  79485. /**
  79486. * Add a new target to this manager
  79487. * @param target defines the target to add
  79488. */
  79489. addTarget(target: MorphTarget): void;
  79490. /**
  79491. * Removes a target from the manager
  79492. * @param target defines the target to remove
  79493. */
  79494. removeTarget(target: MorphTarget): void;
  79495. /**
  79496. * Serializes the current manager into a Serialization object
  79497. * @returns the serialized object
  79498. */
  79499. serialize(): any;
  79500. private _syncActiveTargets;
  79501. /**
  79502. * Syncrhonize the targets with all the meshes using this morph target manager
  79503. */
  79504. synchronize(): void;
  79505. /**
  79506. * Creates a new MorphTargetManager from serialized data
  79507. * @param serializationObject defines the serialized data
  79508. * @param scene defines the hosting scene
  79509. * @returns the new MorphTargetManager
  79510. */
  79511. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79512. }
  79513. }
  79514. declare module BABYLON {
  79515. /**
  79516. * Class used to represent a specific level of detail of a mesh
  79517. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79518. */
  79519. export class MeshLODLevel {
  79520. /** Defines the distance where this level should star being displayed */
  79521. distance: number;
  79522. /** Defines the mesh to use to render this level */
  79523. mesh: Nullable<Mesh>;
  79524. /**
  79525. * Creates a new LOD level
  79526. * @param distance defines the distance where this level should star being displayed
  79527. * @param mesh defines the mesh to use to render this level
  79528. */
  79529. constructor(
  79530. /** Defines the distance where this level should star being displayed */
  79531. distance: number,
  79532. /** Defines the mesh to use to render this level */
  79533. mesh: Nullable<Mesh>);
  79534. }
  79535. }
  79536. declare module BABYLON {
  79537. /**
  79538. * Mesh representing the gorund
  79539. */
  79540. export class GroundMesh extends Mesh {
  79541. /** If octree should be generated */
  79542. generateOctree: boolean;
  79543. private _heightQuads;
  79544. /** @hidden */
  79545. _subdivisionsX: number;
  79546. /** @hidden */
  79547. _subdivisionsY: number;
  79548. /** @hidden */
  79549. _width: number;
  79550. /** @hidden */
  79551. _height: number;
  79552. /** @hidden */
  79553. _minX: number;
  79554. /** @hidden */
  79555. _maxX: number;
  79556. /** @hidden */
  79557. _minZ: number;
  79558. /** @hidden */
  79559. _maxZ: number;
  79560. constructor(name: string, scene: Scene);
  79561. /**
  79562. * "GroundMesh"
  79563. * @returns "GroundMesh"
  79564. */
  79565. getClassName(): string;
  79566. /**
  79567. * The minimum of x and y subdivisions
  79568. */
  79569. readonly subdivisions: number;
  79570. /**
  79571. * X subdivisions
  79572. */
  79573. readonly subdivisionsX: number;
  79574. /**
  79575. * Y subdivisions
  79576. */
  79577. readonly subdivisionsY: number;
  79578. /**
  79579. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79580. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79581. * @param chunksCount the number of subdivisions for x and y
  79582. * @param octreeBlocksSize (Default: 32)
  79583. */
  79584. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79585. /**
  79586. * Returns a height (y) value in the Worl system :
  79587. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79588. * @param x x coordinate
  79589. * @param z z coordinate
  79590. * @returns the ground y position if (x, z) are outside the ground surface.
  79591. */
  79592. getHeightAtCoordinates(x: number, z: number): number;
  79593. /**
  79594. * Returns a normalized vector (Vector3) orthogonal to the ground
  79595. * at the ground coordinates (x, z) expressed in the World system.
  79596. * @param x x coordinate
  79597. * @param z z coordinate
  79598. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79599. */
  79600. getNormalAtCoordinates(x: number, z: number): Vector3;
  79601. /**
  79602. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79603. * at the ground coordinates (x, z) expressed in the World system.
  79604. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79605. * @param x x coordinate
  79606. * @param z z coordinate
  79607. * @param ref vector to store the result
  79608. * @returns the GroundMesh.
  79609. */
  79610. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79611. /**
  79612. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79613. * if the ground has been updated.
  79614. * This can be used in the render loop.
  79615. * @returns the GroundMesh.
  79616. */
  79617. updateCoordinateHeights(): GroundMesh;
  79618. private _getFacetAt;
  79619. private _initHeightQuads;
  79620. private _computeHeightQuads;
  79621. /**
  79622. * Serializes this ground mesh
  79623. * @param serializationObject object to write serialization to
  79624. */
  79625. serialize(serializationObject: any): void;
  79626. /**
  79627. * Parses a serialized ground mesh
  79628. * @param parsedMesh the serialized mesh
  79629. * @param scene the scene to create the ground mesh in
  79630. * @returns the created ground mesh
  79631. */
  79632. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79633. }
  79634. }
  79635. declare module BABYLON {
  79636. /**
  79637. * Interface for Physics-Joint data
  79638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79639. */
  79640. export interface PhysicsJointData {
  79641. /**
  79642. * The main pivot of the joint
  79643. */
  79644. mainPivot?: Vector3;
  79645. /**
  79646. * The connected pivot of the joint
  79647. */
  79648. connectedPivot?: Vector3;
  79649. /**
  79650. * The main axis of the joint
  79651. */
  79652. mainAxis?: Vector3;
  79653. /**
  79654. * The connected axis of the joint
  79655. */
  79656. connectedAxis?: Vector3;
  79657. /**
  79658. * The collision of the joint
  79659. */
  79660. collision?: boolean;
  79661. /**
  79662. * Native Oimo/Cannon/Energy data
  79663. */
  79664. nativeParams?: any;
  79665. }
  79666. /**
  79667. * This is a holder class for the physics joint created by the physics plugin
  79668. * It holds a set of functions to control the underlying joint
  79669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79670. */
  79671. export class PhysicsJoint {
  79672. /**
  79673. * The type of the physics joint
  79674. */
  79675. type: number;
  79676. /**
  79677. * The data for the physics joint
  79678. */
  79679. jointData: PhysicsJointData;
  79680. private _physicsJoint;
  79681. protected _physicsPlugin: IPhysicsEnginePlugin;
  79682. /**
  79683. * Initializes the physics joint
  79684. * @param type The type of the physics joint
  79685. * @param jointData The data for the physics joint
  79686. */
  79687. constructor(
  79688. /**
  79689. * The type of the physics joint
  79690. */
  79691. type: number,
  79692. /**
  79693. * The data for the physics joint
  79694. */
  79695. jointData: PhysicsJointData);
  79696. /**
  79697. * Gets the physics joint
  79698. */
  79699. /**
  79700. * Sets the physics joint
  79701. */
  79702. physicsJoint: any;
  79703. /**
  79704. * Sets the physics plugin
  79705. */
  79706. physicsPlugin: IPhysicsEnginePlugin;
  79707. /**
  79708. * Execute a function that is physics-plugin specific.
  79709. * @param {Function} func the function that will be executed.
  79710. * It accepts two parameters: the physics world and the physics joint
  79711. */
  79712. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79713. /**
  79714. * Distance-Joint type
  79715. */
  79716. static DistanceJoint: number;
  79717. /**
  79718. * Hinge-Joint type
  79719. */
  79720. static HingeJoint: number;
  79721. /**
  79722. * Ball-and-Socket joint type
  79723. */
  79724. static BallAndSocketJoint: number;
  79725. /**
  79726. * Wheel-Joint type
  79727. */
  79728. static WheelJoint: number;
  79729. /**
  79730. * Slider-Joint type
  79731. */
  79732. static SliderJoint: number;
  79733. /**
  79734. * Prismatic-Joint type
  79735. */
  79736. static PrismaticJoint: number;
  79737. /**
  79738. * Universal-Joint type
  79739. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79740. */
  79741. static UniversalJoint: number;
  79742. /**
  79743. * Hinge-Joint 2 type
  79744. */
  79745. static Hinge2Joint: number;
  79746. /**
  79747. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79748. */
  79749. static PointToPointJoint: number;
  79750. /**
  79751. * Spring-Joint type
  79752. */
  79753. static SpringJoint: number;
  79754. /**
  79755. * Lock-Joint type
  79756. */
  79757. static LockJoint: number;
  79758. }
  79759. /**
  79760. * A class representing a physics distance joint
  79761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79762. */
  79763. export class DistanceJoint extends PhysicsJoint {
  79764. /**
  79765. *
  79766. * @param jointData The data for the Distance-Joint
  79767. */
  79768. constructor(jointData: DistanceJointData);
  79769. /**
  79770. * Update the predefined distance.
  79771. * @param maxDistance The maximum preferred distance
  79772. * @param minDistance The minimum preferred distance
  79773. */
  79774. updateDistance(maxDistance: number, minDistance?: number): void;
  79775. }
  79776. /**
  79777. * Represents a Motor-Enabled Joint
  79778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79779. */
  79780. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79781. /**
  79782. * Initializes the Motor-Enabled Joint
  79783. * @param type The type of the joint
  79784. * @param jointData The physica joint data for the joint
  79785. */
  79786. constructor(type: number, jointData: PhysicsJointData);
  79787. /**
  79788. * Set the motor values.
  79789. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79790. * @param force the force to apply
  79791. * @param maxForce max force for this motor.
  79792. */
  79793. setMotor(force?: number, maxForce?: number): void;
  79794. /**
  79795. * Set the motor's limits.
  79796. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79797. * @param upperLimit The upper limit of the motor
  79798. * @param lowerLimit The lower limit of the motor
  79799. */
  79800. setLimit(upperLimit: number, lowerLimit?: number): void;
  79801. }
  79802. /**
  79803. * This class represents a single physics Hinge-Joint
  79804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79805. */
  79806. export class HingeJoint extends MotorEnabledJoint {
  79807. /**
  79808. * Initializes the Hinge-Joint
  79809. * @param jointData The joint data for the Hinge-Joint
  79810. */
  79811. constructor(jointData: PhysicsJointData);
  79812. /**
  79813. * Set the motor values.
  79814. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79815. * @param {number} force the force to apply
  79816. * @param {number} maxForce max force for this motor.
  79817. */
  79818. setMotor(force?: number, maxForce?: number): void;
  79819. /**
  79820. * Set the motor's limits.
  79821. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79822. * @param upperLimit The upper limit of the motor
  79823. * @param lowerLimit The lower limit of the motor
  79824. */
  79825. setLimit(upperLimit: number, lowerLimit?: number): void;
  79826. }
  79827. /**
  79828. * This class represents a dual hinge physics joint (same as wheel joint)
  79829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79830. */
  79831. export class Hinge2Joint extends MotorEnabledJoint {
  79832. /**
  79833. * Initializes the Hinge2-Joint
  79834. * @param jointData The joint data for the Hinge2-Joint
  79835. */
  79836. constructor(jointData: PhysicsJointData);
  79837. /**
  79838. * Set the motor values.
  79839. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79840. * @param {number} targetSpeed the speed the motor is to reach
  79841. * @param {number} maxForce max force for this motor.
  79842. * @param {motorIndex} the motor's index, 0 or 1.
  79843. */
  79844. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79845. /**
  79846. * Set the motor limits.
  79847. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79848. * @param {number} upperLimit the upper limit
  79849. * @param {number} lowerLimit lower limit
  79850. * @param {motorIndex} the motor's index, 0 or 1.
  79851. */
  79852. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79853. }
  79854. /**
  79855. * Interface for a motor enabled joint
  79856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79857. */
  79858. export interface IMotorEnabledJoint {
  79859. /**
  79860. * Physics joint
  79861. */
  79862. physicsJoint: any;
  79863. /**
  79864. * Sets the motor of the motor-enabled joint
  79865. * @param force The force of the motor
  79866. * @param maxForce The maximum force of the motor
  79867. * @param motorIndex The index of the motor
  79868. */
  79869. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79870. /**
  79871. * Sets the limit of the motor
  79872. * @param upperLimit The upper limit of the motor
  79873. * @param lowerLimit The lower limit of the motor
  79874. * @param motorIndex The index of the motor
  79875. */
  79876. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79877. }
  79878. /**
  79879. * Joint data for a Distance-Joint
  79880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79881. */
  79882. export interface DistanceJointData extends PhysicsJointData {
  79883. /**
  79884. * Max distance the 2 joint objects can be apart
  79885. */
  79886. maxDistance: number;
  79887. }
  79888. /**
  79889. * Joint data from a spring joint
  79890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79891. */
  79892. export interface SpringJointData extends PhysicsJointData {
  79893. /**
  79894. * Length of the spring
  79895. */
  79896. length: number;
  79897. /**
  79898. * Stiffness of the spring
  79899. */
  79900. stiffness: number;
  79901. /**
  79902. * Damping of the spring
  79903. */
  79904. damping: number;
  79905. /** this callback will be called when applying the force to the impostors. */
  79906. forceApplicationCallback: () => void;
  79907. }
  79908. }
  79909. declare module BABYLON {
  79910. /**
  79911. * Holds the data for the raycast result
  79912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79913. */
  79914. export class PhysicsRaycastResult {
  79915. private _hasHit;
  79916. private _hitDistance;
  79917. private _hitNormalWorld;
  79918. private _hitPointWorld;
  79919. private _rayFromWorld;
  79920. private _rayToWorld;
  79921. /**
  79922. * Gets if there was a hit
  79923. */
  79924. readonly hasHit: boolean;
  79925. /**
  79926. * Gets the distance from the hit
  79927. */
  79928. readonly hitDistance: number;
  79929. /**
  79930. * Gets the hit normal/direction in the world
  79931. */
  79932. readonly hitNormalWorld: Vector3;
  79933. /**
  79934. * Gets the hit point in the world
  79935. */
  79936. readonly hitPointWorld: Vector3;
  79937. /**
  79938. * Gets the ray "start point" of the ray in the world
  79939. */
  79940. readonly rayFromWorld: Vector3;
  79941. /**
  79942. * Gets the ray "end point" of the ray in the world
  79943. */
  79944. readonly rayToWorld: Vector3;
  79945. /**
  79946. * Sets the hit data (normal & point in world space)
  79947. * @param hitNormalWorld defines the normal in world space
  79948. * @param hitPointWorld defines the point in world space
  79949. */
  79950. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79951. /**
  79952. * Sets the distance from the start point to the hit point
  79953. * @param distance
  79954. */
  79955. setHitDistance(distance: number): void;
  79956. /**
  79957. * Calculates the distance manually
  79958. */
  79959. calculateHitDistance(): void;
  79960. /**
  79961. * Resets all the values to default
  79962. * @param from The from point on world space
  79963. * @param to The to point on world space
  79964. */
  79965. reset(from?: Vector3, to?: Vector3): void;
  79966. }
  79967. /**
  79968. * Interface for the size containing width and height
  79969. */
  79970. interface IXYZ {
  79971. /**
  79972. * X
  79973. */
  79974. x: number;
  79975. /**
  79976. * Y
  79977. */
  79978. y: number;
  79979. /**
  79980. * Z
  79981. */
  79982. z: number;
  79983. }
  79984. }
  79985. declare module BABYLON {
  79986. /**
  79987. * Interface used to describe a physics joint
  79988. */
  79989. export interface PhysicsImpostorJoint {
  79990. /** Defines the main impostor to which the joint is linked */
  79991. mainImpostor: PhysicsImpostor;
  79992. /** Defines the impostor that is connected to the main impostor using this joint */
  79993. connectedImpostor: PhysicsImpostor;
  79994. /** Defines the joint itself */
  79995. joint: PhysicsJoint;
  79996. }
  79997. /** @hidden */
  79998. export interface IPhysicsEnginePlugin {
  79999. world: any;
  80000. name: string;
  80001. setGravity(gravity: Vector3): void;
  80002. setTimeStep(timeStep: number): void;
  80003. getTimeStep(): number;
  80004. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  80005. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  80006. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  80007. generatePhysicsBody(impostor: PhysicsImpostor): void;
  80008. removePhysicsBody(impostor: PhysicsImpostor): void;
  80009. generateJoint(joint: PhysicsImpostorJoint): void;
  80010. removeJoint(joint: PhysicsImpostorJoint): void;
  80011. isSupported(): boolean;
  80012. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  80013. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  80014. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80015. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80016. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80017. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80018. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  80019. getBodyMass(impostor: PhysicsImpostor): number;
  80020. getBodyFriction(impostor: PhysicsImpostor): number;
  80021. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  80022. getBodyRestitution(impostor: PhysicsImpostor): number;
  80023. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  80024. getBodyPressure?(impostor: PhysicsImpostor): number;
  80025. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  80026. getBodyStiffness?(impostor: PhysicsImpostor): number;
  80027. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  80028. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  80029. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80030. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80031. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80032. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80033. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80034. sleepBody(impostor: PhysicsImpostor): void;
  80035. wakeUpBody(impostor: PhysicsImpostor): void;
  80036. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80037. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80038. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80039. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80040. getRadius(impostor: PhysicsImpostor): number;
  80041. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80042. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80043. dispose(): void;
  80044. }
  80045. /**
  80046. * Interface used to define a physics engine
  80047. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80048. */
  80049. export interface IPhysicsEngine {
  80050. /**
  80051. * Gets the gravity vector used by the simulation
  80052. */
  80053. gravity: Vector3;
  80054. /**
  80055. * Sets the gravity vector used by the simulation
  80056. * @param gravity defines the gravity vector to use
  80057. */
  80058. setGravity(gravity: Vector3): void;
  80059. /**
  80060. * Set the time step of the physics engine.
  80061. * Default is 1/60.
  80062. * To slow it down, enter 1/600 for example.
  80063. * To speed it up, 1/30
  80064. * @param newTimeStep the new timestep to apply to this world.
  80065. */
  80066. setTimeStep(newTimeStep: number): void;
  80067. /**
  80068. * Get the time step of the physics engine.
  80069. * @returns the current time step
  80070. */
  80071. getTimeStep(): number;
  80072. /**
  80073. * Release all resources
  80074. */
  80075. dispose(): void;
  80076. /**
  80077. * Gets the name of the current physics plugin
  80078. * @returns the name of the plugin
  80079. */
  80080. getPhysicsPluginName(): string;
  80081. /**
  80082. * Adding a new impostor for the impostor tracking.
  80083. * This will be done by the impostor itself.
  80084. * @param impostor the impostor to add
  80085. */
  80086. addImpostor(impostor: PhysicsImpostor): void;
  80087. /**
  80088. * Remove an impostor from the engine.
  80089. * This impostor and its mesh will not longer be updated by the physics engine.
  80090. * @param impostor the impostor to remove
  80091. */
  80092. removeImpostor(impostor: PhysicsImpostor): void;
  80093. /**
  80094. * Add a joint to the physics engine
  80095. * @param mainImpostor defines the main impostor to which the joint is added.
  80096. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80097. * @param joint defines the joint that will connect both impostors.
  80098. */
  80099. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80100. /**
  80101. * Removes a joint from the simulation
  80102. * @param mainImpostor defines the impostor used with the joint
  80103. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80104. * @param joint defines the joint to remove
  80105. */
  80106. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80107. /**
  80108. * Gets the current plugin used to run the simulation
  80109. * @returns current plugin
  80110. */
  80111. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80112. /**
  80113. * Gets the list of physic impostors
  80114. * @returns an array of PhysicsImpostor
  80115. */
  80116. getImpostors(): Array<PhysicsImpostor>;
  80117. /**
  80118. * Gets the impostor for a physics enabled object
  80119. * @param object defines the object impersonated by the impostor
  80120. * @returns the PhysicsImpostor or null if not found
  80121. */
  80122. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80123. /**
  80124. * Gets the impostor for a physics body object
  80125. * @param body defines physics body used by the impostor
  80126. * @returns the PhysicsImpostor or null if not found
  80127. */
  80128. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80129. /**
  80130. * Does a raycast in the physics world
  80131. * @param from when should the ray start?
  80132. * @param to when should the ray end?
  80133. * @returns PhysicsRaycastResult
  80134. */
  80135. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80136. /**
  80137. * Called by the scene. No need to call it.
  80138. * @param delta defines the timespam between frames
  80139. */
  80140. _step(delta: number): void;
  80141. }
  80142. }
  80143. declare module BABYLON {
  80144. /**
  80145. * The interface for the physics imposter parameters
  80146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80147. */
  80148. export interface PhysicsImpostorParameters {
  80149. /**
  80150. * The mass of the physics imposter
  80151. */
  80152. mass: number;
  80153. /**
  80154. * The friction of the physics imposter
  80155. */
  80156. friction?: number;
  80157. /**
  80158. * The coefficient of restitution of the physics imposter
  80159. */
  80160. restitution?: number;
  80161. /**
  80162. * The native options of the physics imposter
  80163. */
  80164. nativeOptions?: any;
  80165. /**
  80166. * Specifies if the parent should be ignored
  80167. */
  80168. ignoreParent?: boolean;
  80169. /**
  80170. * Specifies if bi-directional transformations should be disabled
  80171. */
  80172. disableBidirectionalTransformation?: boolean;
  80173. /**
  80174. * The pressure inside the physics imposter, soft object only
  80175. */
  80176. pressure?: number;
  80177. /**
  80178. * The stiffness the physics imposter, soft object only
  80179. */
  80180. stiffness?: number;
  80181. /**
  80182. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80183. */
  80184. velocityIterations?: number;
  80185. /**
  80186. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80187. */
  80188. positionIterations?: number;
  80189. /**
  80190. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80191. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80192. * Add to fix multiple points
  80193. */
  80194. fixedPoints?: number;
  80195. /**
  80196. * The collision margin around a soft object
  80197. */
  80198. margin?: number;
  80199. /**
  80200. * The collision margin around a soft object
  80201. */
  80202. damping?: number;
  80203. /**
  80204. * The path for a rope based on an extrusion
  80205. */
  80206. path?: any;
  80207. /**
  80208. * The shape of an extrusion used for a rope based on an extrusion
  80209. */
  80210. shape?: any;
  80211. }
  80212. /**
  80213. * Interface for a physics-enabled object
  80214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80215. */
  80216. export interface IPhysicsEnabledObject {
  80217. /**
  80218. * The position of the physics-enabled object
  80219. */
  80220. position: Vector3;
  80221. /**
  80222. * The rotation of the physics-enabled object
  80223. */
  80224. rotationQuaternion: Nullable<Quaternion>;
  80225. /**
  80226. * The scale of the physics-enabled object
  80227. */
  80228. scaling: Vector3;
  80229. /**
  80230. * The rotation of the physics-enabled object
  80231. */
  80232. rotation?: Vector3;
  80233. /**
  80234. * The parent of the physics-enabled object
  80235. */
  80236. parent?: any;
  80237. /**
  80238. * The bounding info of the physics-enabled object
  80239. * @returns The bounding info of the physics-enabled object
  80240. */
  80241. getBoundingInfo(): BoundingInfo;
  80242. /**
  80243. * Computes the world matrix
  80244. * @param force Specifies if the world matrix should be computed by force
  80245. * @returns A world matrix
  80246. */
  80247. computeWorldMatrix(force: boolean): Matrix;
  80248. /**
  80249. * Gets the world matrix
  80250. * @returns A world matrix
  80251. */
  80252. getWorldMatrix?(): Matrix;
  80253. /**
  80254. * Gets the child meshes
  80255. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80256. * @returns An array of abstract meshes
  80257. */
  80258. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80259. /**
  80260. * Gets the vertex data
  80261. * @param kind The type of vertex data
  80262. * @returns A nullable array of numbers, or a float32 array
  80263. */
  80264. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80265. /**
  80266. * Gets the indices from the mesh
  80267. * @returns A nullable array of index arrays
  80268. */
  80269. getIndices?(): Nullable<IndicesArray>;
  80270. /**
  80271. * Gets the scene from the mesh
  80272. * @returns the indices array or null
  80273. */
  80274. getScene?(): Scene;
  80275. /**
  80276. * Gets the absolute position from the mesh
  80277. * @returns the absolute position
  80278. */
  80279. getAbsolutePosition(): Vector3;
  80280. /**
  80281. * Gets the absolute pivot point from the mesh
  80282. * @returns the absolute pivot point
  80283. */
  80284. getAbsolutePivotPoint(): Vector3;
  80285. /**
  80286. * Rotates the mesh
  80287. * @param axis The axis of rotation
  80288. * @param amount The amount of rotation
  80289. * @param space The space of the rotation
  80290. * @returns The rotation transform node
  80291. */
  80292. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80293. /**
  80294. * Translates the mesh
  80295. * @param axis The axis of translation
  80296. * @param distance The distance of translation
  80297. * @param space The space of the translation
  80298. * @returns The transform node
  80299. */
  80300. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80301. /**
  80302. * Sets the absolute position of the mesh
  80303. * @param absolutePosition The absolute position of the mesh
  80304. * @returns The transform node
  80305. */
  80306. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80307. /**
  80308. * Gets the class name of the mesh
  80309. * @returns The class name
  80310. */
  80311. getClassName(): string;
  80312. }
  80313. /**
  80314. * Represents a physics imposter
  80315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80316. */
  80317. export class PhysicsImpostor {
  80318. /**
  80319. * The physics-enabled object used as the physics imposter
  80320. */
  80321. object: IPhysicsEnabledObject;
  80322. /**
  80323. * The type of the physics imposter
  80324. */
  80325. type: number;
  80326. private _options;
  80327. private _scene?;
  80328. /**
  80329. * The default object size of the imposter
  80330. */
  80331. static DEFAULT_OBJECT_SIZE: Vector3;
  80332. /**
  80333. * The identity quaternion of the imposter
  80334. */
  80335. static IDENTITY_QUATERNION: Quaternion;
  80336. /** @hidden */
  80337. _pluginData: any;
  80338. private _physicsEngine;
  80339. private _physicsBody;
  80340. private _bodyUpdateRequired;
  80341. private _onBeforePhysicsStepCallbacks;
  80342. private _onAfterPhysicsStepCallbacks;
  80343. /** @hidden */
  80344. _onPhysicsCollideCallbacks: Array<{
  80345. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80346. otherImpostors: Array<PhysicsImpostor>;
  80347. }>;
  80348. private _deltaPosition;
  80349. private _deltaRotation;
  80350. private _deltaRotationConjugated;
  80351. /** hidden */
  80352. _isFromLine: boolean;
  80353. private _parent;
  80354. private _isDisposed;
  80355. private static _tmpVecs;
  80356. private static _tmpQuat;
  80357. /**
  80358. * Specifies if the physics imposter is disposed
  80359. */
  80360. readonly isDisposed: boolean;
  80361. /**
  80362. * Gets the mass of the physics imposter
  80363. */
  80364. mass: number;
  80365. /**
  80366. * Gets the coefficient of friction
  80367. */
  80368. /**
  80369. * Sets the coefficient of friction
  80370. */
  80371. friction: number;
  80372. /**
  80373. * Gets the coefficient of restitution
  80374. */
  80375. /**
  80376. * Sets the coefficient of restitution
  80377. */
  80378. restitution: number;
  80379. /**
  80380. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80381. */
  80382. /**
  80383. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80384. */
  80385. pressure: number;
  80386. /**
  80387. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80388. */
  80389. /**
  80390. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80391. */
  80392. stiffness: number;
  80393. /**
  80394. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80395. */
  80396. /**
  80397. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80398. */
  80399. velocityIterations: number;
  80400. /**
  80401. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80402. */
  80403. /**
  80404. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80405. */
  80406. positionIterations: number;
  80407. /**
  80408. * The unique id of the physics imposter
  80409. * set by the physics engine when adding this impostor to the array
  80410. */
  80411. uniqueId: number;
  80412. /**
  80413. * @hidden
  80414. */
  80415. soft: boolean;
  80416. /**
  80417. * @hidden
  80418. */
  80419. segments: number;
  80420. private _joints;
  80421. /**
  80422. * Initializes the physics imposter
  80423. * @param object The physics-enabled object used as the physics imposter
  80424. * @param type The type of the physics imposter
  80425. * @param _options The options for the physics imposter
  80426. * @param _scene The Babylon scene
  80427. */
  80428. constructor(
  80429. /**
  80430. * The physics-enabled object used as the physics imposter
  80431. */
  80432. object: IPhysicsEnabledObject,
  80433. /**
  80434. * The type of the physics imposter
  80435. */
  80436. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80437. /**
  80438. * This function will completly initialize this impostor.
  80439. * It will create a new body - but only if this mesh has no parent.
  80440. * If it has, this impostor will not be used other than to define the impostor
  80441. * of the child mesh.
  80442. * @hidden
  80443. */
  80444. _init(): void;
  80445. private _getPhysicsParent;
  80446. /**
  80447. * Should a new body be generated.
  80448. * @returns boolean specifying if body initialization is required
  80449. */
  80450. isBodyInitRequired(): boolean;
  80451. /**
  80452. * Sets the updated scaling
  80453. * @param updated Specifies if the scaling is updated
  80454. */
  80455. setScalingUpdated(): void;
  80456. /**
  80457. * Force a regeneration of this or the parent's impostor's body.
  80458. * Use under cautious - This will remove all joints already implemented.
  80459. */
  80460. forceUpdate(): void;
  80461. /**
  80462. * Gets the body that holds this impostor. Either its own, or its parent.
  80463. */
  80464. /**
  80465. * Set the physics body. Used mainly by the physics engine/plugin
  80466. */
  80467. physicsBody: any;
  80468. /**
  80469. * Get the parent of the physics imposter
  80470. * @returns Physics imposter or null
  80471. */
  80472. /**
  80473. * Sets the parent of the physics imposter
  80474. */
  80475. parent: Nullable<PhysicsImpostor>;
  80476. /**
  80477. * Resets the update flags
  80478. */
  80479. resetUpdateFlags(): void;
  80480. /**
  80481. * Gets the object extend size
  80482. * @returns the object extend size
  80483. */
  80484. getObjectExtendSize(): Vector3;
  80485. /**
  80486. * Gets the object center
  80487. * @returns The object center
  80488. */
  80489. getObjectCenter(): Vector3;
  80490. /**
  80491. * Get a specific parametes from the options parameter
  80492. * @param paramName The object parameter name
  80493. * @returns The object parameter
  80494. */
  80495. getParam(paramName: string): any;
  80496. /**
  80497. * Sets a specific parameter in the options given to the physics plugin
  80498. * @param paramName The parameter name
  80499. * @param value The value of the parameter
  80500. */
  80501. setParam(paramName: string, value: number): void;
  80502. /**
  80503. * Specifically change the body's mass option. Won't recreate the physics body object
  80504. * @param mass The mass of the physics imposter
  80505. */
  80506. setMass(mass: number): void;
  80507. /**
  80508. * Gets the linear velocity
  80509. * @returns linear velocity or null
  80510. */
  80511. getLinearVelocity(): Nullable<Vector3>;
  80512. /**
  80513. * Sets the linear velocity
  80514. * @param velocity linear velocity or null
  80515. */
  80516. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80517. /**
  80518. * Gets the angular velocity
  80519. * @returns angular velocity or null
  80520. */
  80521. getAngularVelocity(): Nullable<Vector3>;
  80522. /**
  80523. * Sets the angular velocity
  80524. * @param velocity The velocity or null
  80525. */
  80526. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80527. /**
  80528. * Execute a function with the physics plugin native code
  80529. * Provide a function the will have two variables - the world object and the physics body object
  80530. * @param func The function to execute with the physics plugin native code
  80531. */
  80532. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80533. /**
  80534. * Register a function that will be executed before the physics world is stepping forward
  80535. * @param func The function to execute before the physics world is stepped forward
  80536. */
  80537. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80538. /**
  80539. * Unregister a function that will be executed before the physics world is stepping forward
  80540. * @param func The function to execute before the physics world is stepped forward
  80541. */
  80542. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80543. /**
  80544. * Register a function that will be executed after the physics step
  80545. * @param func The function to execute after physics step
  80546. */
  80547. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80548. /**
  80549. * Unregisters a function that will be executed after the physics step
  80550. * @param func The function to execute after physics step
  80551. */
  80552. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80553. /**
  80554. * register a function that will be executed when this impostor collides against a different body
  80555. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80556. * @param func Callback that is executed on collision
  80557. */
  80558. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80559. /**
  80560. * Unregisters the physics imposter on contact
  80561. * @param collideAgainst The physics object to collide against
  80562. * @param func Callback to execute on collision
  80563. */
  80564. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80565. private _tmpQuat;
  80566. private _tmpQuat2;
  80567. /**
  80568. * Get the parent rotation
  80569. * @returns The parent rotation
  80570. */
  80571. getParentsRotation(): Quaternion;
  80572. /**
  80573. * this function is executed by the physics engine.
  80574. */
  80575. beforeStep: () => void;
  80576. /**
  80577. * this function is executed by the physics engine
  80578. */
  80579. afterStep: () => void;
  80580. /**
  80581. * Legacy collision detection event support
  80582. */
  80583. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80584. /**
  80585. * event and body object due to cannon's event-based architecture.
  80586. */
  80587. onCollide: (e: {
  80588. body: any;
  80589. }) => void;
  80590. /**
  80591. * Apply a force
  80592. * @param force The force to apply
  80593. * @param contactPoint The contact point for the force
  80594. * @returns The physics imposter
  80595. */
  80596. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80597. /**
  80598. * Apply an impulse
  80599. * @param force The impulse force
  80600. * @param contactPoint The contact point for the impulse force
  80601. * @returns The physics imposter
  80602. */
  80603. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80604. /**
  80605. * A help function to create a joint
  80606. * @param otherImpostor A physics imposter used to create a joint
  80607. * @param jointType The type of joint
  80608. * @param jointData The data for the joint
  80609. * @returns The physics imposter
  80610. */
  80611. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80612. /**
  80613. * Add a joint to this impostor with a different impostor
  80614. * @param otherImpostor A physics imposter used to add a joint
  80615. * @param joint The joint to add
  80616. * @returns The physics imposter
  80617. */
  80618. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80619. /**
  80620. * Add an anchor to a cloth impostor
  80621. * @param otherImpostor rigid impostor to anchor to
  80622. * @param width ratio across width from 0 to 1
  80623. * @param height ratio up height from 0 to 1
  80624. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80625. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80626. * @returns impostor the soft imposter
  80627. */
  80628. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80629. /**
  80630. * Add a hook to a rope impostor
  80631. * @param otherImpostor rigid impostor to anchor to
  80632. * @param length ratio across rope from 0 to 1
  80633. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80634. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80635. * @returns impostor the rope imposter
  80636. */
  80637. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80638. /**
  80639. * Will keep this body still, in a sleep mode.
  80640. * @returns the physics imposter
  80641. */
  80642. sleep(): PhysicsImpostor;
  80643. /**
  80644. * Wake the body up.
  80645. * @returns The physics imposter
  80646. */
  80647. wakeUp(): PhysicsImpostor;
  80648. /**
  80649. * Clones the physics imposter
  80650. * @param newObject The physics imposter clones to this physics-enabled object
  80651. * @returns A nullable physics imposter
  80652. */
  80653. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80654. /**
  80655. * Disposes the physics imposter
  80656. */
  80657. dispose(): void;
  80658. /**
  80659. * Sets the delta position
  80660. * @param position The delta position amount
  80661. */
  80662. setDeltaPosition(position: Vector3): void;
  80663. /**
  80664. * Sets the delta rotation
  80665. * @param rotation The delta rotation amount
  80666. */
  80667. setDeltaRotation(rotation: Quaternion): void;
  80668. /**
  80669. * Gets the box size of the physics imposter and stores the result in the input parameter
  80670. * @param result Stores the box size
  80671. * @returns The physics imposter
  80672. */
  80673. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80674. /**
  80675. * Gets the radius of the physics imposter
  80676. * @returns Radius of the physics imposter
  80677. */
  80678. getRadius(): number;
  80679. /**
  80680. * Sync a bone with this impostor
  80681. * @param bone The bone to sync to the impostor.
  80682. * @param boneMesh The mesh that the bone is influencing.
  80683. * @param jointPivot The pivot of the joint / bone in local space.
  80684. * @param distToJoint Optional distance from the impostor to the joint.
  80685. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80686. */
  80687. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80688. /**
  80689. * Sync impostor to a bone
  80690. * @param bone The bone that the impostor will be synced to.
  80691. * @param boneMesh The mesh that the bone is influencing.
  80692. * @param jointPivot The pivot of the joint / bone in local space.
  80693. * @param distToJoint Optional distance from the impostor to the joint.
  80694. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80695. * @param boneAxis Optional vector3 axis the bone is aligned with
  80696. */
  80697. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80698. /**
  80699. * No-Imposter type
  80700. */
  80701. static NoImpostor: number;
  80702. /**
  80703. * Sphere-Imposter type
  80704. */
  80705. static SphereImpostor: number;
  80706. /**
  80707. * Box-Imposter type
  80708. */
  80709. static BoxImpostor: number;
  80710. /**
  80711. * Plane-Imposter type
  80712. */
  80713. static PlaneImpostor: number;
  80714. /**
  80715. * Mesh-imposter type
  80716. */
  80717. static MeshImpostor: number;
  80718. /**
  80719. * Cylinder-Imposter type
  80720. */
  80721. static CylinderImpostor: number;
  80722. /**
  80723. * Particle-Imposter type
  80724. */
  80725. static ParticleImpostor: number;
  80726. /**
  80727. * Heightmap-Imposter type
  80728. */
  80729. static HeightmapImpostor: number;
  80730. /**
  80731. * ConvexHull-Impostor type (Ammo.js plugin only)
  80732. */
  80733. static ConvexHullImpostor: number;
  80734. /**
  80735. * Rope-Imposter type
  80736. */
  80737. static RopeImpostor: number;
  80738. /**
  80739. * Cloth-Imposter type
  80740. */
  80741. static ClothImpostor: number;
  80742. /**
  80743. * Softbody-Imposter type
  80744. */
  80745. static SoftbodyImpostor: number;
  80746. }
  80747. }
  80748. declare module BABYLON {
  80749. /**
  80750. * @hidden
  80751. **/
  80752. export class _CreationDataStorage {
  80753. closePath?: boolean;
  80754. closeArray?: boolean;
  80755. idx: number[];
  80756. dashSize: number;
  80757. gapSize: number;
  80758. path3D: Path3D;
  80759. pathArray: Vector3[][];
  80760. arc: number;
  80761. radius: number;
  80762. cap: number;
  80763. tessellation: number;
  80764. }
  80765. /**
  80766. * @hidden
  80767. **/
  80768. class _InstanceDataStorage {
  80769. visibleInstances: any;
  80770. batchCache: _InstancesBatch;
  80771. instancesBufferSize: number;
  80772. instancesBuffer: Nullable<Buffer>;
  80773. instancesData: Float32Array;
  80774. overridenInstanceCount: number;
  80775. isFrozen: boolean;
  80776. previousBatch: _InstancesBatch;
  80777. hardwareInstancedRendering: boolean;
  80778. sideOrientation: number;
  80779. }
  80780. /**
  80781. * @hidden
  80782. **/
  80783. export class _InstancesBatch {
  80784. mustReturn: boolean;
  80785. visibleInstances: Nullable<InstancedMesh[]>[];
  80786. renderSelf: boolean[];
  80787. hardwareInstancedRendering: boolean[];
  80788. }
  80789. /**
  80790. * Class used to represent renderable models
  80791. */
  80792. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80793. /**
  80794. * Mesh side orientation : usually the external or front surface
  80795. */
  80796. static readonly FRONTSIDE: number;
  80797. /**
  80798. * Mesh side orientation : usually the internal or back surface
  80799. */
  80800. static readonly BACKSIDE: number;
  80801. /**
  80802. * Mesh side orientation : both internal and external or front and back surfaces
  80803. */
  80804. static readonly DOUBLESIDE: number;
  80805. /**
  80806. * Mesh side orientation : by default, `FRONTSIDE`
  80807. */
  80808. static readonly DEFAULTSIDE: number;
  80809. /**
  80810. * Mesh cap setting : no cap
  80811. */
  80812. static readonly NO_CAP: number;
  80813. /**
  80814. * Mesh cap setting : one cap at the beginning of the mesh
  80815. */
  80816. static readonly CAP_START: number;
  80817. /**
  80818. * Mesh cap setting : one cap at the end of the mesh
  80819. */
  80820. static readonly CAP_END: number;
  80821. /**
  80822. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80823. */
  80824. static readonly CAP_ALL: number;
  80825. /**
  80826. * Gets the default side orientation.
  80827. * @param orientation the orientation to value to attempt to get
  80828. * @returns the default orientation
  80829. * @hidden
  80830. */
  80831. static _GetDefaultSideOrientation(orientation?: number): number;
  80832. private _internalMeshDataInfo;
  80833. /**
  80834. * An event triggered before rendering the mesh
  80835. */
  80836. readonly onBeforeRenderObservable: Observable<Mesh>;
  80837. /**
  80838. * An event triggered before binding the mesh
  80839. */
  80840. readonly onBeforeBindObservable: Observable<Mesh>;
  80841. /**
  80842. * An event triggered after rendering the mesh
  80843. */
  80844. readonly onAfterRenderObservable: Observable<Mesh>;
  80845. /**
  80846. * An event triggered before drawing the mesh
  80847. */
  80848. readonly onBeforeDrawObservable: Observable<Mesh>;
  80849. private _onBeforeDrawObserver;
  80850. /**
  80851. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80852. */
  80853. onBeforeDraw: () => void;
  80854. /**
  80855. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80856. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80857. */
  80858. delayLoadState: number;
  80859. /**
  80860. * Gets the list of instances created from this mesh
  80861. * it is not supposed to be modified manually.
  80862. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80863. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80864. */
  80865. instances: InstancedMesh[];
  80866. /**
  80867. * Gets the file containing delay loading data for this mesh
  80868. */
  80869. delayLoadingFile: string;
  80870. /** @hidden */
  80871. _binaryInfo: any;
  80872. /**
  80873. * User defined function used to change how LOD level selection is done
  80874. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80875. */
  80876. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80877. /**
  80878. * Gets or sets the morph target manager
  80879. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80880. */
  80881. morphTargetManager: Nullable<MorphTargetManager>;
  80882. /** @hidden */
  80883. _creationDataStorage: Nullable<_CreationDataStorage>;
  80884. /** @hidden */
  80885. _geometry: Nullable<Geometry>;
  80886. /** @hidden */
  80887. _delayInfo: Array<string>;
  80888. /** @hidden */
  80889. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80890. /** @hidden */
  80891. _instanceDataStorage: _InstanceDataStorage;
  80892. private _effectiveMaterial;
  80893. /** @hidden */
  80894. _shouldGenerateFlatShading: boolean;
  80895. /** @hidden */
  80896. _originalBuilderSideOrientation: number;
  80897. /**
  80898. * Use this property to change the original side orientation defined at construction time
  80899. */
  80900. overrideMaterialSideOrientation: Nullable<number>;
  80901. /**
  80902. * Gets the source mesh (the one used to clone this one from)
  80903. */
  80904. readonly source: Nullable<Mesh>;
  80905. /**
  80906. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80907. */
  80908. isUnIndexed: boolean;
  80909. /**
  80910. * @constructor
  80911. * @param name The value used by scene.getMeshByName() to do a lookup.
  80912. * @param scene The scene to add this mesh to.
  80913. * @param parent The parent of this mesh, if it has one
  80914. * @param source An optional Mesh from which geometry is shared, cloned.
  80915. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80916. * When false, achieved by calling a clone(), also passing False.
  80917. * This will make creation of children, recursive.
  80918. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80919. */
  80920. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80921. /**
  80922. * Gets the class name
  80923. * @returns the string "Mesh".
  80924. */
  80925. getClassName(): string;
  80926. /** @hidden */
  80927. readonly _isMesh: boolean;
  80928. /**
  80929. * Returns a description of this mesh
  80930. * @param fullDetails define if full details about this mesh must be used
  80931. * @returns a descriptive string representing this mesh
  80932. */
  80933. toString(fullDetails?: boolean): string;
  80934. /** @hidden */
  80935. _unBindEffect(): void;
  80936. /**
  80937. * Gets a boolean indicating if this mesh has LOD
  80938. */
  80939. readonly hasLODLevels: boolean;
  80940. /**
  80941. * Gets the list of MeshLODLevel associated with the current mesh
  80942. * @returns an array of MeshLODLevel
  80943. */
  80944. getLODLevels(): MeshLODLevel[];
  80945. private _sortLODLevels;
  80946. /**
  80947. * Add a mesh as LOD level triggered at the given distance.
  80948. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80949. * @param distance The distance from the center of the object to show this level
  80950. * @param mesh The mesh to be added as LOD level (can be null)
  80951. * @return This mesh (for chaining)
  80952. */
  80953. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80954. /**
  80955. * Returns the LOD level mesh at the passed distance or null if not found.
  80956. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80957. * @param distance The distance from the center of the object to show this level
  80958. * @returns a Mesh or `null`
  80959. */
  80960. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80961. /**
  80962. * Remove a mesh from the LOD array
  80963. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80964. * @param mesh defines the mesh to be removed
  80965. * @return This mesh (for chaining)
  80966. */
  80967. removeLODLevel(mesh: Mesh): Mesh;
  80968. /**
  80969. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80970. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80971. * @param camera defines the camera to use to compute distance
  80972. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80973. * @return This mesh (for chaining)
  80974. */
  80975. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80976. /**
  80977. * Gets the mesh internal Geometry object
  80978. */
  80979. readonly geometry: Nullable<Geometry>;
  80980. /**
  80981. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80982. * @returns the total number of vertices
  80983. */
  80984. getTotalVertices(): number;
  80985. /**
  80986. * Returns the content of an associated vertex buffer
  80987. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80988. * - VertexBuffer.PositionKind
  80989. * - VertexBuffer.UVKind
  80990. * - VertexBuffer.UV2Kind
  80991. * - VertexBuffer.UV3Kind
  80992. * - VertexBuffer.UV4Kind
  80993. * - VertexBuffer.UV5Kind
  80994. * - VertexBuffer.UV6Kind
  80995. * - VertexBuffer.ColorKind
  80996. * - VertexBuffer.MatricesIndicesKind
  80997. * - VertexBuffer.MatricesIndicesExtraKind
  80998. * - VertexBuffer.MatricesWeightsKind
  80999. * - VertexBuffer.MatricesWeightsExtraKind
  81000. * @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
  81001. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  81002. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  81003. */
  81004. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81005. /**
  81006. * Returns the mesh VertexBuffer object from the requested `kind`
  81007. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81008. * - VertexBuffer.PositionKind
  81009. * - VertexBuffer.UVKind
  81010. * - VertexBuffer.UV2Kind
  81011. * - VertexBuffer.UV3Kind
  81012. * - VertexBuffer.UV4Kind
  81013. * - VertexBuffer.UV5Kind
  81014. * - VertexBuffer.UV6Kind
  81015. * - VertexBuffer.ColorKind
  81016. * - VertexBuffer.MatricesIndicesKind
  81017. * - VertexBuffer.MatricesIndicesExtraKind
  81018. * - VertexBuffer.MatricesWeightsKind
  81019. * - VertexBuffer.MatricesWeightsExtraKind
  81020. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81021. */
  81022. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81023. /**
  81024. * Tests if a specific vertex buffer is associated with this mesh
  81025. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81026. * - VertexBuffer.PositionKind
  81027. * - VertexBuffer.UVKind
  81028. * - VertexBuffer.UV2Kind
  81029. * - VertexBuffer.UV3Kind
  81030. * - VertexBuffer.UV4Kind
  81031. * - VertexBuffer.UV5Kind
  81032. * - VertexBuffer.UV6Kind
  81033. * - VertexBuffer.ColorKind
  81034. * - VertexBuffer.MatricesIndicesKind
  81035. * - VertexBuffer.MatricesIndicesExtraKind
  81036. * - VertexBuffer.MatricesWeightsKind
  81037. * - VertexBuffer.MatricesWeightsExtraKind
  81038. * @returns a boolean
  81039. */
  81040. isVerticesDataPresent(kind: string): boolean;
  81041. /**
  81042. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81043. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81044. * - VertexBuffer.PositionKind
  81045. * - VertexBuffer.UVKind
  81046. * - VertexBuffer.UV2Kind
  81047. * - VertexBuffer.UV3Kind
  81048. * - VertexBuffer.UV4Kind
  81049. * - VertexBuffer.UV5Kind
  81050. * - VertexBuffer.UV6Kind
  81051. * - VertexBuffer.ColorKind
  81052. * - VertexBuffer.MatricesIndicesKind
  81053. * - VertexBuffer.MatricesIndicesExtraKind
  81054. * - VertexBuffer.MatricesWeightsKind
  81055. * - VertexBuffer.MatricesWeightsExtraKind
  81056. * @returns a boolean
  81057. */
  81058. isVertexBufferUpdatable(kind: string): boolean;
  81059. /**
  81060. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81061. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81062. * - VertexBuffer.PositionKind
  81063. * - VertexBuffer.UVKind
  81064. * - VertexBuffer.UV2Kind
  81065. * - VertexBuffer.UV3Kind
  81066. * - VertexBuffer.UV4Kind
  81067. * - VertexBuffer.UV5Kind
  81068. * - VertexBuffer.UV6Kind
  81069. * - VertexBuffer.ColorKind
  81070. * - VertexBuffer.MatricesIndicesKind
  81071. * - VertexBuffer.MatricesIndicesExtraKind
  81072. * - VertexBuffer.MatricesWeightsKind
  81073. * - VertexBuffer.MatricesWeightsExtraKind
  81074. * @returns an array of strings
  81075. */
  81076. getVerticesDataKinds(): string[];
  81077. /**
  81078. * Returns a positive integer : the total number of indices in this mesh geometry.
  81079. * @returns the numner of indices or zero if the mesh has no geometry.
  81080. */
  81081. getTotalIndices(): number;
  81082. /**
  81083. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81084. * @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.
  81085. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81086. * @returns the indices array or an empty array if the mesh has no geometry
  81087. */
  81088. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81089. readonly isBlocked: boolean;
  81090. /**
  81091. * Determine if the current mesh is ready to be rendered
  81092. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81093. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81094. * @returns true if all associated assets are ready (material, textures, shaders)
  81095. */
  81096. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81097. /**
  81098. * 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.
  81099. */
  81100. readonly areNormalsFrozen: boolean;
  81101. /**
  81102. * 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.
  81103. * @returns the current mesh
  81104. */
  81105. freezeNormals(): Mesh;
  81106. /**
  81107. * 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
  81108. * @returns the current mesh
  81109. */
  81110. unfreezeNormals(): Mesh;
  81111. /**
  81112. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81113. */
  81114. overridenInstanceCount: number;
  81115. /** @hidden */
  81116. _preActivate(): Mesh;
  81117. /** @hidden */
  81118. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81119. /** @hidden */
  81120. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81121. /**
  81122. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81123. * This means the mesh underlying bounding box and sphere are recomputed.
  81124. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81125. * @returns the current mesh
  81126. */
  81127. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81128. /** @hidden */
  81129. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81130. /**
  81131. * This function will subdivide the mesh into multiple submeshes
  81132. * @param count defines the expected number of submeshes
  81133. */
  81134. subdivide(count: number): void;
  81135. /**
  81136. * Copy a FloatArray into a specific associated vertex buffer
  81137. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81138. * - VertexBuffer.PositionKind
  81139. * - VertexBuffer.UVKind
  81140. * - VertexBuffer.UV2Kind
  81141. * - VertexBuffer.UV3Kind
  81142. * - VertexBuffer.UV4Kind
  81143. * - VertexBuffer.UV5Kind
  81144. * - VertexBuffer.UV6Kind
  81145. * - VertexBuffer.ColorKind
  81146. * - VertexBuffer.MatricesIndicesKind
  81147. * - VertexBuffer.MatricesIndicesExtraKind
  81148. * - VertexBuffer.MatricesWeightsKind
  81149. * - VertexBuffer.MatricesWeightsExtraKind
  81150. * @param data defines the data source
  81151. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81152. * @param stride defines the data stride size (can be null)
  81153. * @returns the current mesh
  81154. */
  81155. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81156. /**
  81157. * Flags an associated vertex buffer as updatable
  81158. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81159. * - VertexBuffer.PositionKind
  81160. * - VertexBuffer.UVKind
  81161. * - VertexBuffer.UV2Kind
  81162. * - VertexBuffer.UV3Kind
  81163. * - VertexBuffer.UV4Kind
  81164. * - VertexBuffer.UV5Kind
  81165. * - VertexBuffer.UV6Kind
  81166. * - VertexBuffer.ColorKind
  81167. * - VertexBuffer.MatricesIndicesKind
  81168. * - VertexBuffer.MatricesIndicesExtraKind
  81169. * - VertexBuffer.MatricesWeightsKind
  81170. * - VertexBuffer.MatricesWeightsExtraKind
  81171. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81172. */
  81173. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81174. /**
  81175. * Sets the mesh global Vertex Buffer
  81176. * @param buffer defines the buffer to use
  81177. * @returns the current mesh
  81178. */
  81179. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81180. /**
  81181. * Update a specific associated vertex buffer
  81182. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81183. * - VertexBuffer.PositionKind
  81184. * - VertexBuffer.UVKind
  81185. * - VertexBuffer.UV2Kind
  81186. * - VertexBuffer.UV3Kind
  81187. * - VertexBuffer.UV4Kind
  81188. * - VertexBuffer.UV5Kind
  81189. * - VertexBuffer.UV6Kind
  81190. * - VertexBuffer.ColorKind
  81191. * - VertexBuffer.MatricesIndicesKind
  81192. * - VertexBuffer.MatricesIndicesExtraKind
  81193. * - VertexBuffer.MatricesWeightsKind
  81194. * - VertexBuffer.MatricesWeightsExtraKind
  81195. * @param data defines the data source
  81196. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81197. * @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)
  81198. * @returns the current mesh
  81199. */
  81200. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81201. /**
  81202. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81203. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81204. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81205. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81206. * @returns the current mesh
  81207. */
  81208. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81209. /**
  81210. * Creates a un-shared specific occurence of the geometry for the mesh.
  81211. * @returns the current mesh
  81212. */
  81213. makeGeometryUnique(): Mesh;
  81214. /**
  81215. * Set the index buffer of this mesh
  81216. * @param indices defines the source data
  81217. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81218. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81219. * @returns the current mesh
  81220. */
  81221. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81222. /**
  81223. * Update the current index buffer
  81224. * @param indices defines the source data
  81225. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81226. * @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)
  81227. * @returns the current mesh
  81228. */
  81229. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81230. /**
  81231. * Invert the geometry to move from a right handed system to a left handed one.
  81232. * @returns the current mesh
  81233. */
  81234. toLeftHanded(): Mesh;
  81235. /** @hidden */
  81236. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81237. /** @hidden */
  81238. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81239. /**
  81240. * Registers for this mesh a javascript function called just before the rendering process
  81241. * @param func defines the function to call before rendering this mesh
  81242. * @returns the current mesh
  81243. */
  81244. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81245. /**
  81246. * Disposes a previously registered javascript function called before the rendering
  81247. * @param func defines the function to remove
  81248. * @returns the current mesh
  81249. */
  81250. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81251. /**
  81252. * Registers for this mesh a javascript function called just after the rendering is complete
  81253. * @param func defines the function to call after rendering this mesh
  81254. * @returns the current mesh
  81255. */
  81256. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81257. /**
  81258. * Disposes a previously registered javascript function called after the rendering.
  81259. * @param func defines the function to remove
  81260. * @returns the current mesh
  81261. */
  81262. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81263. /** @hidden */
  81264. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81265. /** @hidden */
  81266. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81267. /** @hidden */
  81268. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81269. /** @hidden */
  81270. _freeze(): void;
  81271. /** @hidden */
  81272. _unFreeze(): void;
  81273. /**
  81274. * 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
  81275. * @param subMesh defines the subMesh to render
  81276. * @param enableAlphaMode defines if alpha mode can be changed
  81277. * @returns the current mesh
  81278. */
  81279. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81280. private _onBeforeDraw;
  81281. /**
  81282. * Renormalize the mesh and patch it up if there are no weights
  81283. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81284. * However in the case of zero weights then we set just a single influence to 1.
  81285. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81286. */
  81287. cleanMatrixWeights(): void;
  81288. private normalizeSkinFourWeights;
  81289. private normalizeSkinWeightsAndExtra;
  81290. /**
  81291. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81292. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81293. * the user know there was an issue with importing the mesh
  81294. * @returns a validation object with skinned, valid and report string
  81295. */
  81296. validateSkinning(): {
  81297. skinned: boolean;
  81298. valid: boolean;
  81299. report: string;
  81300. };
  81301. /** @hidden */
  81302. _checkDelayState(): Mesh;
  81303. private _queueLoad;
  81304. /**
  81305. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81306. * A mesh is in the frustum if its bounding box intersects the frustum
  81307. * @param frustumPlanes defines the frustum to test
  81308. * @returns true if the mesh is in the frustum planes
  81309. */
  81310. isInFrustum(frustumPlanes: Plane[]): boolean;
  81311. /**
  81312. * Sets the mesh material by the material or multiMaterial `id` property
  81313. * @param id is a string identifying the material or the multiMaterial
  81314. * @returns the current mesh
  81315. */
  81316. setMaterialByID(id: string): Mesh;
  81317. /**
  81318. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81319. * @returns an array of IAnimatable
  81320. */
  81321. getAnimatables(): IAnimatable[];
  81322. /**
  81323. * Modifies the mesh geometry according to the passed transformation matrix.
  81324. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81325. * The mesh normals are modified using the same transformation.
  81326. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81327. * @param transform defines the transform matrix to use
  81328. * @see http://doc.babylonjs.com/resources/baking_transformations
  81329. * @returns the current mesh
  81330. */
  81331. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81332. /**
  81333. * Modifies the mesh geometry according to its own current World Matrix.
  81334. * The mesh World Matrix is then reset.
  81335. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81336. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81337. * @see http://doc.babylonjs.com/resources/baking_transformations
  81338. * @returns the current mesh
  81339. */
  81340. bakeCurrentTransformIntoVertices(): Mesh;
  81341. /** @hidden */
  81342. readonly _positions: Nullable<Vector3[]>;
  81343. /** @hidden */
  81344. _resetPointsArrayCache(): Mesh;
  81345. /** @hidden */
  81346. _generatePointsArray(): boolean;
  81347. /**
  81348. * Returns a new Mesh object generated from the current mesh properties.
  81349. * This method must not get confused with createInstance()
  81350. * @param name is a string, the name given to the new mesh
  81351. * @param newParent can be any Node object (default `null`)
  81352. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81353. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81354. * @returns a new mesh
  81355. */
  81356. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81357. /**
  81358. * Releases resources associated with this mesh.
  81359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81361. */
  81362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81363. /**
  81364. * Modifies the mesh geometry according to a displacement map.
  81365. * 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.
  81366. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81367. * @param url is a string, the URL from the image file is to be downloaded.
  81368. * @param minHeight is the lower limit of the displacement.
  81369. * @param maxHeight is the upper limit of the displacement.
  81370. * @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.
  81371. * @param uvOffset is an optional vector2 used to offset UV.
  81372. * @param uvScale is an optional vector2 used to scale UV.
  81373. * @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.
  81374. * @returns the Mesh.
  81375. */
  81376. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81377. /**
  81378. * Modifies the mesh geometry according to a displacementMap buffer.
  81379. * 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.
  81380. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81381. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81382. * @param heightMapWidth is the width of the buffer image.
  81383. * @param heightMapHeight is the height of the buffer image.
  81384. * @param minHeight is the lower limit of the displacement.
  81385. * @param maxHeight is the upper limit of the displacement.
  81386. * @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.
  81387. * @param uvOffset is an optional vector2 used to offset UV.
  81388. * @param uvScale is an optional vector2 used to scale UV.
  81389. * @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.
  81390. * @returns the Mesh.
  81391. */
  81392. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81393. /**
  81394. * Modify the mesh to get a flat shading rendering.
  81395. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81396. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81397. * @returns current mesh
  81398. */
  81399. convertToFlatShadedMesh(): Mesh;
  81400. /**
  81401. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81402. * In other words, more vertices, no more indices and a single bigger VBO.
  81403. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81404. * @returns current mesh
  81405. */
  81406. convertToUnIndexedMesh(): Mesh;
  81407. /**
  81408. * Inverses facet orientations.
  81409. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81410. * @param flipNormals will also inverts the normals
  81411. * @returns current mesh
  81412. */
  81413. flipFaces(flipNormals?: boolean): Mesh;
  81414. /**
  81415. * Increase the number of facets and hence vertices in a mesh
  81416. * Vertex normals are interpolated from existing vertex normals
  81417. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81418. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81419. */
  81420. increaseVertices(numberPerEdge: number): void;
  81421. /**
  81422. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81423. * This will undo any application of covertToFlatShadedMesh
  81424. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81425. */
  81426. forceSharedVertices(): void;
  81427. /** @hidden */
  81428. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81429. /** @hidden */
  81430. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81431. /**
  81432. * Creates a new InstancedMesh object from the mesh model.
  81433. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81434. * @param name defines the name of the new instance
  81435. * @returns a new InstancedMesh
  81436. */
  81437. createInstance(name: string): InstancedMesh;
  81438. /**
  81439. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81440. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81441. * @returns the current mesh
  81442. */
  81443. synchronizeInstances(): Mesh;
  81444. /**
  81445. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81446. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81447. * This should be used together with the simplification to avoid disappearing triangles.
  81448. * @param successCallback an optional success callback to be called after the optimization finished.
  81449. * @returns the current mesh
  81450. */
  81451. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81452. /**
  81453. * Serialize current mesh
  81454. * @param serializationObject defines the object which will receive the serialization data
  81455. */
  81456. serialize(serializationObject: any): void;
  81457. /** @hidden */
  81458. _syncGeometryWithMorphTargetManager(): void;
  81459. /** @hidden */
  81460. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81461. /**
  81462. * Returns a new Mesh object parsed from the source provided.
  81463. * @param parsedMesh is the source
  81464. * @param scene defines the hosting scene
  81465. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81466. * @returns a new Mesh
  81467. */
  81468. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81469. /**
  81470. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81471. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81472. * @param name defines the name of the mesh to create
  81473. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81474. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81475. * @param closePath creates a seam between the first and the last points of each path of the path array
  81476. * @param offset is taken in account only if the `pathArray` is containing a single path
  81477. * @param scene defines the hosting scene
  81478. * @param updatable defines if the mesh must be flagged as updatable
  81479. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81480. * @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)
  81481. * @returns a new Mesh
  81482. */
  81483. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81484. /**
  81485. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81486. * @param name defines the name of the mesh to create
  81487. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81488. * @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
  81489. * @param scene defines the hosting scene
  81490. * @param updatable defines if the mesh must be flagged as updatable
  81491. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81492. * @returns a new Mesh
  81493. */
  81494. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81495. /**
  81496. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81497. * @param name defines the name of the mesh to create
  81498. * @param size sets the size (float) of each box side (default 1)
  81499. * @param scene defines the hosting scene
  81500. * @param updatable defines if the mesh must be flagged as updatable
  81501. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81502. * @returns a new Mesh
  81503. */
  81504. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81505. /**
  81506. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81507. * @param name defines the name of the mesh to create
  81508. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81509. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81510. * @param scene defines the hosting scene
  81511. * @param updatable defines if the mesh must be flagged as updatable
  81512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81513. * @returns a new Mesh
  81514. */
  81515. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81516. /**
  81517. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81518. * @param name defines the name of the mesh to create
  81519. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81520. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81521. * @param scene defines the hosting scene
  81522. * @returns a new Mesh
  81523. */
  81524. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81525. /**
  81526. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81527. * @param name defines the name of the mesh to create
  81528. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81529. * @param diameterTop set the top cap diameter (floats, default 1)
  81530. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81531. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81532. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81533. * @param scene defines the hosting scene
  81534. * @param updatable defines if the mesh must be flagged as updatable
  81535. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81536. * @returns a new Mesh
  81537. */
  81538. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81539. /**
  81540. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81541. * @param name defines the name of the mesh to create
  81542. * @param diameter sets the diameter size (float) of the torus (default 1)
  81543. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81544. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81545. * @param scene defines the hosting scene
  81546. * @param updatable defines if the mesh must be flagged as updatable
  81547. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81548. * @returns a new Mesh
  81549. */
  81550. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81551. /**
  81552. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81553. * @param name defines the name of the mesh to create
  81554. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81555. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81556. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81557. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81558. * @param p the number of windings on X axis (positive integers, default 2)
  81559. * @param q the number of windings on Y axis (positive integers, default 3)
  81560. * @param scene defines the hosting scene
  81561. * @param updatable defines if the mesh must be flagged as updatable
  81562. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81563. * @returns a new Mesh
  81564. */
  81565. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81566. /**
  81567. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81568. * @param name defines the name of the mesh to create
  81569. * @param points is an array successive Vector3
  81570. * @param scene defines the hosting scene
  81571. * @param updatable defines if the mesh must be flagged as updatable
  81572. * @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).
  81573. * @returns a new Mesh
  81574. */
  81575. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81576. /**
  81577. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81578. * @param name defines the name of the mesh to create
  81579. * @param points is an array successive Vector3
  81580. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81581. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81582. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81583. * @param scene defines the hosting scene
  81584. * @param updatable defines if the mesh must be flagged as updatable
  81585. * @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)
  81586. * @returns a new Mesh
  81587. */
  81588. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81589. /**
  81590. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81591. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81592. * 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.
  81593. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81594. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81595. * Remember you can only change the shape positions, not their number when updating a polygon.
  81596. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81597. * @param name defines the name of the mesh to create
  81598. * @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
  81599. * @param scene defines the hosting scene
  81600. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81601. * @param updatable defines if the mesh must be flagged as updatable
  81602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81603. * @param earcutInjection can be used to inject your own earcut reference
  81604. * @returns a new Mesh
  81605. */
  81606. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81607. /**
  81608. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81609. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81610. * @param name defines the name of the mesh to create
  81611. * @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
  81612. * @param depth defines the height of extrusion
  81613. * @param scene defines the hosting scene
  81614. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81615. * @param updatable defines if the mesh must be flagged as updatable
  81616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81617. * @param earcutInjection can be used to inject your own earcut reference
  81618. * @returns a new Mesh
  81619. */
  81620. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81621. /**
  81622. * Creates an extruded shape mesh.
  81623. * 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
  81624. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81625. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81626. * @param name defines the name of the mesh to create
  81627. * @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
  81628. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81629. * @param scale is the value to scale the shape
  81630. * @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
  81631. * @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
  81632. * @param scene defines the hosting scene
  81633. * @param updatable defines if the mesh must be flagged as updatable
  81634. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81635. * @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)
  81636. * @returns a new Mesh
  81637. */
  81638. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81639. /**
  81640. * Creates an custom extruded shape mesh.
  81641. * The custom extrusion is a parametric shape.
  81642. * It has no predefined shape. Its final shape will depend on the input parameters.
  81643. * Please consider using the same method from the MeshBuilder class instead
  81644. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81645. * @param name defines the name of the mesh to create
  81646. * @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
  81647. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81648. * @param scaleFunction is a custom Javascript function called on each path point
  81649. * @param rotationFunction is a custom Javascript function called on each path point
  81650. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81651. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81652. * @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
  81653. * @param scene defines the hosting scene
  81654. * @param updatable defines if the mesh must be flagged as updatable
  81655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81656. * @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)
  81657. * @returns a new Mesh
  81658. */
  81659. 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;
  81660. /**
  81661. * Creates lathe mesh.
  81662. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81663. * Please consider using the same method from the MeshBuilder class instead
  81664. * @param name defines the name of the mesh to create
  81665. * @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
  81666. * @param radius is the radius value of the lathe
  81667. * @param tessellation is the side number of the lathe.
  81668. * @param scene defines the hosting scene
  81669. * @param updatable defines if the mesh must be flagged as updatable
  81670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81671. * @returns a new Mesh
  81672. */
  81673. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81674. /**
  81675. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81676. * @param name defines the name of the mesh to create
  81677. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81678. * @param scene defines the hosting scene
  81679. * @param updatable defines if the mesh must be flagged as updatable
  81680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81681. * @returns a new Mesh
  81682. */
  81683. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81684. /**
  81685. * Creates a ground mesh.
  81686. * Please consider using the same method from the MeshBuilder class instead
  81687. * @param name defines the name of the mesh to create
  81688. * @param width set the width of the ground
  81689. * @param height set the height of the ground
  81690. * @param subdivisions sets the number of subdivisions per side
  81691. * @param scene defines the hosting scene
  81692. * @param updatable defines if the mesh must be flagged as updatable
  81693. * @returns a new Mesh
  81694. */
  81695. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81696. /**
  81697. * Creates a tiled ground mesh.
  81698. * Please consider using the same method from the MeshBuilder class instead
  81699. * @param name defines the name of the mesh to create
  81700. * @param xmin set the ground minimum X coordinate
  81701. * @param zmin set the ground minimum Y coordinate
  81702. * @param xmax set the ground maximum X coordinate
  81703. * @param zmax set the ground maximum Z coordinate
  81704. * @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
  81705. * @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
  81706. * @param scene defines the hosting scene
  81707. * @param updatable defines if the mesh must be flagged as updatable
  81708. * @returns a new Mesh
  81709. */
  81710. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81711. w: number;
  81712. h: number;
  81713. }, precision: {
  81714. w: number;
  81715. h: number;
  81716. }, scene: Scene, updatable?: boolean): Mesh;
  81717. /**
  81718. * Creates a ground mesh from a height map.
  81719. * Please consider using the same method from the MeshBuilder class instead
  81720. * @see http://doc.babylonjs.com/babylon101/height_map
  81721. * @param name defines the name of the mesh to create
  81722. * @param url sets the URL of the height map image resource
  81723. * @param width set the ground width size
  81724. * @param height set the ground height size
  81725. * @param subdivisions sets the number of subdivision per side
  81726. * @param minHeight is the minimum altitude on the ground
  81727. * @param maxHeight is the maximum altitude on the ground
  81728. * @param scene defines the hosting scene
  81729. * @param updatable defines if the mesh must be flagged as updatable
  81730. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81731. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81732. * @returns a new Mesh
  81733. */
  81734. 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;
  81735. /**
  81736. * Creates a tube mesh.
  81737. * The tube is a parametric shape.
  81738. * It has no predefined shape. Its final shape will depend on the input parameters.
  81739. * Please consider using the same method from the MeshBuilder class instead
  81740. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81741. * @param name defines the name of the mesh to create
  81742. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81743. * @param radius sets the tube radius size
  81744. * @param tessellation is the number of sides on the tubular surface
  81745. * @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
  81746. * @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
  81747. * @param scene defines the hosting scene
  81748. * @param updatable defines if the mesh must be flagged as updatable
  81749. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81750. * @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)
  81751. * @returns a new Mesh
  81752. */
  81753. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81754. (i: number, distance: number): number;
  81755. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81756. /**
  81757. * Creates a polyhedron mesh.
  81758. * Please consider using the same method from the MeshBuilder class instead.
  81759. * * 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
  81760. * * The parameter `size` (positive float, default 1) sets the polygon size
  81761. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81762. * * 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`
  81763. * * 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
  81764. * * 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)`)
  81765. * * 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
  81766. * * 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
  81767. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81768. * * If you create a double-sided mesh, you can choose what parts of 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
  81769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81770. * @param name defines the name of the mesh to create
  81771. * @param options defines the options used to create the mesh
  81772. * @param scene defines the hosting scene
  81773. * @returns a new Mesh
  81774. */
  81775. static CreatePolyhedron(name: string, options: {
  81776. type?: number;
  81777. size?: number;
  81778. sizeX?: number;
  81779. sizeY?: number;
  81780. sizeZ?: number;
  81781. custom?: any;
  81782. faceUV?: Vector4[];
  81783. faceColors?: Color4[];
  81784. updatable?: boolean;
  81785. sideOrientation?: number;
  81786. }, scene: Scene): Mesh;
  81787. /**
  81788. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81789. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81790. * * 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`)
  81791. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81792. * * 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
  81793. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81794. * * If you create a double-sided mesh, you can choose what parts of 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
  81795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81796. * @param name defines the name of the mesh
  81797. * @param options defines the options used to create the mesh
  81798. * @param scene defines the hosting scene
  81799. * @returns a new Mesh
  81800. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81801. */
  81802. static CreateIcoSphere(name: string, options: {
  81803. radius?: number;
  81804. flat?: boolean;
  81805. subdivisions?: number;
  81806. sideOrientation?: number;
  81807. updatable?: boolean;
  81808. }, scene: Scene): Mesh;
  81809. /**
  81810. * Creates a decal mesh.
  81811. * Please consider using the same method from the MeshBuilder class instead.
  81812. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81813. * @param name defines the name of the mesh
  81814. * @param sourceMesh defines the mesh receiving the decal
  81815. * @param position sets the position of the decal in world coordinates
  81816. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81817. * @param size sets the decal scaling
  81818. * @param angle sets the angle to rotate the decal
  81819. * @returns a new Mesh
  81820. */
  81821. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81822. /**
  81823. * Prepare internal position array for software CPU skinning
  81824. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81825. */
  81826. setPositionsForCPUSkinning(): Float32Array;
  81827. /**
  81828. * Prepare internal normal array for software CPU skinning
  81829. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81830. */
  81831. setNormalsForCPUSkinning(): Float32Array;
  81832. /**
  81833. * Updates the vertex buffer by applying transformation from the bones
  81834. * @param skeleton defines the skeleton to apply to current mesh
  81835. * @returns the current mesh
  81836. */
  81837. applySkeleton(skeleton: Skeleton): Mesh;
  81838. /**
  81839. * 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
  81840. * @param meshes defines the list of meshes to scan
  81841. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81842. */
  81843. static MinMax(meshes: AbstractMesh[]): {
  81844. min: Vector3;
  81845. max: Vector3;
  81846. };
  81847. /**
  81848. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81849. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81850. * @returns a vector3
  81851. */
  81852. static Center(meshesOrMinMaxVector: {
  81853. min: Vector3;
  81854. max: Vector3;
  81855. } | AbstractMesh[]): Vector3;
  81856. /**
  81857. * Merge the array of meshes into a single mesh for performance reasons.
  81858. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81859. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81860. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81861. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81862. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81863. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81864. * @returns a new mesh
  81865. */
  81866. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81867. /** @hidden */
  81868. addInstance(instance: InstancedMesh): void;
  81869. /** @hidden */
  81870. removeInstance(instance: InstancedMesh): void;
  81871. }
  81872. }
  81873. declare module BABYLON {
  81874. /**
  81875. * Base class for the main features of a material in Babylon.js
  81876. */
  81877. export class Material implements IAnimatable {
  81878. /**
  81879. * Returns the triangle fill mode
  81880. */
  81881. static readonly TriangleFillMode: number;
  81882. /**
  81883. * Returns the wireframe mode
  81884. */
  81885. static readonly WireFrameFillMode: number;
  81886. /**
  81887. * Returns the point fill mode
  81888. */
  81889. static readonly PointFillMode: number;
  81890. /**
  81891. * Returns the point list draw mode
  81892. */
  81893. static readonly PointListDrawMode: number;
  81894. /**
  81895. * Returns the line list draw mode
  81896. */
  81897. static readonly LineListDrawMode: number;
  81898. /**
  81899. * Returns the line loop draw mode
  81900. */
  81901. static readonly LineLoopDrawMode: number;
  81902. /**
  81903. * Returns the line strip draw mode
  81904. */
  81905. static readonly LineStripDrawMode: number;
  81906. /**
  81907. * Returns the triangle strip draw mode
  81908. */
  81909. static readonly TriangleStripDrawMode: number;
  81910. /**
  81911. * Returns the triangle fan draw mode
  81912. */
  81913. static readonly TriangleFanDrawMode: number;
  81914. /**
  81915. * Stores the clock-wise side orientation
  81916. */
  81917. static readonly ClockWiseSideOrientation: number;
  81918. /**
  81919. * Stores the counter clock-wise side orientation
  81920. */
  81921. static readonly CounterClockWiseSideOrientation: number;
  81922. /**
  81923. * The dirty texture flag value
  81924. */
  81925. static readonly TextureDirtyFlag: number;
  81926. /**
  81927. * The dirty light flag value
  81928. */
  81929. static readonly LightDirtyFlag: number;
  81930. /**
  81931. * The dirty fresnel flag value
  81932. */
  81933. static readonly FresnelDirtyFlag: number;
  81934. /**
  81935. * The dirty attribute flag value
  81936. */
  81937. static readonly AttributesDirtyFlag: number;
  81938. /**
  81939. * The dirty misc flag value
  81940. */
  81941. static readonly MiscDirtyFlag: number;
  81942. /**
  81943. * The all dirty flag value
  81944. */
  81945. static readonly AllDirtyFlag: number;
  81946. /**
  81947. * The ID of the material
  81948. */
  81949. id: string;
  81950. /**
  81951. * Gets or sets the unique id of the material
  81952. */
  81953. uniqueId: number;
  81954. /**
  81955. * The name of the material
  81956. */
  81957. name: string;
  81958. /**
  81959. * Gets or sets user defined metadata
  81960. */
  81961. metadata: any;
  81962. /**
  81963. * For internal use only. Please do not use.
  81964. */
  81965. reservedDataStore: any;
  81966. /**
  81967. * Specifies if the ready state should be checked on each call
  81968. */
  81969. checkReadyOnEveryCall: boolean;
  81970. /**
  81971. * Specifies if the ready state should be checked once
  81972. */
  81973. checkReadyOnlyOnce: boolean;
  81974. /**
  81975. * The state of the material
  81976. */
  81977. state: string;
  81978. /**
  81979. * The alpha value of the material
  81980. */
  81981. protected _alpha: number;
  81982. /**
  81983. * List of inspectable custom properties (used by the Inspector)
  81984. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81985. */
  81986. inspectableCustomProperties: IInspectable[];
  81987. /**
  81988. * Sets the alpha value of the material
  81989. */
  81990. /**
  81991. * Gets the alpha value of the material
  81992. */
  81993. alpha: number;
  81994. /**
  81995. * Specifies if back face culling is enabled
  81996. */
  81997. protected _backFaceCulling: boolean;
  81998. /**
  81999. * Sets the back-face culling state
  82000. */
  82001. /**
  82002. * Gets the back-face culling state
  82003. */
  82004. backFaceCulling: boolean;
  82005. /**
  82006. * Stores the value for side orientation
  82007. */
  82008. sideOrientation: number;
  82009. /**
  82010. * Callback triggered when the material is compiled
  82011. */
  82012. onCompiled: Nullable<(effect: Effect) => void>;
  82013. /**
  82014. * Callback triggered when an error occurs
  82015. */
  82016. onError: Nullable<(effect: Effect, errors: string) => void>;
  82017. /**
  82018. * Callback triggered to get the render target textures
  82019. */
  82020. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82021. /**
  82022. * Gets a boolean indicating that current material needs to register RTT
  82023. */
  82024. readonly hasRenderTargetTextures: boolean;
  82025. /**
  82026. * Specifies if the material should be serialized
  82027. */
  82028. doNotSerialize: boolean;
  82029. /**
  82030. * @hidden
  82031. */
  82032. _storeEffectOnSubMeshes: boolean;
  82033. /**
  82034. * Stores the animations for the material
  82035. */
  82036. animations: Nullable<Array<Animation>>;
  82037. /**
  82038. * An event triggered when the material is disposed
  82039. */
  82040. onDisposeObservable: Observable<Material>;
  82041. /**
  82042. * An observer which watches for dispose events
  82043. */
  82044. private _onDisposeObserver;
  82045. private _onUnBindObservable;
  82046. /**
  82047. * Called during a dispose event
  82048. */
  82049. onDispose: () => void;
  82050. private _onBindObservable;
  82051. /**
  82052. * An event triggered when the material is bound
  82053. */
  82054. readonly onBindObservable: Observable<AbstractMesh>;
  82055. /**
  82056. * An observer which watches for bind events
  82057. */
  82058. private _onBindObserver;
  82059. /**
  82060. * Called during a bind event
  82061. */
  82062. onBind: (Mesh: AbstractMesh) => void;
  82063. /**
  82064. * An event triggered when the material is unbound
  82065. */
  82066. readonly onUnBindObservable: Observable<Material>;
  82067. /**
  82068. * Stores the value of the alpha mode
  82069. */
  82070. private _alphaMode;
  82071. /**
  82072. * Sets the value of the alpha mode.
  82073. *
  82074. * | Value | Type | Description |
  82075. * | --- | --- | --- |
  82076. * | 0 | ALPHA_DISABLE | |
  82077. * | 1 | ALPHA_ADD | |
  82078. * | 2 | ALPHA_COMBINE | |
  82079. * | 3 | ALPHA_SUBTRACT | |
  82080. * | 4 | ALPHA_MULTIPLY | |
  82081. * | 5 | ALPHA_MAXIMIZED | |
  82082. * | 6 | ALPHA_ONEONE | |
  82083. * | 7 | ALPHA_PREMULTIPLIED | |
  82084. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82085. * | 9 | ALPHA_INTERPOLATE | |
  82086. * | 10 | ALPHA_SCREENMODE | |
  82087. *
  82088. */
  82089. /**
  82090. * Gets the value of the alpha mode
  82091. */
  82092. alphaMode: number;
  82093. /**
  82094. * Stores the state of the need depth pre-pass value
  82095. */
  82096. private _needDepthPrePass;
  82097. /**
  82098. * Sets the need depth pre-pass value
  82099. */
  82100. /**
  82101. * Gets the depth pre-pass value
  82102. */
  82103. needDepthPrePass: boolean;
  82104. /**
  82105. * Specifies if depth writing should be disabled
  82106. */
  82107. disableDepthWrite: boolean;
  82108. /**
  82109. * Specifies if depth writing should be forced
  82110. */
  82111. forceDepthWrite: boolean;
  82112. /**
  82113. * Specifies if there should be a separate pass for culling
  82114. */
  82115. separateCullingPass: boolean;
  82116. /**
  82117. * Stores the state specifing if fog should be enabled
  82118. */
  82119. private _fogEnabled;
  82120. /**
  82121. * Sets the state for enabling fog
  82122. */
  82123. /**
  82124. * Gets the value of the fog enabled state
  82125. */
  82126. fogEnabled: boolean;
  82127. /**
  82128. * Stores the size of points
  82129. */
  82130. pointSize: number;
  82131. /**
  82132. * Stores the z offset value
  82133. */
  82134. zOffset: number;
  82135. /**
  82136. * Gets a value specifying if wireframe mode is enabled
  82137. */
  82138. /**
  82139. * Sets the state of wireframe mode
  82140. */
  82141. wireframe: boolean;
  82142. /**
  82143. * Gets the value specifying if point clouds are enabled
  82144. */
  82145. /**
  82146. * Sets the state of point cloud mode
  82147. */
  82148. pointsCloud: boolean;
  82149. /**
  82150. * Gets the material fill mode
  82151. */
  82152. /**
  82153. * Sets the material fill mode
  82154. */
  82155. fillMode: number;
  82156. /**
  82157. * @hidden
  82158. * Stores the effects for the material
  82159. */
  82160. _effect: Nullable<Effect>;
  82161. /**
  82162. * @hidden
  82163. * Specifies if the material was previously ready
  82164. */
  82165. _wasPreviouslyReady: boolean;
  82166. /**
  82167. * Specifies if uniform buffers should be used
  82168. */
  82169. private _useUBO;
  82170. /**
  82171. * Stores a reference to the scene
  82172. */
  82173. private _scene;
  82174. /**
  82175. * Stores the fill mode state
  82176. */
  82177. private _fillMode;
  82178. /**
  82179. * Specifies if the depth write state should be cached
  82180. */
  82181. private _cachedDepthWriteState;
  82182. /**
  82183. * Stores the uniform buffer
  82184. */
  82185. protected _uniformBuffer: UniformBuffer;
  82186. /** @hidden */
  82187. _indexInSceneMaterialArray: number;
  82188. /** @hidden */
  82189. meshMap: Nullable<{
  82190. [id: string]: AbstractMesh | undefined;
  82191. }>;
  82192. /**
  82193. * Creates a material instance
  82194. * @param name defines the name of the material
  82195. * @param scene defines the scene to reference
  82196. * @param doNotAdd specifies if the material should be added to the scene
  82197. */
  82198. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82199. /**
  82200. * Returns a string representation of the current material
  82201. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82202. * @returns a string with material information
  82203. */
  82204. toString(fullDetails?: boolean): string;
  82205. /**
  82206. * Gets the class name of the material
  82207. * @returns a string with the class name of the material
  82208. */
  82209. getClassName(): string;
  82210. /**
  82211. * Specifies if updates for the material been locked
  82212. */
  82213. readonly isFrozen: boolean;
  82214. /**
  82215. * Locks updates for the material
  82216. */
  82217. freeze(): void;
  82218. /**
  82219. * Unlocks updates for the material
  82220. */
  82221. unfreeze(): void;
  82222. /**
  82223. * Specifies if the material is ready to be used
  82224. * @param mesh defines the mesh to check
  82225. * @param useInstances specifies if instances should be used
  82226. * @returns a boolean indicating if the material is ready to be used
  82227. */
  82228. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82229. /**
  82230. * Specifies that the submesh is ready to be used
  82231. * @param mesh defines the mesh to check
  82232. * @param subMesh defines which submesh to check
  82233. * @param useInstances specifies that instances should be used
  82234. * @returns a boolean indicating that the submesh is ready or not
  82235. */
  82236. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82237. /**
  82238. * Returns the material effect
  82239. * @returns the effect associated with the material
  82240. */
  82241. getEffect(): Nullable<Effect>;
  82242. /**
  82243. * Returns the current scene
  82244. * @returns a Scene
  82245. */
  82246. getScene(): Scene;
  82247. /**
  82248. * Specifies if the material will require alpha blending
  82249. * @returns a boolean specifying if alpha blending is needed
  82250. */
  82251. needAlphaBlending(): boolean;
  82252. /**
  82253. * Specifies if the mesh will require alpha blending
  82254. * @param mesh defines the mesh to check
  82255. * @returns a boolean specifying if alpha blending is needed for the mesh
  82256. */
  82257. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82258. /**
  82259. * Specifies if this material should be rendered in alpha test mode
  82260. * @returns a boolean specifying if an alpha test is needed.
  82261. */
  82262. needAlphaTesting(): boolean;
  82263. /**
  82264. * Gets the texture used for the alpha test
  82265. * @returns the texture to use for alpha testing
  82266. */
  82267. getAlphaTestTexture(): Nullable<BaseTexture>;
  82268. /**
  82269. * Marks the material to indicate that it needs to be re-calculated
  82270. */
  82271. markDirty(): void;
  82272. /** @hidden */
  82273. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82274. /**
  82275. * Binds the material to the mesh
  82276. * @param world defines the world transformation matrix
  82277. * @param mesh defines the mesh to bind the material to
  82278. */
  82279. bind(world: Matrix, mesh?: Mesh): void;
  82280. /**
  82281. * Binds the submesh to the material
  82282. * @param world defines the world transformation matrix
  82283. * @param mesh defines the mesh containing the submesh
  82284. * @param subMesh defines the submesh to bind the material to
  82285. */
  82286. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82287. /**
  82288. * Binds the world matrix to the material
  82289. * @param world defines the world transformation matrix
  82290. */
  82291. bindOnlyWorldMatrix(world: Matrix): void;
  82292. /**
  82293. * Binds the scene's uniform buffer to the effect.
  82294. * @param effect defines the effect to bind to the scene uniform buffer
  82295. * @param sceneUbo defines the uniform buffer storing scene data
  82296. */
  82297. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82298. /**
  82299. * Binds the view matrix to the effect
  82300. * @param effect defines the effect to bind the view matrix to
  82301. */
  82302. bindView(effect: Effect): void;
  82303. /**
  82304. * Binds the view projection matrix to the effect
  82305. * @param effect defines the effect to bind the view projection matrix to
  82306. */
  82307. bindViewProjection(effect: Effect): void;
  82308. /**
  82309. * Specifies if material alpha testing should be turned on for the mesh
  82310. * @param mesh defines the mesh to check
  82311. */
  82312. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82313. /**
  82314. * Processes to execute after binding the material to a mesh
  82315. * @param mesh defines the rendered mesh
  82316. */
  82317. protected _afterBind(mesh?: Mesh): void;
  82318. /**
  82319. * Unbinds the material from the mesh
  82320. */
  82321. unbind(): void;
  82322. /**
  82323. * Gets the active textures from the material
  82324. * @returns an array of textures
  82325. */
  82326. getActiveTextures(): BaseTexture[];
  82327. /**
  82328. * Specifies if the material uses a texture
  82329. * @param texture defines the texture to check against the material
  82330. * @returns a boolean specifying if the material uses the texture
  82331. */
  82332. hasTexture(texture: BaseTexture): boolean;
  82333. /**
  82334. * Makes a duplicate of the material, and gives it a new name
  82335. * @param name defines the new name for the duplicated material
  82336. * @returns the cloned material
  82337. */
  82338. clone(name: string): Nullable<Material>;
  82339. /**
  82340. * Gets the meshes bound to the material
  82341. * @returns an array of meshes bound to the material
  82342. */
  82343. getBindedMeshes(): AbstractMesh[];
  82344. /**
  82345. * Force shader compilation
  82346. * @param mesh defines the mesh associated with this material
  82347. * @param onCompiled defines a function to execute once the material is compiled
  82348. * @param options defines the options to configure the compilation
  82349. */
  82350. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82351. clipPlane: boolean;
  82352. }>): void;
  82353. /**
  82354. * Force shader compilation
  82355. * @param mesh defines the mesh that will use this material
  82356. * @param options defines additional options for compiling the shaders
  82357. * @returns a promise that resolves when the compilation completes
  82358. */
  82359. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82360. clipPlane: boolean;
  82361. }>): Promise<void>;
  82362. private static readonly _ImageProcessingDirtyCallBack;
  82363. private static readonly _TextureDirtyCallBack;
  82364. private static readonly _FresnelDirtyCallBack;
  82365. private static readonly _MiscDirtyCallBack;
  82366. private static readonly _LightsDirtyCallBack;
  82367. private static readonly _AttributeDirtyCallBack;
  82368. private static _FresnelAndMiscDirtyCallBack;
  82369. private static _TextureAndMiscDirtyCallBack;
  82370. private static readonly _DirtyCallbackArray;
  82371. private static readonly _RunDirtyCallBacks;
  82372. /**
  82373. * Marks a define in the material to indicate that it needs to be re-computed
  82374. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82375. */
  82376. markAsDirty(flag: number): void;
  82377. /**
  82378. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82379. * @param func defines a function which checks material defines against the submeshes
  82380. */
  82381. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82382. /**
  82383. * Indicates that image processing needs to be re-calculated for all submeshes
  82384. */
  82385. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82386. /**
  82387. * Indicates that textures need to be re-calculated for all submeshes
  82388. */
  82389. protected _markAllSubMeshesAsTexturesDirty(): void;
  82390. /**
  82391. * Indicates that fresnel needs to be re-calculated for all submeshes
  82392. */
  82393. protected _markAllSubMeshesAsFresnelDirty(): void;
  82394. /**
  82395. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82396. */
  82397. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82398. /**
  82399. * Indicates that lights need to be re-calculated for all submeshes
  82400. */
  82401. protected _markAllSubMeshesAsLightsDirty(): void;
  82402. /**
  82403. * Indicates that attributes need to be re-calculated for all submeshes
  82404. */
  82405. protected _markAllSubMeshesAsAttributesDirty(): void;
  82406. /**
  82407. * Indicates that misc needs to be re-calculated for all submeshes
  82408. */
  82409. protected _markAllSubMeshesAsMiscDirty(): void;
  82410. /**
  82411. * Indicates that textures and misc need to be re-calculated for all submeshes
  82412. */
  82413. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82414. /**
  82415. * Disposes the material
  82416. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82417. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82418. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82419. */
  82420. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82421. /** @hidden */
  82422. private releaseVertexArrayObject;
  82423. /**
  82424. * Serializes this material
  82425. * @returns the serialized material object
  82426. */
  82427. serialize(): any;
  82428. /**
  82429. * Creates a material from parsed material data
  82430. * @param parsedMaterial defines parsed material data
  82431. * @param scene defines the hosting scene
  82432. * @param rootUrl defines the root URL to use to load textures
  82433. * @returns a new material
  82434. */
  82435. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82436. }
  82437. }
  82438. declare module BABYLON {
  82439. /**
  82440. * Base class for submeshes
  82441. */
  82442. export class BaseSubMesh {
  82443. /** @hidden */
  82444. _materialDefines: Nullable<MaterialDefines>;
  82445. /** @hidden */
  82446. _materialEffect: Nullable<Effect>;
  82447. /**
  82448. * Gets associated effect
  82449. */
  82450. readonly effect: Nullable<Effect>;
  82451. /**
  82452. * Sets associated effect (effect used to render this submesh)
  82453. * @param effect defines the effect to associate with
  82454. * @param defines defines the set of defines used to compile this effect
  82455. */
  82456. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82457. }
  82458. /**
  82459. * Defines a subdivision inside a mesh
  82460. */
  82461. export class SubMesh extends BaseSubMesh implements ICullable {
  82462. /** the material index to use */
  82463. materialIndex: number;
  82464. /** vertex index start */
  82465. verticesStart: number;
  82466. /** vertices count */
  82467. verticesCount: number;
  82468. /** index start */
  82469. indexStart: number;
  82470. /** indices count */
  82471. indexCount: number;
  82472. /** @hidden */
  82473. _linesIndexCount: number;
  82474. private _mesh;
  82475. private _renderingMesh;
  82476. private _boundingInfo;
  82477. private _linesIndexBuffer;
  82478. /** @hidden */
  82479. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82480. /** @hidden */
  82481. _trianglePlanes: Plane[];
  82482. /** @hidden */
  82483. _lastColliderTransformMatrix: Nullable<Matrix>;
  82484. /** @hidden */
  82485. _renderId: number;
  82486. /** @hidden */
  82487. _alphaIndex: number;
  82488. /** @hidden */
  82489. _distanceToCamera: number;
  82490. /** @hidden */
  82491. _id: number;
  82492. private _currentMaterial;
  82493. /**
  82494. * Add a new submesh to a mesh
  82495. * @param materialIndex defines the material index to use
  82496. * @param verticesStart defines vertex index start
  82497. * @param verticesCount defines vertices count
  82498. * @param indexStart defines index start
  82499. * @param indexCount defines indices count
  82500. * @param mesh defines the parent mesh
  82501. * @param renderingMesh defines an optional rendering mesh
  82502. * @param createBoundingBox defines if bounding box should be created for this submesh
  82503. * @returns the new submesh
  82504. */
  82505. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82506. /**
  82507. * Creates a new submesh
  82508. * @param materialIndex defines the material index to use
  82509. * @param verticesStart defines vertex index start
  82510. * @param verticesCount defines vertices count
  82511. * @param indexStart defines index start
  82512. * @param indexCount defines indices count
  82513. * @param mesh defines the parent mesh
  82514. * @param renderingMesh defines an optional rendering mesh
  82515. * @param createBoundingBox defines if bounding box should be created for this submesh
  82516. */
  82517. constructor(
  82518. /** the material index to use */
  82519. materialIndex: number,
  82520. /** vertex index start */
  82521. verticesStart: number,
  82522. /** vertices count */
  82523. verticesCount: number,
  82524. /** index start */
  82525. indexStart: number,
  82526. /** indices count */
  82527. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82528. /**
  82529. * Returns true if this submesh covers the entire parent mesh
  82530. * @ignorenaming
  82531. */
  82532. readonly IsGlobal: boolean;
  82533. /**
  82534. * Returns the submesh BoudingInfo object
  82535. * @returns current bounding info (or mesh's one if the submesh is global)
  82536. */
  82537. getBoundingInfo(): BoundingInfo;
  82538. /**
  82539. * Sets the submesh BoundingInfo
  82540. * @param boundingInfo defines the new bounding info to use
  82541. * @returns the SubMesh
  82542. */
  82543. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82544. /**
  82545. * Returns the mesh of the current submesh
  82546. * @return the parent mesh
  82547. */
  82548. getMesh(): AbstractMesh;
  82549. /**
  82550. * Returns the rendering mesh of the submesh
  82551. * @returns the rendering mesh (could be different from parent mesh)
  82552. */
  82553. getRenderingMesh(): Mesh;
  82554. /**
  82555. * Returns the submesh material
  82556. * @returns null or the current material
  82557. */
  82558. getMaterial(): Nullable<Material>;
  82559. /**
  82560. * Sets a new updated BoundingInfo object to the submesh
  82561. * @param data defines an optional position array to use to determine the bounding info
  82562. * @returns the SubMesh
  82563. */
  82564. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82565. /** @hidden */
  82566. _checkCollision(collider: Collider): boolean;
  82567. /**
  82568. * Updates the submesh BoundingInfo
  82569. * @param world defines the world matrix to use to update the bounding info
  82570. * @returns the submesh
  82571. */
  82572. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82573. /**
  82574. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82575. * @param frustumPlanes defines the frustum planes
  82576. * @returns true if the submesh is intersecting with the frustum
  82577. */
  82578. isInFrustum(frustumPlanes: Plane[]): boolean;
  82579. /**
  82580. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82581. * @param frustumPlanes defines the frustum planes
  82582. * @returns true if the submesh is inside the frustum
  82583. */
  82584. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82585. /**
  82586. * Renders the submesh
  82587. * @param enableAlphaMode defines if alpha needs to be used
  82588. * @returns the submesh
  82589. */
  82590. render(enableAlphaMode: boolean): SubMesh;
  82591. /**
  82592. * @hidden
  82593. */
  82594. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82595. /**
  82596. * Checks if the submesh intersects with a ray
  82597. * @param ray defines the ray to test
  82598. * @returns true is the passed ray intersects the submesh bounding box
  82599. */
  82600. canIntersects(ray: Ray): boolean;
  82601. /**
  82602. * Intersects current submesh with a ray
  82603. * @param ray defines the ray to test
  82604. * @param positions defines mesh's positions array
  82605. * @param indices defines mesh's indices array
  82606. * @param fastCheck defines if only bounding info should be used
  82607. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82608. * @returns intersection info or null if no intersection
  82609. */
  82610. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82611. /** @hidden */
  82612. private _intersectLines;
  82613. /** @hidden */
  82614. private _intersectTriangles;
  82615. /** @hidden */
  82616. private _intersectUnIndexedTriangles;
  82617. /** @hidden */
  82618. _rebuild(): void;
  82619. /**
  82620. * Creates a new submesh from the passed mesh
  82621. * @param newMesh defines the new hosting mesh
  82622. * @param newRenderingMesh defines an optional rendering mesh
  82623. * @returns the new submesh
  82624. */
  82625. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82626. /**
  82627. * Release associated resources
  82628. */
  82629. dispose(): void;
  82630. /**
  82631. * Gets the class name
  82632. * @returns the string "SubMesh".
  82633. */
  82634. getClassName(): string;
  82635. /**
  82636. * Creates a new submesh from indices data
  82637. * @param materialIndex the index of the main mesh material
  82638. * @param startIndex the index where to start the copy in the mesh indices array
  82639. * @param indexCount the number of indices to copy then from the startIndex
  82640. * @param mesh the main mesh to create the submesh from
  82641. * @param renderingMesh the optional rendering mesh
  82642. * @returns a new submesh
  82643. */
  82644. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82645. }
  82646. }
  82647. declare module BABYLON {
  82648. /**
  82649. * Class used to store geometry data (vertex buffers + index buffer)
  82650. */
  82651. export class Geometry implements IGetSetVerticesData {
  82652. /**
  82653. * Gets or sets the ID of the geometry
  82654. */
  82655. id: string;
  82656. /**
  82657. * Gets or sets the unique ID of the geometry
  82658. */
  82659. uniqueId: number;
  82660. /**
  82661. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82662. */
  82663. delayLoadState: number;
  82664. /**
  82665. * Gets the file containing the data to load when running in delay load state
  82666. */
  82667. delayLoadingFile: Nullable<string>;
  82668. /**
  82669. * Callback called when the geometry is updated
  82670. */
  82671. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82672. private _scene;
  82673. private _engine;
  82674. private _meshes;
  82675. private _totalVertices;
  82676. /** @hidden */
  82677. _indices: IndicesArray;
  82678. /** @hidden */
  82679. _vertexBuffers: {
  82680. [key: string]: VertexBuffer;
  82681. };
  82682. private _isDisposed;
  82683. private _extend;
  82684. private _boundingBias;
  82685. /** @hidden */
  82686. _delayInfo: Array<string>;
  82687. private _indexBuffer;
  82688. private _indexBufferIsUpdatable;
  82689. /** @hidden */
  82690. _boundingInfo: Nullable<BoundingInfo>;
  82691. /** @hidden */
  82692. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82693. /** @hidden */
  82694. _softwareSkinningFrameId: number;
  82695. private _vertexArrayObjects;
  82696. private _updatable;
  82697. /** @hidden */
  82698. _positions: Nullable<Vector3[]>;
  82699. /**
  82700. * 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
  82701. */
  82702. /**
  82703. * 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
  82704. */
  82705. boundingBias: Vector2;
  82706. /**
  82707. * Static function used to attach a new empty geometry to a mesh
  82708. * @param mesh defines the mesh to attach the geometry to
  82709. * @returns the new Geometry
  82710. */
  82711. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82712. /**
  82713. * Creates a new geometry
  82714. * @param id defines the unique ID
  82715. * @param scene defines the hosting scene
  82716. * @param vertexData defines the VertexData used to get geometry data
  82717. * @param updatable defines if geometry must be updatable (false by default)
  82718. * @param mesh defines the mesh that will be associated with the geometry
  82719. */
  82720. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82721. /**
  82722. * Gets the current extend of the geometry
  82723. */
  82724. readonly extend: {
  82725. minimum: Vector3;
  82726. maximum: Vector3;
  82727. };
  82728. /**
  82729. * Gets the hosting scene
  82730. * @returns the hosting Scene
  82731. */
  82732. getScene(): Scene;
  82733. /**
  82734. * Gets the hosting engine
  82735. * @returns the hosting Engine
  82736. */
  82737. getEngine(): Engine;
  82738. /**
  82739. * Defines if the geometry is ready to use
  82740. * @returns true if the geometry is ready to be used
  82741. */
  82742. isReady(): boolean;
  82743. /**
  82744. * Gets a value indicating that the geometry should not be serialized
  82745. */
  82746. readonly doNotSerialize: boolean;
  82747. /** @hidden */
  82748. _rebuild(): void;
  82749. /**
  82750. * Affects all geometry data in one call
  82751. * @param vertexData defines the geometry data
  82752. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82753. */
  82754. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82755. /**
  82756. * Set specific vertex data
  82757. * @param kind defines the data kind (Position, normal, etc...)
  82758. * @param data defines the vertex data to use
  82759. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82760. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82761. */
  82762. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82763. /**
  82764. * Removes a specific vertex data
  82765. * @param kind defines the data kind (Position, normal, etc...)
  82766. */
  82767. removeVerticesData(kind: string): void;
  82768. /**
  82769. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82770. * @param buffer defines the vertex buffer to use
  82771. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82772. */
  82773. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82774. /**
  82775. * Update a specific vertex buffer
  82776. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82777. * It will do nothing if the buffer is not updatable
  82778. * @param kind defines the data kind (Position, normal, etc...)
  82779. * @param data defines the data to use
  82780. * @param offset defines the offset in the target buffer where to store the data
  82781. * @param useBytes set to true if the offset is in bytes
  82782. */
  82783. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82784. /**
  82785. * Update a specific vertex buffer
  82786. * This function will create a new buffer if the current one is not updatable
  82787. * @param kind defines the data kind (Position, normal, etc...)
  82788. * @param data defines the data to use
  82789. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82790. */
  82791. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82792. private _updateBoundingInfo;
  82793. /** @hidden */
  82794. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82795. /**
  82796. * Gets total number of vertices
  82797. * @returns the total number of vertices
  82798. */
  82799. getTotalVertices(): number;
  82800. /**
  82801. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82802. * @param kind defines the data kind (Position, normal, etc...)
  82803. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82804. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82805. * @returns a float array containing vertex data
  82806. */
  82807. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82808. /**
  82809. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82810. * @param kind defines the data kind (Position, normal, etc...)
  82811. * @returns true if the vertex buffer with the specified kind is updatable
  82812. */
  82813. isVertexBufferUpdatable(kind: string): boolean;
  82814. /**
  82815. * Gets a specific vertex buffer
  82816. * @param kind defines the data kind (Position, normal, etc...)
  82817. * @returns a VertexBuffer
  82818. */
  82819. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82820. /**
  82821. * Returns all vertex buffers
  82822. * @return an object holding all vertex buffers indexed by kind
  82823. */
  82824. getVertexBuffers(): Nullable<{
  82825. [key: string]: VertexBuffer;
  82826. }>;
  82827. /**
  82828. * Gets a boolean indicating if specific vertex buffer is present
  82829. * @param kind defines the data kind (Position, normal, etc...)
  82830. * @returns true if data is present
  82831. */
  82832. isVerticesDataPresent(kind: string): boolean;
  82833. /**
  82834. * Gets a list of all attached data kinds (Position, normal, etc...)
  82835. * @returns a list of string containing all kinds
  82836. */
  82837. getVerticesDataKinds(): string[];
  82838. /**
  82839. * Update index buffer
  82840. * @param indices defines the indices to store in the index buffer
  82841. * @param offset defines the offset in the target buffer where to store the data
  82842. * @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)
  82843. */
  82844. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82845. /**
  82846. * Creates a new index buffer
  82847. * @param indices defines the indices to store in the index buffer
  82848. * @param totalVertices defines the total number of vertices (could be null)
  82849. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82850. */
  82851. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82852. /**
  82853. * Return the total number of indices
  82854. * @returns the total number of indices
  82855. */
  82856. getTotalIndices(): number;
  82857. /**
  82858. * Gets the index buffer array
  82859. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82860. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82861. * @returns the index buffer array
  82862. */
  82863. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82864. /**
  82865. * Gets the index buffer
  82866. * @return the index buffer
  82867. */
  82868. getIndexBuffer(): Nullable<DataBuffer>;
  82869. /** @hidden */
  82870. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82871. /**
  82872. * Release the associated resources for a specific mesh
  82873. * @param mesh defines the source mesh
  82874. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82875. */
  82876. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82877. /**
  82878. * Apply current geometry to a given mesh
  82879. * @param mesh defines the mesh to apply geometry to
  82880. */
  82881. applyToMesh(mesh: Mesh): void;
  82882. private _updateExtend;
  82883. private _applyToMesh;
  82884. private notifyUpdate;
  82885. /**
  82886. * Load the geometry if it was flagged as delay loaded
  82887. * @param scene defines the hosting scene
  82888. * @param onLoaded defines a callback called when the geometry is loaded
  82889. */
  82890. load(scene: Scene, onLoaded?: () => void): void;
  82891. private _queueLoad;
  82892. /**
  82893. * Invert the geometry to move from a right handed system to a left handed one.
  82894. */
  82895. toLeftHanded(): void;
  82896. /** @hidden */
  82897. _resetPointsArrayCache(): void;
  82898. /** @hidden */
  82899. _generatePointsArray(): boolean;
  82900. /**
  82901. * Gets a value indicating if the geometry is disposed
  82902. * @returns true if the geometry was disposed
  82903. */
  82904. isDisposed(): boolean;
  82905. private _disposeVertexArrayObjects;
  82906. /**
  82907. * Free all associated resources
  82908. */
  82909. dispose(): void;
  82910. /**
  82911. * Clone the current geometry into a new geometry
  82912. * @param id defines the unique ID of the new geometry
  82913. * @returns a new geometry object
  82914. */
  82915. copy(id: string): Geometry;
  82916. /**
  82917. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82918. * @return a JSON representation of the current geometry data (without the vertices data)
  82919. */
  82920. serialize(): any;
  82921. private toNumberArray;
  82922. /**
  82923. * Serialize all vertices data into a JSON oject
  82924. * @returns a JSON representation of the current geometry data
  82925. */
  82926. serializeVerticeData(): any;
  82927. /**
  82928. * Extracts a clone of a mesh geometry
  82929. * @param mesh defines the source mesh
  82930. * @param id defines the unique ID of the new geometry object
  82931. * @returns the new geometry object
  82932. */
  82933. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82934. /**
  82935. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82936. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82937. * Be aware Math.random() could cause collisions, but:
  82938. * "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"
  82939. * @returns a string containing a new GUID
  82940. */
  82941. static RandomId(): string;
  82942. /** @hidden */
  82943. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82944. private static _CleanMatricesWeights;
  82945. /**
  82946. * Create a new geometry from persisted data (Using .babylon file format)
  82947. * @param parsedVertexData defines the persisted data
  82948. * @param scene defines the hosting scene
  82949. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82950. * @returns the new geometry object
  82951. */
  82952. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82953. }
  82954. }
  82955. declare module BABYLON {
  82956. /**
  82957. * Define an interface for all classes that will get and set the data on vertices
  82958. */
  82959. export interface IGetSetVerticesData {
  82960. /**
  82961. * Gets a boolean indicating if specific vertex data is present
  82962. * @param kind defines the vertex data kind to use
  82963. * @returns true is data kind is present
  82964. */
  82965. isVerticesDataPresent(kind: string): boolean;
  82966. /**
  82967. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82968. * @param kind defines the data kind (Position, normal, etc...)
  82969. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82970. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82971. * @returns a float array containing vertex data
  82972. */
  82973. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82974. /**
  82975. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82976. * @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.
  82977. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82978. * @returns the indices array or an empty array if the mesh has no geometry
  82979. */
  82980. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82981. /**
  82982. * Set specific vertex data
  82983. * @param kind defines the data kind (Position, normal, etc...)
  82984. * @param data defines the vertex data to use
  82985. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82986. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82987. */
  82988. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82989. /**
  82990. * Update a specific associated vertex buffer
  82991. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82992. * - VertexBuffer.PositionKind
  82993. * - VertexBuffer.UVKind
  82994. * - VertexBuffer.UV2Kind
  82995. * - VertexBuffer.UV3Kind
  82996. * - VertexBuffer.UV4Kind
  82997. * - VertexBuffer.UV5Kind
  82998. * - VertexBuffer.UV6Kind
  82999. * - VertexBuffer.ColorKind
  83000. * - VertexBuffer.MatricesIndicesKind
  83001. * - VertexBuffer.MatricesIndicesExtraKind
  83002. * - VertexBuffer.MatricesWeightsKind
  83003. * - VertexBuffer.MatricesWeightsExtraKind
  83004. * @param data defines the data source
  83005. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83006. * @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)
  83007. */
  83008. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  83009. /**
  83010. * Creates a new index buffer
  83011. * @param indices defines the indices to store in the index buffer
  83012. * @param totalVertices defines the total number of vertices (could be null)
  83013. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83014. */
  83015. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  83016. }
  83017. /**
  83018. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83019. */
  83020. export class VertexData {
  83021. /**
  83022. * Mesh side orientation : usually the external or front surface
  83023. */
  83024. static readonly FRONTSIDE: number;
  83025. /**
  83026. * Mesh side orientation : usually the internal or back surface
  83027. */
  83028. static readonly BACKSIDE: number;
  83029. /**
  83030. * Mesh side orientation : both internal and external or front and back surfaces
  83031. */
  83032. static readonly DOUBLESIDE: number;
  83033. /**
  83034. * Mesh side orientation : by default, `FRONTSIDE`
  83035. */
  83036. static readonly DEFAULTSIDE: number;
  83037. /**
  83038. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83039. */
  83040. positions: Nullable<FloatArray>;
  83041. /**
  83042. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83043. */
  83044. normals: Nullable<FloatArray>;
  83045. /**
  83046. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83047. */
  83048. tangents: Nullable<FloatArray>;
  83049. /**
  83050. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83051. */
  83052. uvs: Nullable<FloatArray>;
  83053. /**
  83054. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83055. */
  83056. uvs2: Nullable<FloatArray>;
  83057. /**
  83058. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83059. */
  83060. uvs3: Nullable<FloatArray>;
  83061. /**
  83062. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83063. */
  83064. uvs4: Nullable<FloatArray>;
  83065. /**
  83066. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83067. */
  83068. uvs5: Nullable<FloatArray>;
  83069. /**
  83070. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83071. */
  83072. uvs6: Nullable<FloatArray>;
  83073. /**
  83074. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83075. */
  83076. colors: Nullable<FloatArray>;
  83077. /**
  83078. * 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).
  83079. */
  83080. matricesIndices: Nullable<FloatArray>;
  83081. /**
  83082. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83083. */
  83084. matricesWeights: Nullable<FloatArray>;
  83085. /**
  83086. * An array extending the number of possible indices
  83087. */
  83088. matricesIndicesExtra: Nullable<FloatArray>;
  83089. /**
  83090. * An array extending the number of possible weights when the number of indices is extended
  83091. */
  83092. matricesWeightsExtra: Nullable<FloatArray>;
  83093. /**
  83094. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83095. */
  83096. indices: Nullable<IndicesArray>;
  83097. /**
  83098. * Uses the passed data array to set the set the values for the specified kind of data
  83099. * @param data a linear array of floating numbers
  83100. * @param kind the type of data that is being set, eg positions, colors etc
  83101. */
  83102. set(data: FloatArray, kind: string): void;
  83103. /**
  83104. * Associates the vertexData to the passed Mesh.
  83105. * Sets it as updatable or not (default `false`)
  83106. * @param mesh the mesh the vertexData is applied to
  83107. * @param updatable when used and having the value true allows new data to update the vertexData
  83108. * @returns the VertexData
  83109. */
  83110. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83111. /**
  83112. * Associates the vertexData to the passed Geometry.
  83113. * Sets it as updatable or not (default `false`)
  83114. * @param geometry the geometry the vertexData is applied to
  83115. * @param updatable when used and having the value true allows new data to update the vertexData
  83116. * @returns VertexData
  83117. */
  83118. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83119. /**
  83120. * Updates the associated mesh
  83121. * @param mesh the mesh to be updated
  83122. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83123. * @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
  83124. * @returns VertexData
  83125. */
  83126. updateMesh(mesh: Mesh): VertexData;
  83127. /**
  83128. * Updates the associated geometry
  83129. * @param geometry the geometry to be updated
  83130. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83131. * @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
  83132. * @returns VertexData.
  83133. */
  83134. updateGeometry(geometry: Geometry): VertexData;
  83135. private _applyTo;
  83136. private _update;
  83137. /**
  83138. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83139. * @param matrix the transforming matrix
  83140. * @returns the VertexData
  83141. */
  83142. transform(matrix: Matrix): VertexData;
  83143. /**
  83144. * Merges the passed VertexData into the current one
  83145. * @param other the VertexData to be merged into the current one
  83146. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83147. * @returns the modified VertexData
  83148. */
  83149. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83150. private _mergeElement;
  83151. private _validate;
  83152. /**
  83153. * Serializes the VertexData
  83154. * @returns a serialized object
  83155. */
  83156. serialize(): any;
  83157. /**
  83158. * Extracts the vertexData from a mesh
  83159. * @param mesh the mesh from which to extract the VertexData
  83160. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83161. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83162. * @returns the object VertexData associated to the passed mesh
  83163. */
  83164. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83165. /**
  83166. * Extracts the vertexData from the geometry
  83167. * @param geometry the geometry from which to extract the VertexData
  83168. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83169. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83170. * @returns the object VertexData associated to the passed mesh
  83171. */
  83172. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83173. private static _ExtractFrom;
  83174. /**
  83175. * Creates the VertexData for a Ribbon
  83176. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83177. * * pathArray array of paths, each of which an array of successive Vector3
  83178. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83179. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83180. * * 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
  83181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83182. * * 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)
  83183. * * 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)
  83184. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83185. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83186. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83187. * @returns the VertexData of the ribbon
  83188. */
  83189. static CreateRibbon(options: {
  83190. pathArray: Vector3[][];
  83191. closeArray?: boolean;
  83192. closePath?: boolean;
  83193. offset?: number;
  83194. sideOrientation?: number;
  83195. frontUVs?: Vector4;
  83196. backUVs?: Vector4;
  83197. invertUV?: boolean;
  83198. uvs?: Vector2[];
  83199. colors?: Color4[];
  83200. }): VertexData;
  83201. /**
  83202. * Creates the VertexData for a box
  83203. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83204. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83205. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83206. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83207. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83208. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83209. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83210. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83211. * * 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)
  83212. * * 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)
  83213. * @returns the VertexData of the box
  83214. */
  83215. static CreateBox(options: {
  83216. size?: number;
  83217. width?: number;
  83218. height?: number;
  83219. depth?: number;
  83220. faceUV?: Vector4[];
  83221. faceColors?: Color4[];
  83222. sideOrientation?: number;
  83223. frontUVs?: Vector4;
  83224. backUVs?: Vector4;
  83225. }): VertexData;
  83226. /**
  83227. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83228. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83229. * * segments sets the number of horizontal strips optional, default 32
  83230. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83231. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83232. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83233. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83234. * * 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
  83235. * * 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
  83236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83237. * * 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)
  83238. * * 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)
  83239. * @returns the VertexData of the ellipsoid
  83240. */
  83241. static CreateSphere(options: {
  83242. segments?: number;
  83243. diameter?: number;
  83244. diameterX?: number;
  83245. diameterY?: number;
  83246. diameterZ?: number;
  83247. arc?: number;
  83248. slice?: number;
  83249. sideOrientation?: number;
  83250. frontUVs?: Vector4;
  83251. backUVs?: Vector4;
  83252. }): VertexData;
  83253. /**
  83254. * Creates the VertexData for a cylinder, cone or prism
  83255. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83256. * * height sets the height (y direction) of the cylinder, optional, default 2
  83257. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83258. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83259. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83260. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83261. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83262. * * 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
  83263. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83264. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83265. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83266. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83268. * * 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)
  83269. * * 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)
  83270. * @returns the VertexData of the cylinder, cone or prism
  83271. */
  83272. static CreateCylinder(options: {
  83273. height?: number;
  83274. diameterTop?: number;
  83275. diameterBottom?: number;
  83276. diameter?: number;
  83277. tessellation?: number;
  83278. subdivisions?: number;
  83279. arc?: number;
  83280. faceColors?: Color4[];
  83281. faceUV?: Vector4[];
  83282. hasRings?: boolean;
  83283. enclose?: boolean;
  83284. sideOrientation?: number;
  83285. frontUVs?: Vector4;
  83286. backUVs?: Vector4;
  83287. }): VertexData;
  83288. /**
  83289. * Creates the VertexData for a torus
  83290. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83291. * * diameter the diameter of the torus, optional default 1
  83292. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83293. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83295. * * 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)
  83296. * * 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)
  83297. * @returns the VertexData of the torus
  83298. */
  83299. static CreateTorus(options: {
  83300. diameter?: number;
  83301. thickness?: number;
  83302. tessellation?: number;
  83303. sideOrientation?: number;
  83304. frontUVs?: Vector4;
  83305. backUVs?: Vector4;
  83306. }): VertexData;
  83307. /**
  83308. * Creates the VertexData of the LineSystem
  83309. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83310. * - lines an array of lines, each line being an array of successive Vector3
  83311. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83312. * @returns the VertexData of the LineSystem
  83313. */
  83314. static CreateLineSystem(options: {
  83315. lines: Vector3[][];
  83316. colors?: Nullable<Color4[][]>;
  83317. }): VertexData;
  83318. /**
  83319. * Create the VertexData for a DashedLines
  83320. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83321. * - points an array successive Vector3
  83322. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83323. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83324. * - dashNb the intended total number of dashes, optional, default 200
  83325. * @returns the VertexData for the DashedLines
  83326. */
  83327. static CreateDashedLines(options: {
  83328. points: Vector3[];
  83329. dashSize?: number;
  83330. gapSize?: number;
  83331. dashNb?: number;
  83332. }): VertexData;
  83333. /**
  83334. * Creates the VertexData for a Ground
  83335. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83336. * - width the width (x direction) of the ground, optional, default 1
  83337. * - height the height (z direction) of the ground, optional, default 1
  83338. * - subdivisions the number of subdivisions per side, optional, default 1
  83339. * @returns the VertexData of the Ground
  83340. */
  83341. static CreateGround(options: {
  83342. width?: number;
  83343. height?: number;
  83344. subdivisions?: number;
  83345. subdivisionsX?: number;
  83346. subdivisionsY?: number;
  83347. }): VertexData;
  83348. /**
  83349. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83350. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83351. * * xmin the ground minimum X coordinate, optional, default -1
  83352. * * zmin the ground minimum Z coordinate, optional, default -1
  83353. * * xmax the ground maximum X coordinate, optional, default 1
  83354. * * zmax the ground maximum Z coordinate, optional, default 1
  83355. * * 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}
  83356. * * 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}
  83357. * @returns the VertexData of the TiledGround
  83358. */
  83359. static CreateTiledGround(options: {
  83360. xmin: number;
  83361. zmin: number;
  83362. xmax: number;
  83363. zmax: number;
  83364. subdivisions?: {
  83365. w: number;
  83366. h: number;
  83367. };
  83368. precision?: {
  83369. w: number;
  83370. h: number;
  83371. };
  83372. }): VertexData;
  83373. /**
  83374. * Creates the VertexData of the Ground designed from a heightmap
  83375. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83376. * * width the width (x direction) of the ground
  83377. * * height the height (z direction) of the ground
  83378. * * subdivisions the number of subdivisions per side
  83379. * * minHeight the minimum altitude on the ground, optional, default 0
  83380. * * maxHeight the maximum altitude on the ground, optional default 1
  83381. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83382. * * buffer the array holding the image color data
  83383. * * bufferWidth the width of image
  83384. * * bufferHeight the height of image
  83385. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83386. * @returns the VertexData of the Ground designed from a heightmap
  83387. */
  83388. static CreateGroundFromHeightMap(options: {
  83389. width: number;
  83390. height: number;
  83391. subdivisions: number;
  83392. minHeight: number;
  83393. maxHeight: number;
  83394. colorFilter: Color3;
  83395. buffer: Uint8Array;
  83396. bufferWidth: number;
  83397. bufferHeight: number;
  83398. alphaFilter: number;
  83399. }): VertexData;
  83400. /**
  83401. * Creates the VertexData for a Plane
  83402. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83403. * * size sets the width and height of the plane to the value of size, optional default 1
  83404. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83405. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83406. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83407. * * 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)
  83408. * * 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)
  83409. * @returns the VertexData of the box
  83410. */
  83411. static CreatePlane(options: {
  83412. size?: number;
  83413. width?: number;
  83414. height?: number;
  83415. sideOrientation?: number;
  83416. frontUVs?: Vector4;
  83417. backUVs?: Vector4;
  83418. }): VertexData;
  83419. /**
  83420. * Creates the VertexData of the Disc or regular Polygon
  83421. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83422. * * radius the radius of the disc, optional default 0.5
  83423. * * tessellation the number of polygon sides, optional, default 64
  83424. * * 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
  83425. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83426. * * 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)
  83427. * * 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)
  83428. * @returns the VertexData of the box
  83429. */
  83430. static CreateDisc(options: {
  83431. radius?: number;
  83432. tessellation?: number;
  83433. arc?: number;
  83434. sideOrientation?: number;
  83435. frontUVs?: Vector4;
  83436. backUVs?: Vector4;
  83437. }): VertexData;
  83438. /**
  83439. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83440. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83441. * @param polygon a mesh built from polygonTriangulation.build()
  83442. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83443. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83444. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83445. * @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)
  83446. * @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)
  83447. * @returns the VertexData of the Polygon
  83448. */
  83449. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83450. /**
  83451. * Creates the VertexData of the IcoSphere
  83452. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83453. * * radius the radius of the IcoSphere, optional default 1
  83454. * * radiusX allows stretching in the x direction, optional, default radius
  83455. * * radiusY allows stretching in the y direction, optional, default radius
  83456. * * radiusZ allows stretching in the z direction, optional, default radius
  83457. * * flat when true creates a flat shaded mesh, optional, default true
  83458. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83459. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83460. * * 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)
  83461. * * 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)
  83462. * @returns the VertexData of the IcoSphere
  83463. */
  83464. static CreateIcoSphere(options: {
  83465. radius?: number;
  83466. radiusX?: number;
  83467. radiusY?: number;
  83468. radiusZ?: number;
  83469. flat?: boolean;
  83470. subdivisions?: number;
  83471. sideOrientation?: number;
  83472. frontUVs?: Vector4;
  83473. backUVs?: Vector4;
  83474. }): VertexData;
  83475. /**
  83476. * Creates the VertexData for a Polyhedron
  83477. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83478. * * type provided types are:
  83479. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83480. * * 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)
  83481. * * size the size of the IcoSphere, optional default 1
  83482. * * sizeX allows stretching in the x direction, optional, default size
  83483. * * sizeY allows stretching in the y direction, optional, default size
  83484. * * sizeZ allows stretching in the z direction, optional, default size
  83485. * * 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
  83486. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83487. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83488. * * flat when true creates a flat shaded mesh, optional, default true
  83489. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83490. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83491. * * 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)
  83492. * * 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)
  83493. * @returns the VertexData of the Polyhedron
  83494. */
  83495. static CreatePolyhedron(options: {
  83496. type?: number;
  83497. size?: number;
  83498. sizeX?: number;
  83499. sizeY?: number;
  83500. sizeZ?: number;
  83501. custom?: any;
  83502. faceUV?: Vector4[];
  83503. faceColors?: Color4[];
  83504. flat?: boolean;
  83505. sideOrientation?: number;
  83506. frontUVs?: Vector4;
  83507. backUVs?: Vector4;
  83508. }): VertexData;
  83509. /**
  83510. * Creates the VertexData for a TorusKnot
  83511. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83512. * * radius the radius of the torus knot, optional, default 2
  83513. * * tube the thickness of the tube, optional, default 0.5
  83514. * * radialSegments the number of sides on each tube segments, optional, default 32
  83515. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83516. * * p the number of windings around the z axis, optional, default 2
  83517. * * q the number of windings around the x axis, optional, default 3
  83518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83519. * * 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)
  83520. * * 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)
  83521. * @returns the VertexData of the Torus Knot
  83522. */
  83523. static CreateTorusKnot(options: {
  83524. radius?: number;
  83525. tube?: number;
  83526. radialSegments?: number;
  83527. tubularSegments?: number;
  83528. p?: number;
  83529. q?: number;
  83530. sideOrientation?: number;
  83531. frontUVs?: Vector4;
  83532. backUVs?: Vector4;
  83533. }): VertexData;
  83534. /**
  83535. * Compute normals for given positions and indices
  83536. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83537. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83538. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83539. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83540. * * facetNormals : optional array of facet normals (vector3)
  83541. * * facetPositions : optional array of facet positions (vector3)
  83542. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83543. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83544. * * bInfo : optional bounding info, required for facetPartitioning computation
  83545. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83546. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83547. * * useRightHandedSystem: optional boolean to for right handed system computation
  83548. * * depthSort : optional boolean to enable the facet depth sort computation
  83549. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83550. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83551. */
  83552. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83553. facetNormals?: any;
  83554. facetPositions?: any;
  83555. facetPartitioning?: any;
  83556. ratio?: number;
  83557. bInfo?: any;
  83558. bbSize?: Vector3;
  83559. subDiv?: any;
  83560. useRightHandedSystem?: boolean;
  83561. depthSort?: boolean;
  83562. distanceTo?: Vector3;
  83563. depthSortedFacets?: any;
  83564. }): void;
  83565. /** @hidden */
  83566. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83567. /**
  83568. * Applies VertexData created from the imported parameters to the geometry
  83569. * @param parsedVertexData the parsed data from an imported file
  83570. * @param geometry the geometry to apply the VertexData to
  83571. */
  83572. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83573. }
  83574. }
  83575. declare module BABYLON {
  83576. /**
  83577. * Class containing static functions to help procedurally build meshes
  83578. */
  83579. export class DiscBuilder {
  83580. /**
  83581. * Creates a plane polygonal mesh. By default, this is a disc
  83582. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83583. * * 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
  83584. * * 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
  83585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83588. * @param name defines the name of the mesh
  83589. * @param options defines the options used to create the mesh
  83590. * @param scene defines the hosting scene
  83591. * @returns the plane polygonal mesh
  83592. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83593. */
  83594. static CreateDisc(name: string, options: {
  83595. radius?: number;
  83596. tessellation?: number;
  83597. arc?: number;
  83598. updatable?: boolean;
  83599. sideOrientation?: number;
  83600. frontUVs?: Vector4;
  83601. backUVs?: Vector4;
  83602. }, scene?: Nullable<Scene>): Mesh;
  83603. }
  83604. }
  83605. declare module BABYLON {
  83606. /**
  83607. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83608. *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.
  83609. * The SPS is also a particle system. It provides some methods to manage the particles.
  83610. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83611. *
  83612. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83613. */
  83614. export class SolidParticleSystem implements IDisposable {
  83615. /**
  83616. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83617. * Example : var p = SPS.particles[i];
  83618. */
  83619. particles: SolidParticle[];
  83620. /**
  83621. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83622. */
  83623. nbParticles: number;
  83624. /**
  83625. * If the particles must ever face the camera (default false). Useful for planar particles.
  83626. */
  83627. billboard: boolean;
  83628. /**
  83629. * Recompute normals when adding a shape
  83630. */
  83631. recomputeNormals: boolean;
  83632. /**
  83633. * This a counter ofr your own usage. It's not set by any SPS functions.
  83634. */
  83635. counter: number;
  83636. /**
  83637. * The SPS name. This name is also given to the underlying mesh.
  83638. */
  83639. name: string;
  83640. /**
  83641. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83642. */
  83643. mesh: Mesh;
  83644. /**
  83645. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83646. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83647. */
  83648. vars: any;
  83649. /**
  83650. * This array is populated when the SPS is set as 'pickable'.
  83651. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83652. * Each element of this array is an object `{idx: int, faceId: int}`.
  83653. * `idx` is the picked particle index in the `SPS.particles` array
  83654. * `faceId` is the picked face index counted within this particle.
  83655. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83656. */
  83657. pickedParticles: {
  83658. idx: number;
  83659. faceId: number;
  83660. }[];
  83661. /**
  83662. * This array is populated when `enableDepthSort` is set to true.
  83663. * Each element of this array is an instance of the class DepthSortedParticle.
  83664. */
  83665. depthSortedParticles: DepthSortedParticle[];
  83666. /**
  83667. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83668. * @hidden
  83669. */
  83670. _bSphereOnly: boolean;
  83671. /**
  83672. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83673. * @hidden
  83674. */
  83675. _bSphereRadiusFactor: number;
  83676. private _scene;
  83677. private _positions;
  83678. private _indices;
  83679. private _normals;
  83680. private _colors;
  83681. private _uvs;
  83682. private _indices32;
  83683. private _positions32;
  83684. private _normals32;
  83685. private _fixedNormal32;
  83686. private _colors32;
  83687. private _uvs32;
  83688. private _index;
  83689. private _updatable;
  83690. private _pickable;
  83691. private _isVisibilityBoxLocked;
  83692. private _alwaysVisible;
  83693. private _depthSort;
  83694. private _shapeCounter;
  83695. private _copy;
  83696. private _color;
  83697. private _computeParticleColor;
  83698. private _computeParticleTexture;
  83699. private _computeParticleRotation;
  83700. private _computeParticleVertex;
  83701. private _computeBoundingBox;
  83702. private _depthSortParticles;
  83703. private _camera;
  83704. private _mustUnrotateFixedNormals;
  83705. private _particlesIntersect;
  83706. private _needs32Bits;
  83707. /**
  83708. * Creates a SPS (Solid Particle System) object.
  83709. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83710. * @param scene (Scene) is the scene in which the SPS is added.
  83711. * @param options defines the options of the sps e.g.
  83712. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83713. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83714. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83715. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83716. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83717. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83718. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83719. */
  83720. constructor(name: string, scene: Scene, options?: {
  83721. updatable?: boolean;
  83722. isPickable?: boolean;
  83723. enableDepthSort?: boolean;
  83724. particleIntersection?: boolean;
  83725. boundingSphereOnly?: boolean;
  83726. bSphereRadiusFactor?: number;
  83727. });
  83728. /**
  83729. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83730. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83731. * @returns the created mesh
  83732. */
  83733. buildMesh(): Mesh;
  83734. /**
  83735. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83736. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83737. * Thus the particles generated from `digest()` have their property `position` set yet.
  83738. * @param mesh ( Mesh ) is the mesh to be digested
  83739. * @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
  83740. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83741. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83742. * @returns the current SPS
  83743. */
  83744. digest(mesh: Mesh, options?: {
  83745. facetNb?: number;
  83746. number?: number;
  83747. delta?: number;
  83748. }): SolidParticleSystem;
  83749. private _unrotateFixedNormals;
  83750. private _resetCopy;
  83751. private _meshBuilder;
  83752. private _posToShape;
  83753. private _uvsToShapeUV;
  83754. private _addParticle;
  83755. /**
  83756. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83757. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83758. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83759. * @param nb (positive integer) the number of particles to be created from this model
  83760. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83761. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83762. * @returns the number of shapes in the system
  83763. */
  83764. addShape(mesh: Mesh, nb: number, options?: {
  83765. positionFunction?: any;
  83766. vertexFunction?: any;
  83767. }): number;
  83768. private _rebuildParticle;
  83769. /**
  83770. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83771. * @returns the SPS.
  83772. */
  83773. rebuildMesh(): SolidParticleSystem;
  83774. /**
  83775. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83776. * This method calls `updateParticle()` for each particle of the SPS.
  83777. * For an animated SPS, it is usually called within the render loop.
  83778. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83779. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83780. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83781. * @returns the SPS.
  83782. */
  83783. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83784. /**
  83785. * Disposes the SPS.
  83786. */
  83787. dispose(): void;
  83788. /**
  83789. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83791. * @returns the SPS.
  83792. */
  83793. refreshVisibleSize(): SolidParticleSystem;
  83794. /**
  83795. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83796. * @param size the size (float) of the visibility box
  83797. * note : this doesn't lock the SPS mesh bounding box.
  83798. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83799. */
  83800. setVisibilityBox(size: number): void;
  83801. /**
  83802. * Gets whether the SPS as always visible or not
  83803. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83804. */
  83805. /**
  83806. * Sets the SPS as always visible or not
  83807. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83808. */
  83809. isAlwaysVisible: boolean;
  83810. /**
  83811. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83812. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83813. */
  83814. /**
  83815. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83816. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83817. */
  83818. isVisibilityBoxLocked: boolean;
  83819. /**
  83820. * Tells to `setParticles()` to compute the particle rotations or not.
  83821. * Default value : true. The SPS is faster when it's set to false.
  83822. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83823. */
  83824. /**
  83825. * Gets if `setParticles()` computes the particle rotations or not.
  83826. * Default value : true. The SPS is faster when it's set to false.
  83827. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83828. */
  83829. computeParticleRotation: boolean;
  83830. /**
  83831. * Tells to `setParticles()` to compute the particle colors or not.
  83832. * Default value : true. The SPS is faster when it's set to false.
  83833. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83834. */
  83835. /**
  83836. * Gets if `setParticles()` computes the particle colors or not.
  83837. * Default value : true. The SPS is faster when it's set to false.
  83838. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83839. */
  83840. computeParticleColor: boolean;
  83841. /**
  83842. * Gets if `setParticles()` computes the particle textures or not.
  83843. * Default value : true. The SPS is faster when it's set to false.
  83844. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83845. */
  83846. computeParticleTexture: boolean;
  83847. /**
  83848. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83849. * Default value : false. The SPS is faster when it's set to false.
  83850. * Note : the particle custom vertex positions aren't stored values.
  83851. */
  83852. /**
  83853. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83854. * Default value : false. The SPS is faster when it's set to false.
  83855. * Note : the particle custom vertex positions aren't stored values.
  83856. */
  83857. computeParticleVertex: boolean;
  83858. /**
  83859. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83860. */
  83861. /**
  83862. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83863. */
  83864. computeBoundingBox: boolean;
  83865. /**
  83866. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83867. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83868. * Default : `true`
  83869. */
  83870. /**
  83871. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83872. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83873. * Default : `true`
  83874. */
  83875. depthSortParticles: boolean;
  83876. /**
  83877. * This function does nothing. It may be overwritten to set all the particle first values.
  83878. * The SPS doesn't call this function, you may have to call it by your own.
  83879. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83880. */
  83881. initParticles(): void;
  83882. /**
  83883. * This function does nothing. It may be overwritten to recycle a particle.
  83884. * The SPS doesn't call this function, you may have to call it by your own.
  83885. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83886. * @param particle The particle to recycle
  83887. * @returns the recycled particle
  83888. */
  83889. recycleParticle(particle: SolidParticle): SolidParticle;
  83890. /**
  83891. * Updates a particle : this function should be overwritten by the user.
  83892. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83893. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83894. * @example : just set a particle position or velocity and recycle conditions
  83895. * @param particle The particle to update
  83896. * @returns the updated particle
  83897. */
  83898. updateParticle(particle: SolidParticle): SolidParticle;
  83899. /**
  83900. * Updates a vertex of a particle : it can be overwritten by the user.
  83901. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83902. * @param particle the current particle
  83903. * @param vertex the current index of the current particle
  83904. * @param pt the index of the current vertex in the particle shape
  83905. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83906. * @example : just set a vertex particle position
  83907. * @returns the updated vertex
  83908. */
  83909. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83910. /**
  83911. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83912. * This does nothing and may be overwritten by the user.
  83913. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83914. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83915. * @param update the boolean update value actually passed to setParticles()
  83916. */
  83917. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83918. /**
  83919. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83920. * This will be passed three parameters.
  83921. * This does nothing and may be overwritten by the user.
  83922. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83923. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83924. * @param update the boolean update value actually passed to setParticles()
  83925. */
  83926. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83927. }
  83928. }
  83929. declare module BABYLON {
  83930. /**
  83931. * Represents one particle of a solid particle system.
  83932. */
  83933. export class SolidParticle {
  83934. /**
  83935. * particle global index
  83936. */
  83937. idx: number;
  83938. /**
  83939. * The color of the particle
  83940. */
  83941. color: Nullable<Color4>;
  83942. /**
  83943. * The world space position of the particle.
  83944. */
  83945. position: Vector3;
  83946. /**
  83947. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83948. */
  83949. rotation: Vector3;
  83950. /**
  83951. * The world space rotation quaternion of the particle.
  83952. */
  83953. rotationQuaternion: Nullable<Quaternion>;
  83954. /**
  83955. * The scaling of the particle.
  83956. */
  83957. scaling: Vector3;
  83958. /**
  83959. * The uvs of the particle.
  83960. */
  83961. uvs: Vector4;
  83962. /**
  83963. * The current speed of the particle.
  83964. */
  83965. velocity: Vector3;
  83966. /**
  83967. * The pivot point in the particle local space.
  83968. */
  83969. pivot: Vector3;
  83970. /**
  83971. * Must the particle be translated from its pivot point in its local space ?
  83972. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83973. * Default : false
  83974. */
  83975. translateFromPivot: boolean;
  83976. /**
  83977. * Is the particle active or not ?
  83978. */
  83979. alive: boolean;
  83980. /**
  83981. * Is the particle visible or not ?
  83982. */
  83983. isVisible: boolean;
  83984. /**
  83985. * Index of this particle in the global "positions" array (Internal use)
  83986. * @hidden
  83987. */
  83988. _pos: number;
  83989. /**
  83990. * @hidden Index of this particle in the global "indices" array (Internal use)
  83991. */
  83992. _ind: number;
  83993. /**
  83994. * @hidden ModelShape of this particle (Internal use)
  83995. */
  83996. _model: ModelShape;
  83997. /**
  83998. * ModelShape id of this particle
  83999. */
  84000. shapeId: number;
  84001. /**
  84002. * Index of the particle in its shape id (Internal use)
  84003. */
  84004. idxInShape: number;
  84005. /**
  84006. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  84007. */
  84008. _modelBoundingInfo: BoundingInfo;
  84009. /**
  84010. * @hidden Particle BoundingInfo object (Internal use)
  84011. */
  84012. _boundingInfo: BoundingInfo;
  84013. /**
  84014. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  84015. */
  84016. _sps: SolidParticleSystem;
  84017. /**
  84018. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  84019. */
  84020. _stillInvisible: boolean;
  84021. /**
  84022. * @hidden Last computed particle rotation matrix
  84023. */
  84024. _rotationMatrix: number[];
  84025. /**
  84026. * Parent particle Id, if any.
  84027. * Default null.
  84028. */
  84029. parentId: Nullable<number>;
  84030. /**
  84031. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84032. * The possible values are :
  84033. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84034. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84035. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84036. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84037. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84038. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84039. * */
  84040. cullingStrategy: number;
  84041. /**
  84042. * @hidden Internal global position in the SPS.
  84043. */
  84044. _globalPosition: Vector3;
  84045. /**
  84046. * Creates a Solid Particle object.
  84047. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84048. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84049. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84050. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84051. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84052. * @param shapeId (integer) is the model shape identifier in the SPS.
  84053. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84054. * @param sps defines the sps it is associated to
  84055. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84056. */
  84057. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84058. /**
  84059. * Legacy support, changed scale to scaling
  84060. */
  84061. /**
  84062. * Legacy support, changed scale to scaling
  84063. */
  84064. scale: Vector3;
  84065. /**
  84066. * Legacy support, changed quaternion to rotationQuaternion
  84067. */
  84068. /**
  84069. * Legacy support, changed quaternion to rotationQuaternion
  84070. */
  84071. quaternion: Nullable<Quaternion>;
  84072. /**
  84073. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84074. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84075. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84076. * @returns true if it intersects
  84077. */
  84078. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84079. /**
  84080. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84081. * A particle is in the frustum if its bounding box intersects the frustum
  84082. * @param frustumPlanes defines the frustum to test
  84083. * @returns true if the particle is in the frustum planes
  84084. */
  84085. isInFrustum(frustumPlanes: Plane[]): boolean;
  84086. /**
  84087. * get the rotation matrix of the particle
  84088. * @hidden
  84089. */
  84090. getRotationMatrix(m: Matrix): void;
  84091. }
  84092. /**
  84093. * Represents the shape of the model used by one particle of a solid particle system.
  84094. * SPS internal tool, don't use it manually.
  84095. */
  84096. export class ModelShape {
  84097. /**
  84098. * The shape id
  84099. * @hidden
  84100. */
  84101. shapeID: number;
  84102. /**
  84103. * flat array of model positions (internal use)
  84104. * @hidden
  84105. */
  84106. _shape: Vector3[];
  84107. /**
  84108. * flat array of model UVs (internal use)
  84109. * @hidden
  84110. */
  84111. _shapeUV: number[];
  84112. /**
  84113. * length of the shape in the model indices array (internal use)
  84114. * @hidden
  84115. */
  84116. _indicesLength: number;
  84117. /**
  84118. * Custom position function (internal use)
  84119. * @hidden
  84120. */
  84121. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84122. /**
  84123. * Custom vertex function (internal use)
  84124. * @hidden
  84125. */
  84126. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84127. /**
  84128. * 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.
  84129. * SPS internal tool, don't use it manually.
  84130. * @hidden
  84131. */
  84132. 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>);
  84133. }
  84134. /**
  84135. * Represents a Depth Sorted Particle in the solid particle system.
  84136. */
  84137. export class DepthSortedParticle {
  84138. /**
  84139. * Index of the particle in the "indices" array
  84140. */
  84141. ind: number;
  84142. /**
  84143. * Length of the particle shape in the "indices" array
  84144. */
  84145. indicesLength: number;
  84146. /**
  84147. * Squared distance from the particle to the camera
  84148. */
  84149. sqDistance: number;
  84150. }
  84151. }
  84152. declare module BABYLON {
  84153. /**
  84154. * @hidden
  84155. */
  84156. export class _MeshCollisionData {
  84157. _checkCollisions: boolean;
  84158. _collisionMask: number;
  84159. _collisionGroup: number;
  84160. _collider: Nullable<Collider>;
  84161. _oldPositionForCollisions: Vector3;
  84162. _diffPositionForCollisions: Vector3;
  84163. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  84164. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  84165. }
  84166. }
  84167. declare module BABYLON {
  84168. /**
  84169. * Class used to store all common mesh properties
  84170. */
  84171. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84172. /** No occlusion */
  84173. static OCCLUSION_TYPE_NONE: number;
  84174. /** Occlusion set to optimisitic */
  84175. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84176. /** Occlusion set to strict */
  84177. static OCCLUSION_TYPE_STRICT: number;
  84178. /** Use an accurante occlusion algorithm */
  84179. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84180. /** Use a conservative occlusion algorithm */
  84181. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84182. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84183. * Test order :
  84184. * Is the bounding sphere outside the frustum ?
  84185. * If not, are the bounding box vertices outside the frustum ?
  84186. * It not, then the cullable object is in the frustum.
  84187. */
  84188. static readonly CULLINGSTRATEGY_STANDARD: number;
  84189. /** Culling strategy : Bounding Sphere Only.
  84190. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84191. * It's also less accurate than the standard because some not visible objects can still be selected.
  84192. * Test : is the bounding sphere outside the frustum ?
  84193. * If not, then the cullable object is in the frustum.
  84194. */
  84195. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84196. /** Culling strategy : Optimistic Inclusion.
  84197. * This in an inclusion test first, then the standard exclusion test.
  84198. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84199. * 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.
  84200. * Anyway, it's as accurate as the standard strategy.
  84201. * Test :
  84202. * Is the cullable object bounding sphere center in the frustum ?
  84203. * If not, apply the default culling strategy.
  84204. */
  84205. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84206. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84207. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84208. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84209. * 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.
  84210. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84211. * Test :
  84212. * Is the cullable object bounding sphere center in the frustum ?
  84213. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84214. */
  84215. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84216. /**
  84217. * No billboard
  84218. */
  84219. static readonly BILLBOARDMODE_NONE: number;
  84220. /** Billboard on X axis */
  84221. static readonly BILLBOARDMODE_X: number;
  84222. /** Billboard on Y axis */
  84223. static readonly BILLBOARDMODE_Y: number;
  84224. /** Billboard on Z axis */
  84225. static readonly BILLBOARDMODE_Z: number;
  84226. /** Billboard on all axes */
  84227. static readonly BILLBOARDMODE_ALL: number;
  84228. private _internalAbstractMeshDataInfo;
  84229. /**
  84230. * The culling strategy to use to check whether the mesh must be rendered or not.
  84231. * This value can be changed at any time and will be used on the next render mesh selection.
  84232. * The possible values are :
  84233. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84234. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84235. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84236. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84237. * Please read each static variable documentation to get details about the culling process.
  84238. * */
  84239. cullingStrategy: number;
  84240. /**
  84241. * Gets the number of facets in the mesh
  84242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84243. */
  84244. readonly facetNb: number;
  84245. /**
  84246. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84247. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84248. */
  84249. partitioningSubdivisions: number;
  84250. /**
  84251. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84252. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84253. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84254. */
  84255. partitioningBBoxRatio: number;
  84256. /**
  84257. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84258. * Works only for updatable meshes.
  84259. * Doesn't work with multi-materials
  84260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84261. */
  84262. mustDepthSortFacets: boolean;
  84263. /**
  84264. * The location (Vector3) where the facet depth sort must be computed from.
  84265. * By default, the active camera position.
  84266. * Used only when facet depth sort is enabled
  84267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84268. */
  84269. facetDepthSortFrom: Vector3;
  84270. /**
  84271. * gets a boolean indicating if facetData is enabled
  84272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84273. */
  84274. readonly isFacetDataEnabled: boolean;
  84275. /** @hidden */
  84276. _updateNonUniformScalingState(value: boolean): boolean;
  84277. /**
  84278. * An event triggered when this mesh collides with another one
  84279. */
  84280. onCollideObservable: Observable<AbstractMesh>;
  84281. /** Set a function to call when this mesh collides with another one */
  84282. onCollide: () => void;
  84283. /**
  84284. * An event triggered when the collision's position changes
  84285. */
  84286. onCollisionPositionChangeObservable: Observable<Vector3>;
  84287. /** Set a function to call when the collision's position changes */
  84288. onCollisionPositionChange: () => void;
  84289. /**
  84290. * An event triggered when material is changed
  84291. */
  84292. onMaterialChangedObservable: Observable<AbstractMesh>;
  84293. /**
  84294. * Gets or sets the orientation for POV movement & rotation
  84295. */
  84296. definedFacingForward: boolean;
  84297. /** @hidden */
  84298. _occlusionQuery: Nullable<WebGLQuery>;
  84299. /** @hidden */
  84300. _isActive: boolean;
  84301. /** @hidden */
  84302. _onlyForInstances: boolean;
  84303. /** @hidden */
  84304. _renderingGroup: Nullable<RenderingGroup>;
  84305. /**
  84306. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84307. */
  84308. /**
  84309. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84310. */
  84311. visibility: number;
  84312. /** Gets or sets the alpha index used to sort transparent meshes
  84313. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84314. */
  84315. alphaIndex: number;
  84316. /**
  84317. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84318. */
  84319. isVisible: boolean;
  84320. /**
  84321. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84322. */
  84323. isPickable: boolean;
  84324. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84325. showSubMeshesBoundingBox: boolean;
  84326. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84327. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84328. */
  84329. isBlocker: boolean;
  84330. /**
  84331. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84332. */
  84333. enablePointerMoveEvents: boolean;
  84334. /**
  84335. * Specifies the rendering group id for this mesh (0 by default)
  84336. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84337. */
  84338. renderingGroupId: number;
  84339. private _material;
  84340. /** Gets or sets current material */
  84341. material: Nullable<Material>;
  84342. /**
  84343. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84344. * @see http://doc.babylonjs.com/babylon101/shadows
  84345. */
  84346. receiveShadows: boolean;
  84347. /** Defines color to use when rendering outline */
  84348. outlineColor: Color3;
  84349. /** Define width to use when rendering outline */
  84350. outlineWidth: number;
  84351. /** Defines color to use when rendering overlay */
  84352. overlayColor: Color3;
  84353. /** Defines alpha to use when rendering overlay */
  84354. overlayAlpha: number;
  84355. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84356. hasVertexAlpha: boolean;
  84357. /** 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) */
  84358. useVertexColors: boolean;
  84359. /**
  84360. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84361. */
  84362. computeBonesUsingShaders: boolean;
  84363. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84364. numBoneInfluencers: number;
  84365. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84366. applyFog: boolean;
  84367. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84368. useOctreeForRenderingSelection: boolean;
  84369. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84370. useOctreeForPicking: boolean;
  84371. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84372. useOctreeForCollisions: boolean;
  84373. /**
  84374. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84375. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84376. */
  84377. layerMask: number;
  84378. /**
  84379. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84380. */
  84381. alwaysSelectAsActiveMesh: boolean;
  84382. /**
  84383. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84384. */
  84385. doNotSyncBoundingInfo: boolean;
  84386. /**
  84387. * Gets or sets the current action manager
  84388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84389. */
  84390. actionManager: Nullable<AbstractActionManager>;
  84391. private _meshCollisionData;
  84392. /**
  84393. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84395. */
  84396. ellipsoid: Vector3;
  84397. /**
  84398. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84399. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84400. */
  84401. ellipsoidOffset: Vector3;
  84402. /**
  84403. * Gets or sets a collision mask used to mask collisions (default is -1).
  84404. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84405. */
  84406. collisionMask: number;
  84407. /**
  84408. * Gets or sets the current collision group mask (-1 by default).
  84409. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84410. */
  84411. collisionGroup: number;
  84412. /**
  84413. * Defines edge width used when edgesRenderer is enabled
  84414. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84415. */
  84416. edgesWidth: number;
  84417. /**
  84418. * Defines edge color used when edgesRenderer is enabled
  84419. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84420. */
  84421. edgesColor: Color4;
  84422. /** @hidden */
  84423. _edgesRenderer: Nullable<IEdgesRenderer>;
  84424. /** @hidden */
  84425. _masterMesh: Nullable<AbstractMesh>;
  84426. /** @hidden */
  84427. _boundingInfo: Nullable<BoundingInfo>;
  84428. /** @hidden */
  84429. _renderId: number;
  84430. /**
  84431. * Gets or sets the list of subMeshes
  84432. * @see http://doc.babylonjs.com/how_to/multi_materials
  84433. */
  84434. subMeshes: SubMesh[];
  84435. /** @hidden */
  84436. _intersectionsInProgress: AbstractMesh[];
  84437. /** @hidden */
  84438. _unIndexed: boolean;
  84439. /** @hidden */
  84440. _lightSources: Light[];
  84441. /** Gets the list of lights affecting that mesh */
  84442. readonly lightSources: Light[];
  84443. /** @hidden */
  84444. readonly _positions: Nullable<Vector3[]>;
  84445. /** @hidden */
  84446. _waitingData: {
  84447. lods: Nullable<any>;
  84448. actions: Nullable<any>;
  84449. freezeWorldMatrix: Nullable<boolean>;
  84450. };
  84451. /** @hidden */
  84452. _bonesTransformMatrices: Nullable<Float32Array>;
  84453. /**
  84454. * Gets or sets a skeleton to apply skining transformations
  84455. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84456. */
  84457. skeleton: Nullable<Skeleton>;
  84458. /**
  84459. * An event triggered when the mesh is rebuilt.
  84460. */
  84461. onRebuildObservable: Observable<AbstractMesh>;
  84462. /**
  84463. * Creates a new AbstractMesh
  84464. * @param name defines the name of the mesh
  84465. * @param scene defines the hosting scene
  84466. */
  84467. constructor(name: string, scene?: Nullable<Scene>);
  84468. /**
  84469. * Returns the string "AbstractMesh"
  84470. * @returns "AbstractMesh"
  84471. */
  84472. getClassName(): string;
  84473. /**
  84474. * Gets a string representation of the current mesh
  84475. * @param fullDetails defines a boolean indicating if full details must be included
  84476. * @returns a string representation of the current mesh
  84477. */
  84478. toString(fullDetails?: boolean): string;
  84479. /**
  84480. * @hidden
  84481. */
  84482. protected _getEffectiveParent(): Nullable<Node>;
  84483. /** @hidden */
  84484. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84485. /** @hidden */
  84486. _rebuild(): void;
  84487. /** @hidden */
  84488. _resyncLightSources(): void;
  84489. /** @hidden */
  84490. _resyncLighSource(light: Light): void;
  84491. /** @hidden */
  84492. _unBindEffect(): void;
  84493. /** @hidden */
  84494. _removeLightSource(light: Light): void;
  84495. private _markSubMeshesAsDirty;
  84496. /** @hidden */
  84497. _markSubMeshesAsLightDirty(): void;
  84498. /** @hidden */
  84499. _markSubMeshesAsAttributesDirty(): void;
  84500. /** @hidden */
  84501. _markSubMeshesAsMiscDirty(): void;
  84502. /**
  84503. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84504. */
  84505. scaling: Vector3;
  84506. /**
  84507. * Returns true if the mesh is blocked. Implemented by child classes
  84508. */
  84509. readonly isBlocked: boolean;
  84510. /**
  84511. * Returns the mesh itself by default. Implemented by child classes
  84512. * @param camera defines the camera to use to pick the right LOD level
  84513. * @returns the currentAbstractMesh
  84514. */
  84515. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84516. /**
  84517. * Returns 0 by default. Implemented by child classes
  84518. * @returns an integer
  84519. */
  84520. getTotalVertices(): number;
  84521. /**
  84522. * Returns a positive integer : the total number of indices in this mesh geometry.
  84523. * @returns the numner of indices or zero if the mesh has no geometry.
  84524. */
  84525. getTotalIndices(): number;
  84526. /**
  84527. * Returns null by default. Implemented by child classes
  84528. * @returns null
  84529. */
  84530. getIndices(): Nullable<IndicesArray>;
  84531. /**
  84532. * Returns the array of the requested vertex data kind. Implemented by child classes
  84533. * @param kind defines the vertex data kind to use
  84534. * @returns null
  84535. */
  84536. getVerticesData(kind: string): Nullable<FloatArray>;
  84537. /**
  84538. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84539. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84540. * Note that a new underlying VertexBuffer object is created each call.
  84541. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84542. * @param kind defines vertex data kind:
  84543. * * VertexBuffer.PositionKind
  84544. * * VertexBuffer.UVKind
  84545. * * VertexBuffer.UV2Kind
  84546. * * VertexBuffer.UV3Kind
  84547. * * VertexBuffer.UV4Kind
  84548. * * VertexBuffer.UV5Kind
  84549. * * VertexBuffer.UV6Kind
  84550. * * VertexBuffer.ColorKind
  84551. * * VertexBuffer.MatricesIndicesKind
  84552. * * VertexBuffer.MatricesIndicesExtraKind
  84553. * * VertexBuffer.MatricesWeightsKind
  84554. * * VertexBuffer.MatricesWeightsExtraKind
  84555. * @param data defines the data source
  84556. * @param updatable defines if the data must be flagged as updatable (or static)
  84557. * @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
  84558. * @returns the current mesh
  84559. */
  84560. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84561. /**
  84562. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84563. * If the mesh has no geometry, it is simply returned as it is.
  84564. * @param kind defines vertex data kind:
  84565. * * VertexBuffer.PositionKind
  84566. * * VertexBuffer.UVKind
  84567. * * VertexBuffer.UV2Kind
  84568. * * VertexBuffer.UV3Kind
  84569. * * VertexBuffer.UV4Kind
  84570. * * VertexBuffer.UV5Kind
  84571. * * VertexBuffer.UV6Kind
  84572. * * VertexBuffer.ColorKind
  84573. * * VertexBuffer.MatricesIndicesKind
  84574. * * VertexBuffer.MatricesIndicesExtraKind
  84575. * * VertexBuffer.MatricesWeightsKind
  84576. * * VertexBuffer.MatricesWeightsExtraKind
  84577. * @param data defines the data source
  84578. * @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
  84579. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84580. * @returns the current mesh
  84581. */
  84582. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84583. /**
  84584. * Sets the mesh indices,
  84585. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84586. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84587. * @param totalVertices Defines the total number of vertices
  84588. * @returns the current mesh
  84589. */
  84590. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84591. /**
  84592. * Gets a boolean indicating if specific vertex data is present
  84593. * @param kind defines the vertex data kind to use
  84594. * @returns true is data kind is present
  84595. */
  84596. isVerticesDataPresent(kind: string): boolean;
  84597. /**
  84598. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84599. * @returns a BoundingInfo
  84600. */
  84601. getBoundingInfo(): BoundingInfo;
  84602. /**
  84603. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84604. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84605. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84606. * @returns the current mesh
  84607. */
  84608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84609. /**
  84610. * Overwrite the current bounding info
  84611. * @param boundingInfo defines the new bounding info
  84612. * @returns the current mesh
  84613. */
  84614. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84615. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84616. readonly useBones: boolean;
  84617. /** @hidden */
  84618. _preActivate(): void;
  84619. /** @hidden */
  84620. _preActivateForIntermediateRendering(renderId: number): void;
  84621. /** @hidden */
  84622. _activate(renderId: number): boolean;
  84623. /** @hidden */
  84624. _postActivate(): void;
  84625. /** @hidden */
  84626. _freeze(): void;
  84627. /** @hidden */
  84628. _unFreeze(): void;
  84629. /**
  84630. * Gets the current world matrix
  84631. * @returns a Matrix
  84632. */
  84633. getWorldMatrix(): Matrix;
  84634. /** @hidden */
  84635. _getWorldMatrixDeterminant(): number;
  84636. /**
  84637. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84638. */
  84639. readonly isAnInstance: boolean;
  84640. /**
  84641. * Perform relative position change from the point of view of behind the front of the mesh.
  84642. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84643. * Supports definition of mesh facing forward or backward
  84644. * @param amountRight defines the distance on the right axis
  84645. * @param amountUp defines the distance on the up axis
  84646. * @param amountForward defines the distance on the forward axis
  84647. * @returns the current mesh
  84648. */
  84649. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84650. /**
  84651. * Calculate relative position change from the point of view of behind the front of the mesh.
  84652. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84653. * Supports definition of mesh facing forward or backward
  84654. * @param amountRight defines the distance on the right axis
  84655. * @param amountUp defines the distance on the up axis
  84656. * @param amountForward defines the distance on the forward axis
  84657. * @returns the new displacement vector
  84658. */
  84659. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84660. /**
  84661. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84662. * Supports definition of mesh facing forward or backward
  84663. * @param flipBack defines the flip
  84664. * @param twirlClockwise defines the twirl
  84665. * @param tiltRight defines the tilt
  84666. * @returns the current mesh
  84667. */
  84668. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84669. /**
  84670. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84671. * Supports definition of mesh facing forward or backward.
  84672. * @param flipBack defines the flip
  84673. * @param twirlClockwise defines the twirl
  84674. * @param tiltRight defines the tilt
  84675. * @returns the new rotation vector
  84676. */
  84677. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84678. /**
  84679. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84680. * This means the mesh underlying bounding box and sphere are recomputed.
  84681. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84682. * @returns the current mesh
  84683. */
  84684. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84685. /** @hidden */
  84686. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84687. /** @hidden */
  84688. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84689. /** @hidden */
  84690. _updateBoundingInfo(): AbstractMesh;
  84691. /** @hidden */
  84692. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84693. /** @hidden */
  84694. protected _afterComputeWorldMatrix(): void;
  84695. /** @hidden */
  84696. readonly _effectiveMesh: AbstractMesh;
  84697. /**
  84698. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84699. * A mesh is in the frustum if its bounding box intersects the frustum
  84700. * @param frustumPlanes defines the frustum to test
  84701. * @returns true if the mesh is in the frustum planes
  84702. */
  84703. isInFrustum(frustumPlanes: Plane[]): boolean;
  84704. /**
  84705. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84706. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84707. * @param frustumPlanes defines the frustum to test
  84708. * @returns true if the mesh is completely in the frustum planes
  84709. */
  84710. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84711. /**
  84712. * True if the mesh intersects another mesh or a SolidParticle object
  84713. * @param mesh defines a target mesh or SolidParticle to test
  84714. * @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)
  84715. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84716. * @returns true if there is an intersection
  84717. */
  84718. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84719. /**
  84720. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84721. * @param point defines the point to test
  84722. * @returns true if there is an intersection
  84723. */
  84724. intersectsPoint(point: Vector3): boolean;
  84725. /**
  84726. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84727. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84728. */
  84729. checkCollisions: boolean;
  84730. /**
  84731. * Gets Collider object used to compute collisions (not physics)
  84732. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84733. */
  84734. readonly collider: Nullable<Collider>;
  84735. /**
  84736. * Move the mesh using collision engine
  84737. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84738. * @param displacement defines the requested displacement vector
  84739. * @returns the current mesh
  84740. */
  84741. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84742. private _onCollisionPositionChange;
  84743. /** @hidden */
  84744. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84745. /** @hidden */
  84746. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84747. /** @hidden */
  84748. _checkCollision(collider: Collider): AbstractMesh;
  84749. /** @hidden */
  84750. _generatePointsArray(): boolean;
  84751. /**
  84752. * Checks if the passed Ray intersects with the mesh
  84753. * @param ray defines the ray to use
  84754. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84755. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84756. * @returns the picking info
  84757. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84758. */
  84759. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84760. /**
  84761. * Clones the current mesh
  84762. * @param name defines the mesh name
  84763. * @param newParent defines the new mesh parent
  84764. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84765. * @returns the new mesh
  84766. */
  84767. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84768. /**
  84769. * Disposes all the submeshes of the current meshnp
  84770. * @returns the current mesh
  84771. */
  84772. releaseSubMeshes(): AbstractMesh;
  84773. /**
  84774. * Releases resources associated with this abstract mesh.
  84775. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84776. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84777. */
  84778. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84779. /**
  84780. * Adds the passed mesh as a child to the current mesh
  84781. * @param mesh defines the child mesh
  84782. * @returns the current mesh
  84783. */
  84784. addChild(mesh: AbstractMesh): AbstractMesh;
  84785. /**
  84786. * Removes the passed mesh from the current mesh children list
  84787. * @param mesh defines the child mesh
  84788. * @returns the current mesh
  84789. */
  84790. removeChild(mesh: AbstractMesh): AbstractMesh;
  84791. /** @hidden */
  84792. private _initFacetData;
  84793. /**
  84794. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84795. * This method can be called within the render loop.
  84796. * 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
  84797. * @returns the current mesh
  84798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84799. */
  84800. updateFacetData(): AbstractMesh;
  84801. /**
  84802. * Returns the facetLocalNormals array.
  84803. * The normals are expressed in the mesh local spac
  84804. * @returns an array of Vector3
  84805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84806. */
  84807. getFacetLocalNormals(): Vector3[];
  84808. /**
  84809. * Returns the facetLocalPositions array.
  84810. * The facet positions are expressed in the mesh local space
  84811. * @returns an array of Vector3
  84812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84813. */
  84814. getFacetLocalPositions(): Vector3[];
  84815. /**
  84816. * Returns the facetLocalPartioning array
  84817. * @returns an array of array of numbers
  84818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84819. */
  84820. getFacetLocalPartitioning(): number[][];
  84821. /**
  84822. * Returns the i-th facet position in the world system.
  84823. * This method allocates a new Vector3 per call
  84824. * @param i defines the facet index
  84825. * @returns a new Vector3
  84826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84827. */
  84828. getFacetPosition(i: number): Vector3;
  84829. /**
  84830. * Sets the reference Vector3 with the i-th facet position in the world system
  84831. * @param i defines the facet index
  84832. * @param ref defines the target vector
  84833. * @returns the current mesh
  84834. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84835. */
  84836. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84837. /**
  84838. * Returns the i-th facet normal in the world system.
  84839. * This method allocates a new Vector3 per call
  84840. * @param i defines the facet index
  84841. * @returns a new Vector3
  84842. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84843. */
  84844. getFacetNormal(i: number): Vector3;
  84845. /**
  84846. * Sets the reference Vector3 with the i-th facet normal in the world system
  84847. * @param i defines the facet index
  84848. * @param ref defines the target vector
  84849. * @returns the current mesh
  84850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84851. */
  84852. getFacetNormalToRef(i: number, ref: Vector3): this;
  84853. /**
  84854. * 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)
  84855. * @param x defines x coordinate
  84856. * @param y defines y coordinate
  84857. * @param z defines z coordinate
  84858. * @returns the array of facet indexes
  84859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84860. */
  84861. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84862. /**
  84863. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84864. * @param projected sets as the (x,y,z) world projection on the facet
  84865. * @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
  84866. * @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
  84867. * @param x defines x coordinate
  84868. * @param y defines y coordinate
  84869. * @param z defines z coordinate
  84870. * @returns the face index if found (or null instead)
  84871. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84872. */
  84873. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84874. /**
  84875. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84876. * @param projected sets as the (x,y,z) local projection on the facet
  84877. * @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
  84878. * @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
  84879. * @param x defines x coordinate
  84880. * @param y defines y coordinate
  84881. * @param z defines z coordinate
  84882. * @returns the face index if found (or null instead)
  84883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84884. */
  84885. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84886. /**
  84887. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84888. * @returns the parameters
  84889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84890. */
  84891. getFacetDataParameters(): any;
  84892. /**
  84893. * Disables the feature FacetData and frees the related memory
  84894. * @returns the current mesh
  84895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84896. */
  84897. disableFacetData(): AbstractMesh;
  84898. /**
  84899. * Updates the AbstractMesh indices array
  84900. * @param indices defines the data source
  84901. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84902. * @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)
  84903. * @returns the current mesh
  84904. */
  84905. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84906. /**
  84907. * Creates new normals data for the mesh
  84908. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84909. * @returns the current mesh
  84910. */
  84911. createNormals(updatable: boolean): AbstractMesh;
  84912. /**
  84913. * Align the mesh with a normal
  84914. * @param normal defines the normal to use
  84915. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84916. * @returns the current mesh
  84917. */
  84918. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84919. /** @hidden */
  84920. _checkOcclusionQuery(): boolean;
  84921. }
  84922. }
  84923. declare module BABYLON {
  84924. /**
  84925. * Interface used to define ActionEvent
  84926. */
  84927. export interface IActionEvent {
  84928. /** The mesh or sprite that triggered the action */
  84929. source: any;
  84930. /** The X mouse cursor position at the time of the event */
  84931. pointerX: number;
  84932. /** The Y mouse cursor position at the time of the event */
  84933. pointerY: number;
  84934. /** The mesh that is currently pointed at (can be null) */
  84935. meshUnderPointer: Nullable<AbstractMesh>;
  84936. /** the original (browser) event that triggered the ActionEvent */
  84937. sourceEvent?: any;
  84938. /** additional data for the event */
  84939. additionalData?: any;
  84940. }
  84941. /**
  84942. * ActionEvent is the event being sent when an action is triggered.
  84943. */
  84944. export class ActionEvent implements IActionEvent {
  84945. /** The mesh or sprite that triggered the action */
  84946. source: any;
  84947. /** The X mouse cursor position at the time of the event */
  84948. pointerX: number;
  84949. /** The Y mouse cursor position at the time of the event */
  84950. pointerY: number;
  84951. /** The mesh that is currently pointed at (can be null) */
  84952. meshUnderPointer: Nullable<AbstractMesh>;
  84953. /** the original (browser) event that triggered the ActionEvent */
  84954. sourceEvent?: any;
  84955. /** additional data for the event */
  84956. additionalData?: any;
  84957. /**
  84958. * Creates a new ActionEvent
  84959. * @param source The mesh or sprite that triggered the action
  84960. * @param pointerX The X mouse cursor position at the time of the event
  84961. * @param pointerY The Y mouse cursor position at the time of the event
  84962. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84963. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84964. * @param additionalData additional data for the event
  84965. */
  84966. constructor(
  84967. /** The mesh or sprite that triggered the action */
  84968. source: any,
  84969. /** The X mouse cursor position at the time of the event */
  84970. pointerX: number,
  84971. /** The Y mouse cursor position at the time of the event */
  84972. pointerY: number,
  84973. /** The mesh that is currently pointed at (can be null) */
  84974. meshUnderPointer: Nullable<AbstractMesh>,
  84975. /** the original (browser) event that triggered the ActionEvent */
  84976. sourceEvent?: any,
  84977. /** additional data for the event */
  84978. additionalData?: any);
  84979. /**
  84980. * Helper function to auto-create an ActionEvent from a source mesh.
  84981. * @param source The source mesh that triggered the event
  84982. * @param evt The original (browser) event
  84983. * @param additionalData additional data for the event
  84984. * @returns the new ActionEvent
  84985. */
  84986. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84987. /**
  84988. * Helper function to auto-create an ActionEvent from a source sprite
  84989. * @param source The source sprite that triggered the event
  84990. * @param scene Scene associated with the sprite
  84991. * @param evt The original (browser) event
  84992. * @param additionalData additional data for the event
  84993. * @returns the new ActionEvent
  84994. */
  84995. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84996. /**
  84997. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84998. * @param scene the scene where the event occurred
  84999. * @param evt The original (browser) event
  85000. * @returns the new ActionEvent
  85001. */
  85002. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  85003. /**
  85004. * Helper function to auto-create an ActionEvent from a primitive
  85005. * @param prim defines the target primitive
  85006. * @param pointerPos defines the pointer position
  85007. * @param evt The original (browser) event
  85008. * @param additionalData additional data for the event
  85009. * @returns the new ActionEvent
  85010. */
  85011. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  85012. }
  85013. }
  85014. declare module BABYLON {
  85015. /**
  85016. * Abstract class used to decouple action Manager from scene and meshes.
  85017. * Do not instantiate.
  85018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  85019. */
  85020. export abstract class AbstractActionManager implements IDisposable {
  85021. /** Gets the list of active triggers */
  85022. static Triggers: {
  85023. [key: string]: number;
  85024. };
  85025. /** Gets the cursor to use when hovering items */
  85026. hoverCursor: string;
  85027. /** Gets the list of actions */
  85028. actions: IAction[];
  85029. /**
  85030. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85031. */
  85032. isRecursive: boolean;
  85033. /**
  85034. * Releases all associated resources
  85035. */
  85036. abstract dispose(): void;
  85037. /**
  85038. * Does this action manager has pointer triggers
  85039. */
  85040. abstract readonly hasPointerTriggers: boolean;
  85041. /**
  85042. * Does this action manager has pick triggers
  85043. */
  85044. abstract readonly hasPickTriggers: boolean;
  85045. /**
  85046. * Process a specific trigger
  85047. * @param trigger defines the trigger to process
  85048. * @param evt defines the event details to be processed
  85049. */
  85050. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85051. /**
  85052. * Does this action manager handles actions of any of the given triggers
  85053. * @param triggers defines the triggers to be tested
  85054. * @return a boolean indicating whether one (or more) of the triggers is handled
  85055. */
  85056. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85057. /**
  85058. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85059. * speed.
  85060. * @param triggerA defines the trigger to be tested
  85061. * @param triggerB defines the trigger to be tested
  85062. * @return a boolean indicating whether one (or more) of the triggers is handled
  85063. */
  85064. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85065. /**
  85066. * Does this action manager handles actions of a given trigger
  85067. * @param trigger defines the trigger to be tested
  85068. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85069. * @return whether the trigger is handled
  85070. */
  85071. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85072. /**
  85073. * Serialize this manager to a JSON object
  85074. * @param name defines the property name to store this manager
  85075. * @returns a JSON representation of this manager
  85076. */
  85077. abstract serialize(name: string): any;
  85078. /**
  85079. * Registers an action to this action manager
  85080. * @param action defines the action to be registered
  85081. * @return the action amended (prepared) after registration
  85082. */
  85083. abstract registerAction(action: IAction): Nullable<IAction>;
  85084. /**
  85085. * Unregisters an action to this action manager
  85086. * @param action defines the action to be unregistered
  85087. * @return a boolean indicating whether the action has been unregistered
  85088. */
  85089. abstract unregisterAction(action: IAction): Boolean;
  85090. /**
  85091. * Does exist one action manager with at least one trigger
  85092. **/
  85093. static readonly HasTriggers: boolean;
  85094. /**
  85095. * Does exist one action manager with at least one pick trigger
  85096. **/
  85097. static readonly HasPickTriggers: boolean;
  85098. /**
  85099. * Does exist one action manager that handles actions of a given trigger
  85100. * @param trigger defines the trigger to be tested
  85101. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85102. **/
  85103. static HasSpecificTrigger(trigger: number): boolean;
  85104. }
  85105. }
  85106. declare module BABYLON {
  85107. /**
  85108. * Defines how a node can be built from a string name.
  85109. */
  85110. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85111. /**
  85112. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85113. */
  85114. export class Node implements IBehaviorAware<Node> {
  85115. /** @hidden */
  85116. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85117. private static _NodeConstructors;
  85118. /**
  85119. * Add a new node constructor
  85120. * @param type defines the type name of the node to construct
  85121. * @param constructorFunc defines the constructor function
  85122. */
  85123. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85124. /**
  85125. * Returns a node constructor based on type name
  85126. * @param type defines the type name
  85127. * @param name defines the new node name
  85128. * @param scene defines the hosting scene
  85129. * @param options defines optional options to transmit to constructors
  85130. * @returns the new constructor or null
  85131. */
  85132. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85133. /**
  85134. * Gets or sets the name of the node
  85135. */
  85136. name: string;
  85137. /**
  85138. * Gets or sets the id of the node
  85139. */
  85140. id: string;
  85141. /**
  85142. * Gets or sets the unique id of the node
  85143. */
  85144. uniqueId: number;
  85145. /**
  85146. * Gets or sets a string used to store user defined state for the node
  85147. */
  85148. state: string;
  85149. /**
  85150. * Gets or sets an object used to store user defined information for the node
  85151. */
  85152. metadata: any;
  85153. /**
  85154. * For internal use only. Please do not use.
  85155. */
  85156. reservedDataStore: any;
  85157. /**
  85158. * List of inspectable custom properties (used by the Inspector)
  85159. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85160. */
  85161. inspectableCustomProperties: IInspectable[];
  85162. /**
  85163. * Gets or sets a boolean used to define if the node must be serialized
  85164. */
  85165. doNotSerialize: boolean;
  85166. /** @hidden */
  85167. _isDisposed: boolean;
  85168. /**
  85169. * Gets a list of Animations associated with the node
  85170. */
  85171. animations: Animation[];
  85172. protected _ranges: {
  85173. [name: string]: Nullable<AnimationRange>;
  85174. };
  85175. /**
  85176. * Callback raised when the node is ready to be used
  85177. */
  85178. onReady: Nullable<(node: Node) => void>;
  85179. private _isEnabled;
  85180. private _isParentEnabled;
  85181. private _isReady;
  85182. /** @hidden */
  85183. _currentRenderId: number;
  85184. private _parentUpdateId;
  85185. /** @hidden */
  85186. _childUpdateId: number;
  85187. /** @hidden */
  85188. _waitingParentId: Nullable<string>;
  85189. /** @hidden */
  85190. _scene: Scene;
  85191. /** @hidden */
  85192. _cache: any;
  85193. private _parentNode;
  85194. private _children;
  85195. /** @hidden */
  85196. _worldMatrix: Matrix;
  85197. /** @hidden */
  85198. _worldMatrixDeterminant: number;
  85199. /** @hidden */
  85200. _worldMatrixDeterminantIsDirty: boolean;
  85201. /** @hidden */
  85202. private _sceneRootNodesIndex;
  85203. /**
  85204. * Gets a boolean indicating if the node has been disposed
  85205. * @returns true if the node was disposed
  85206. */
  85207. isDisposed(): boolean;
  85208. /**
  85209. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85210. * @see https://doc.babylonjs.com/how_to/parenting
  85211. */
  85212. parent: Nullable<Node>;
  85213. private addToSceneRootNodes;
  85214. private removeFromSceneRootNodes;
  85215. private _animationPropertiesOverride;
  85216. /**
  85217. * Gets or sets the animation properties override
  85218. */
  85219. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85220. /**
  85221. * Gets a string idenfifying the name of the class
  85222. * @returns "Node" string
  85223. */
  85224. getClassName(): string;
  85225. /** @hidden */
  85226. readonly _isNode: boolean;
  85227. /**
  85228. * An event triggered when the mesh is disposed
  85229. */
  85230. onDisposeObservable: Observable<Node>;
  85231. private _onDisposeObserver;
  85232. /**
  85233. * Sets a callback that will be raised when the node will be disposed
  85234. */
  85235. onDispose: () => void;
  85236. /**
  85237. * Creates a new Node
  85238. * @param name the name and id to be given to this node
  85239. * @param scene the scene this node will be added to
  85240. * @param addToRootNodes the node will be added to scene.rootNodes
  85241. */
  85242. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85243. /**
  85244. * Gets the scene of the node
  85245. * @returns a scene
  85246. */
  85247. getScene(): Scene;
  85248. /**
  85249. * Gets the engine of the node
  85250. * @returns a Engine
  85251. */
  85252. getEngine(): Engine;
  85253. private _behaviors;
  85254. /**
  85255. * Attach a behavior to the node
  85256. * @see http://doc.babylonjs.com/features/behaviour
  85257. * @param behavior defines the behavior to attach
  85258. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85259. * @returns the current Node
  85260. */
  85261. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85262. /**
  85263. * Remove an attached behavior
  85264. * @see http://doc.babylonjs.com/features/behaviour
  85265. * @param behavior defines the behavior to attach
  85266. * @returns the current Node
  85267. */
  85268. removeBehavior(behavior: Behavior<Node>): Node;
  85269. /**
  85270. * Gets the list of attached behaviors
  85271. * @see http://doc.babylonjs.com/features/behaviour
  85272. */
  85273. readonly behaviors: Behavior<Node>[];
  85274. /**
  85275. * Gets an attached behavior by name
  85276. * @param name defines the name of the behavior to look for
  85277. * @see http://doc.babylonjs.com/features/behaviour
  85278. * @returns null if behavior was not found else the requested behavior
  85279. */
  85280. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85281. /**
  85282. * Returns the latest update of the World matrix
  85283. * @returns a Matrix
  85284. */
  85285. getWorldMatrix(): Matrix;
  85286. /** @hidden */
  85287. _getWorldMatrixDeterminant(): number;
  85288. /**
  85289. * Returns directly the latest state of the mesh World matrix.
  85290. * A Matrix is returned.
  85291. */
  85292. readonly worldMatrixFromCache: Matrix;
  85293. /** @hidden */
  85294. _initCache(): void;
  85295. /** @hidden */
  85296. updateCache(force?: boolean): void;
  85297. /** @hidden */
  85298. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85299. /** @hidden */
  85300. _updateCache(ignoreParentClass?: boolean): void;
  85301. /** @hidden */
  85302. _isSynchronized(): boolean;
  85303. /** @hidden */
  85304. _markSyncedWithParent(): void;
  85305. /** @hidden */
  85306. isSynchronizedWithParent(): boolean;
  85307. /** @hidden */
  85308. isSynchronized(): boolean;
  85309. /**
  85310. * Is this node ready to be used/rendered
  85311. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85312. * @return true if the node is ready
  85313. */
  85314. isReady(completeCheck?: boolean): boolean;
  85315. /**
  85316. * Is this node enabled?
  85317. * 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
  85318. * @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
  85319. * @return whether this node (and its parent) is enabled
  85320. */
  85321. isEnabled(checkAncestors?: boolean): boolean;
  85322. /** @hidden */
  85323. protected _syncParentEnabledState(): void;
  85324. /**
  85325. * Set the enabled state of this node
  85326. * @param value defines the new enabled state
  85327. */
  85328. setEnabled(value: boolean): void;
  85329. /**
  85330. * Is this node a descendant of the given node?
  85331. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85332. * @param ancestor defines the parent node to inspect
  85333. * @returns a boolean indicating if this node is a descendant of the given node
  85334. */
  85335. isDescendantOf(ancestor: Node): boolean;
  85336. /** @hidden */
  85337. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85338. /**
  85339. * Will return all nodes that have this node as ascendant
  85340. * @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
  85341. * @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
  85342. * @return all children nodes of all types
  85343. */
  85344. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85345. /**
  85346. * Get all child-meshes of this node
  85347. * @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)
  85348. * @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
  85349. * @returns an array of AbstractMesh
  85350. */
  85351. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85352. /**
  85353. * Get all direct children of this node
  85354. * @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
  85355. * @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)
  85356. * @returns an array of Node
  85357. */
  85358. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85359. /** @hidden */
  85360. _setReady(state: boolean): void;
  85361. /**
  85362. * Get an animation by name
  85363. * @param name defines the name of the animation to look for
  85364. * @returns null if not found else the requested animation
  85365. */
  85366. getAnimationByName(name: string): Nullable<Animation>;
  85367. /**
  85368. * Creates an animation range for this node
  85369. * @param name defines the name of the range
  85370. * @param from defines the starting key
  85371. * @param to defines the end key
  85372. */
  85373. createAnimationRange(name: string, from: number, to: number): void;
  85374. /**
  85375. * Delete a specific animation range
  85376. * @param name defines the name of the range to delete
  85377. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85378. */
  85379. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85380. /**
  85381. * Get an animation range by name
  85382. * @param name defines the name of the animation range to look for
  85383. * @returns null if not found else the requested animation range
  85384. */
  85385. getAnimationRange(name: string): Nullable<AnimationRange>;
  85386. /**
  85387. * Gets the list of all animation ranges defined on this node
  85388. * @returns an array
  85389. */
  85390. getAnimationRanges(): Nullable<AnimationRange>[];
  85391. /**
  85392. * Will start the animation sequence
  85393. * @param name defines the range frames for animation sequence
  85394. * @param loop defines if the animation should loop (false by default)
  85395. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85396. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85397. * @returns the object created for this animation. If range does not exist, it will return null
  85398. */
  85399. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85400. /**
  85401. * Serialize animation ranges into a JSON compatible object
  85402. * @returns serialization object
  85403. */
  85404. serializeAnimationRanges(): any;
  85405. /**
  85406. * Computes the world matrix of the node
  85407. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85408. * @returns the world matrix
  85409. */
  85410. computeWorldMatrix(force?: boolean): Matrix;
  85411. /**
  85412. * Releases resources associated with this node.
  85413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85415. */
  85416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85417. /**
  85418. * Parse animation range data from a serialization object and store them into a given node
  85419. * @param node defines where to store the animation ranges
  85420. * @param parsedNode defines the serialization object to read data from
  85421. * @param scene defines the hosting scene
  85422. */
  85423. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85424. /**
  85425. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85426. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85427. * @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
  85428. * @returns the new bounding vectors
  85429. */
  85430. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85431. min: Vector3;
  85432. max: Vector3;
  85433. };
  85434. }
  85435. }
  85436. declare module BABYLON {
  85437. /**
  85438. * @hidden
  85439. */
  85440. export class _IAnimationState {
  85441. key: number;
  85442. repeatCount: number;
  85443. workValue?: any;
  85444. loopMode?: number;
  85445. offsetValue?: any;
  85446. highLimitValue?: any;
  85447. }
  85448. /**
  85449. * Class used to store any kind of animation
  85450. */
  85451. export class Animation {
  85452. /**Name of the animation */
  85453. name: string;
  85454. /**Property to animate */
  85455. targetProperty: string;
  85456. /**The frames per second of the animation */
  85457. framePerSecond: number;
  85458. /**The data type of the animation */
  85459. dataType: number;
  85460. /**The loop mode of the animation */
  85461. loopMode?: number | undefined;
  85462. /**Specifies if blending should be enabled */
  85463. enableBlending?: boolean | undefined;
  85464. /**
  85465. * Use matrix interpolation instead of using direct key value when animating matrices
  85466. */
  85467. static AllowMatricesInterpolation: boolean;
  85468. /**
  85469. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85470. */
  85471. static AllowMatrixDecomposeForInterpolation: boolean;
  85472. /**
  85473. * Stores the key frames of the animation
  85474. */
  85475. private _keys;
  85476. /**
  85477. * Stores the easing function of the animation
  85478. */
  85479. private _easingFunction;
  85480. /**
  85481. * @hidden Internal use only
  85482. */
  85483. _runtimeAnimations: RuntimeAnimation[];
  85484. /**
  85485. * The set of event that will be linked to this animation
  85486. */
  85487. private _events;
  85488. /**
  85489. * Stores an array of target property paths
  85490. */
  85491. targetPropertyPath: string[];
  85492. /**
  85493. * Stores the blending speed of the animation
  85494. */
  85495. blendingSpeed: number;
  85496. /**
  85497. * Stores the animation ranges for the animation
  85498. */
  85499. private _ranges;
  85500. /**
  85501. * @hidden Internal use
  85502. */
  85503. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85504. /**
  85505. * Sets up an animation
  85506. * @param property The property to animate
  85507. * @param animationType The animation type to apply
  85508. * @param framePerSecond The frames per second of the animation
  85509. * @param easingFunction The easing function used in the animation
  85510. * @returns The created animation
  85511. */
  85512. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85513. /**
  85514. * Create and start an animation on a node
  85515. * @param name defines the name of the global animation that will be run on all nodes
  85516. * @param node defines the root node where the animation will take place
  85517. * @param targetProperty defines property to animate
  85518. * @param framePerSecond defines the number of frame per second yo use
  85519. * @param totalFrame defines the number of frames in total
  85520. * @param from defines the initial value
  85521. * @param to defines the final value
  85522. * @param loopMode defines which loop mode you want to use (off by default)
  85523. * @param easingFunction defines the easing function to use (linear by default)
  85524. * @param onAnimationEnd defines the callback to call when animation end
  85525. * @returns the animatable created for this animation
  85526. */
  85527. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85528. /**
  85529. * Create and start an animation on a node and its descendants
  85530. * @param name defines the name of the global animation that will be run on all nodes
  85531. * @param node defines the root node where the animation will take place
  85532. * @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
  85533. * @param targetProperty defines property to animate
  85534. * @param framePerSecond defines the number of frame per second to use
  85535. * @param totalFrame defines the number of frames in total
  85536. * @param from defines the initial value
  85537. * @param to defines the final value
  85538. * @param loopMode defines which loop mode you want to use (off by default)
  85539. * @param easingFunction defines the easing function to use (linear by default)
  85540. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85541. * @returns the list of animatables created for all nodes
  85542. * @example https://www.babylonjs-playground.com/#MH0VLI
  85543. */
  85544. 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[]>;
  85545. /**
  85546. * Creates a new animation, merges it with the existing animations and starts it
  85547. * @param name Name of the animation
  85548. * @param node Node which contains the scene that begins the animations
  85549. * @param targetProperty Specifies which property to animate
  85550. * @param framePerSecond The frames per second of the animation
  85551. * @param totalFrame The total number of frames
  85552. * @param from The frame at the beginning of the animation
  85553. * @param to The frame at the end of the animation
  85554. * @param loopMode Specifies the loop mode of the animation
  85555. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85556. * @param onAnimationEnd Callback to run once the animation is complete
  85557. * @returns Nullable animation
  85558. */
  85559. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85560. /**
  85561. * Transition property of an host to the target Value
  85562. * @param property The property to transition
  85563. * @param targetValue The target Value of the property
  85564. * @param host The object where the property to animate belongs
  85565. * @param scene Scene used to run the animation
  85566. * @param frameRate Framerate (in frame/s) to use
  85567. * @param transition The transition type we want to use
  85568. * @param duration The duration of the animation, in milliseconds
  85569. * @param onAnimationEnd Callback trigger at the end of the animation
  85570. * @returns Nullable animation
  85571. */
  85572. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85573. /**
  85574. * Return the array of runtime animations currently using this animation
  85575. */
  85576. readonly runtimeAnimations: RuntimeAnimation[];
  85577. /**
  85578. * Specifies if any of the runtime animations are currently running
  85579. */
  85580. readonly hasRunningRuntimeAnimations: boolean;
  85581. /**
  85582. * Initializes the animation
  85583. * @param name Name of the animation
  85584. * @param targetProperty Property to animate
  85585. * @param framePerSecond The frames per second of the animation
  85586. * @param dataType The data type of the animation
  85587. * @param loopMode The loop mode of the animation
  85588. * @param enableBlending Specifies if blending should be enabled
  85589. */
  85590. constructor(
  85591. /**Name of the animation */
  85592. name: string,
  85593. /**Property to animate */
  85594. targetProperty: string,
  85595. /**The frames per second of the animation */
  85596. framePerSecond: number,
  85597. /**The data type of the animation */
  85598. dataType: number,
  85599. /**The loop mode of the animation */
  85600. loopMode?: number | undefined,
  85601. /**Specifies if blending should be enabled */
  85602. enableBlending?: boolean | undefined);
  85603. /**
  85604. * Converts the animation to a string
  85605. * @param fullDetails support for multiple levels of logging within scene loading
  85606. * @returns String form of the animation
  85607. */
  85608. toString(fullDetails?: boolean): string;
  85609. /**
  85610. * Add an event to this animation
  85611. * @param event Event to add
  85612. */
  85613. addEvent(event: AnimationEvent): void;
  85614. /**
  85615. * Remove all events found at the given frame
  85616. * @param frame The frame to remove events from
  85617. */
  85618. removeEvents(frame: number): void;
  85619. /**
  85620. * Retrieves all the events from the animation
  85621. * @returns Events from the animation
  85622. */
  85623. getEvents(): AnimationEvent[];
  85624. /**
  85625. * Creates an animation range
  85626. * @param name Name of the animation range
  85627. * @param from Starting frame of the animation range
  85628. * @param to Ending frame of the animation
  85629. */
  85630. createRange(name: string, from: number, to: number): void;
  85631. /**
  85632. * Deletes an animation range by name
  85633. * @param name Name of the animation range to delete
  85634. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85635. */
  85636. deleteRange(name: string, deleteFrames?: boolean): void;
  85637. /**
  85638. * Gets the animation range by name, or null if not defined
  85639. * @param name Name of the animation range
  85640. * @returns Nullable animation range
  85641. */
  85642. getRange(name: string): Nullable<AnimationRange>;
  85643. /**
  85644. * Gets the key frames from the animation
  85645. * @returns The key frames of the animation
  85646. */
  85647. getKeys(): Array<IAnimationKey>;
  85648. /**
  85649. * Gets the highest frame rate of the animation
  85650. * @returns Highest frame rate of the animation
  85651. */
  85652. getHighestFrame(): number;
  85653. /**
  85654. * Gets the easing function of the animation
  85655. * @returns Easing function of the animation
  85656. */
  85657. getEasingFunction(): IEasingFunction;
  85658. /**
  85659. * Sets the easing function of the animation
  85660. * @param easingFunction A custom mathematical formula for animation
  85661. */
  85662. setEasingFunction(easingFunction: EasingFunction): void;
  85663. /**
  85664. * Interpolates a scalar linearly
  85665. * @param startValue Start value of the animation curve
  85666. * @param endValue End value of the animation curve
  85667. * @param gradient Scalar amount to interpolate
  85668. * @returns Interpolated scalar value
  85669. */
  85670. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85671. /**
  85672. * Interpolates a scalar cubically
  85673. * @param startValue Start value of the animation curve
  85674. * @param outTangent End tangent of the animation
  85675. * @param endValue End value of the animation curve
  85676. * @param inTangent Start tangent of the animation curve
  85677. * @param gradient Scalar amount to interpolate
  85678. * @returns Interpolated scalar value
  85679. */
  85680. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85681. /**
  85682. * Interpolates a quaternion using a spherical linear interpolation
  85683. * @param startValue Start value of the animation curve
  85684. * @param endValue End value of the animation curve
  85685. * @param gradient Scalar amount to interpolate
  85686. * @returns Interpolated quaternion value
  85687. */
  85688. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85689. /**
  85690. * Interpolates a quaternion cubically
  85691. * @param startValue Start value of the animation curve
  85692. * @param outTangent End tangent of the animation curve
  85693. * @param endValue End value of the animation curve
  85694. * @param inTangent Start tangent of the animation curve
  85695. * @param gradient Scalar amount to interpolate
  85696. * @returns Interpolated quaternion value
  85697. */
  85698. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85699. /**
  85700. * Interpolates a Vector3 linearl
  85701. * @param startValue Start value of the animation curve
  85702. * @param endValue End value of the animation curve
  85703. * @param gradient Scalar amount to interpolate
  85704. * @returns Interpolated scalar value
  85705. */
  85706. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85707. /**
  85708. * Interpolates a Vector3 cubically
  85709. * @param startValue Start value of the animation curve
  85710. * @param outTangent End tangent of the animation
  85711. * @param endValue End value of the animation curve
  85712. * @param inTangent Start tangent of the animation curve
  85713. * @param gradient Scalar amount to interpolate
  85714. * @returns InterpolatedVector3 value
  85715. */
  85716. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85717. /**
  85718. * Interpolates a Vector2 linearly
  85719. * @param startValue Start value of the animation curve
  85720. * @param endValue End value of the animation curve
  85721. * @param gradient Scalar amount to interpolate
  85722. * @returns Interpolated Vector2 value
  85723. */
  85724. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85725. /**
  85726. * Interpolates a Vector2 cubically
  85727. * @param startValue Start value of the animation curve
  85728. * @param outTangent End tangent of the animation
  85729. * @param endValue End value of the animation curve
  85730. * @param inTangent Start tangent of the animation curve
  85731. * @param gradient Scalar amount to interpolate
  85732. * @returns Interpolated Vector2 value
  85733. */
  85734. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85735. /**
  85736. * Interpolates a size linearly
  85737. * @param startValue Start value of the animation curve
  85738. * @param endValue End value of the animation curve
  85739. * @param gradient Scalar amount to interpolate
  85740. * @returns Interpolated Size value
  85741. */
  85742. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85743. /**
  85744. * Interpolates a Color3 linearly
  85745. * @param startValue Start value of the animation curve
  85746. * @param endValue End value of the animation curve
  85747. * @param gradient Scalar amount to interpolate
  85748. * @returns Interpolated Color3 value
  85749. */
  85750. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85751. /**
  85752. * @hidden Internal use only
  85753. */
  85754. _getKeyValue(value: any): any;
  85755. /**
  85756. * @hidden Internal use only
  85757. */
  85758. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85759. /**
  85760. * Defines the function to use to interpolate matrices
  85761. * @param startValue defines the start matrix
  85762. * @param endValue defines the end matrix
  85763. * @param gradient defines the gradient between both matrices
  85764. * @param result defines an optional target matrix where to store the interpolation
  85765. * @returns the interpolated matrix
  85766. */
  85767. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85768. /**
  85769. * Makes a copy of the animation
  85770. * @returns Cloned animation
  85771. */
  85772. clone(): Animation;
  85773. /**
  85774. * Sets the key frames of the animation
  85775. * @param values The animation key frames to set
  85776. */
  85777. setKeys(values: Array<IAnimationKey>): void;
  85778. /**
  85779. * Serializes the animation to an object
  85780. * @returns Serialized object
  85781. */
  85782. serialize(): any;
  85783. /**
  85784. * Float animation type
  85785. */
  85786. private static _ANIMATIONTYPE_FLOAT;
  85787. /**
  85788. * Vector3 animation type
  85789. */
  85790. private static _ANIMATIONTYPE_VECTOR3;
  85791. /**
  85792. * Quaternion animation type
  85793. */
  85794. private static _ANIMATIONTYPE_QUATERNION;
  85795. /**
  85796. * Matrix animation type
  85797. */
  85798. private static _ANIMATIONTYPE_MATRIX;
  85799. /**
  85800. * Color3 animation type
  85801. */
  85802. private static _ANIMATIONTYPE_COLOR3;
  85803. /**
  85804. * Vector2 animation type
  85805. */
  85806. private static _ANIMATIONTYPE_VECTOR2;
  85807. /**
  85808. * Size animation type
  85809. */
  85810. private static _ANIMATIONTYPE_SIZE;
  85811. /**
  85812. * Relative Loop Mode
  85813. */
  85814. private static _ANIMATIONLOOPMODE_RELATIVE;
  85815. /**
  85816. * Cycle Loop Mode
  85817. */
  85818. private static _ANIMATIONLOOPMODE_CYCLE;
  85819. /**
  85820. * Constant Loop Mode
  85821. */
  85822. private static _ANIMATIONLOOPMODE_CONSTANT;
  85823. /**
  85824. * Get the float animation type
  85825. */
  85826. static readonly ANIMATIONTYPE_FLOAT: number;
  85827. /**
  85828. * Get the Vector3 animation type
  85829. */
  85830. static readonly ANIMATIONTYPE_VECTOR3: number;
  85831. /**
  85832. * Get the Vector2 animation type
  85833. */
  85834. static readonly ANIMATIONTYPE_VECTOR2: number;
  85835. /**
  85836. * Get the Size animation type
  85837. */
  85838. static readonly ANIMATIONTYPE_SIZE: number;
  85839. /**
  85840. * Get the Quaternion animation type
  85841. */
  85842. static readonly ANIMATIONTYPE_QUATERNION: number;
  85843. /**
  85844. * Get the Matrix animation type
  85845. */
  85846. static readonly ANIMATIONTYPE_MATRIX: number;
  85847. /**
  85848. * Get the Color3 animation type
  85849. */
  85850. static readonly ANIMATIONTYPE_COLOR3: number;
  85851. /**
  85852. * Get the Relative Loop Mode
  85853. */
  85854. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85855. /**
  85856. * Get the Cycle Loop Mode
  85857. */
  85858. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85859. /**
  85860. * Get the Constant Loop Mode
  85861. */
  85862. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85863. /** @hidden */
  85864. static _UniversalLerp(left: any, right: any, amount: number): any;
  85865. /**
  85866. * Parses an animation object and creates an animation
  85867. * @param parsedAnimation Parsed animation object
  85868. * @returns Animation object
  85869. */
  85870. static Parse(parsedAnimation: any): Animation;
  85871. /**
  85872. * Appends the serialized animations from the source animations
  85873. * @param source Source containing the animations
  85874. * @param destination Target to store the animations
  85875. */
  85876. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85877. }
  85878. }
  85879. declare module BABYLON {
  85880. /**
  85881. * Base class of all the textures in babylon.
  85882. * It groups all the common properties the materials, post process, lights... might need
  85883. * in order to make a correct use of the texture.
  85884. */
  85885. export class BaseTexture implements IAnimatable {
  85886. /**
  85887. * Default anisotropic filtering level for the application.
  85888. * It is set to 4 as a good tradeoff between perf and quality.
  85889. */
  85890. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85891. /**
  85892. * Gets or sets the unique id of the texture
  85893. */
  85894. uniqueId: number;
  85895. /**
  85896. * Define the name of the texture.
  85897. */
  85898. name: string;
  85899. /**
  85900. * Gets or sets an object used to store user defined information.
  85901. */
  85902. metadata: any;
  85903. /**
  85904. * For internal use only. Please do not use.
  85905. */
  85906. reservedDataStore: any;
  85907. private _hasAlpha;
  85908. /**
  85909. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85910. */
  85911. hasAlpha: boolean;
  85912. /**
  85913. * Defines if the alpha value should be determined via the rgb values.
  85914. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85915. */
  85916. getAlphaFromRGB: boolean;
  85917. /**
  85918. * Intensity or strength of the texture.
  85919. * It is commonly used by materials to fine tune the intensity of the texture
  85920. */
  85921. level: number;
  85922. /**
  85923. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85924. * This is part of the texture as textures usually maps to one uv set.
  85925. */
  85926. coordinatesIndex: number;
  85927. private _coordinatesMode;
  85928. /**
  85929. * How a texture is mapped.
  85930. *
  85931. * | Value | Type | Description |
  85932. * | ----- | ----------------------------------- | ----------- |
  85933. * | 0 | EXPLICIT_MODE | |
  85934. * | 1 | SPHERICAL_MODE | |
  85935. * | 2 | PLANAR_MODE | |
  85936. * | 3 | CUBIC_MODE | |
  85937. * | 4 | PROJECTION_MODE | |
  85938. * | 5 | SKYBOX_MODE | |
  85939. * | 6 | INVCUBIC_MODE | |
  85940. * | 7 | EQUIRECTANGULAR_MODE | |
  85941. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85942. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85943. */
  85944. coordinatesMode: number;
  85945. /**
  85946. * | Value | Type | Description |
  85947. * | ----- | ------------------ | ----------- |
  85948. * | 0 | CLAMP_ADDRESSMODE | |
  85949. * | 1 | WRAP_ADDRESSMODE | |
  85950. * | 2 | MIRROR_ADDRESSMODE | |
  85951. */
  85952. wrapU: number;
  85953. /**
  85954. * | Value | Type | Description |
  85955. * | ----- | ------------------ | ----------- |
  85956. * | 0 | CLAMP_ADDRESSMODE | |
  85957. * | 1 | WRAP_ADDRESSMODE | |
  85958. * | 2 | MIRROR_ADDRESSMODE | |
  85959. */
  85960. wrapV: number;
  85961. /**
  85962. * | Value | Type | Description |
  85963. * | ----- | ------------------ | ----------- |
  85964. * | 0 | CLAMP_ADDRESSMODE | |
  85965. * | 1 | WRAP_ADDRESSMODE | |
  85966. * | 2 | MIRROR_ADDRESSMODE | |
  85967. */
  85968. wrapR: number;
  85969. /**
  85970. * With compliant hardware and browser (supporting anisotropic filtering)
  85971. * this defines the level of anisotropic filtering in the texture.
  85972. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85973. */
  85974. anisotropicFilteringLevel: number;
  85975. /**
  85976. * Define if the texture is a cube texture or if false a 2d texture.
  85977. */
  85978. isCube: boolean;
  85979. /**
  85980. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85981. */
  85982. is3D: boolean;
  85983. /**
  85984. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85985. * HDR texture are usually stored in linear space.
  85986. * This only impacts the PBR and Background materials
  85987. */
  85988. gammaSpace: boolean;
  85989. /**
  85990. * Gets whether or not the texture contains RGBD data.
  85991. */
  85992. readonly isRGBD: boolean;
  85993. /**
  85994. * Is Z inverted in the texture (useful in a cube texture).
  85995. */
  85996. invertZ: boolean;
  85997. /**
  85998. * Are mip maps generated for this texture or not.
  85999. */
  86000. readonly noMipmap: boolean;
  86001. /**
  86002. * @hidden
  86003. */
  86004. lodLevelInAlpha: boolean;
  86005. /**
  86006. * With prefiltered texture, defined the offset used during the prefiltering steps.
  86007. */
  86008. lodGenerationOffset: number;
  86009. /**
  86010. * With prefiltered texture, defined the scale used during the prefiltering steps.
  86011. */
  86012. lodGenerationScale: number;
  86013. /**
  86014. * Define if the texture is a render target.
  86015. */
  86016. isRenderTarget: boolean;
  86017. /**
  86018. * Define the unique id of the texture in the scene.
  86019. */
  86020. readonly uid: string;
  86021. /**
  86022. * Return a string representation of the texture.
  86023. * @returns the texture as a string
  86024. */
  86025. toString(): string;
  86026. /**
  86027. * Get the class name of the texture.
  86028. * @returns "BaseTexture"
  86029. */
  86030. getClassName(): string;
  86031. /**
  86032. * Define the list of animation attached to the texture.
  86033. */
  86034. animations: Animation[];
  86035. /**
  86036. * An event triggered when the texture is disposed.
  86037. */
  86038. onDisposeObservable: Observable<BaseTexture>;
  86039. private _onDisposeObserver;
  86040. /**
  86041. * Callback triggered when the texture has been disposed.
  86042. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86043. */
  86044. onDispose: () => void;
  86045. /**
  86046. * Define the current state of the loading sequence when in delayed load mode.
  86047. */
  86048. delayLoadState: number;
  86049. private _scene;
  86050. /** @hidden */
  86051. _texture: Nullable<InternalTexture>;
  86052. private _uid;
  86053. /**
  86054. * Define if the texture is preventinga material to render or not.
  86055. * If not and the texture is not ready, the engine will use a default black texture instead.
  86056. */
  86057. readonly isBlocking: boolean;
  86058. /**
  86059. * Instantiates a new BaseTexture.
  86060. * Base class of all the textures in babylon.
  86061. * It groups all the common properties the materials, post process, lights... might need
  86062. * in order to make a correct use of the texture.
  86063. * @param scene Define the scene the texture blongs to
  86064. */
  86065. constructor(scene: Nullable<Scene>);
  86066. /**
  86067. * Get the scene the texture belongs to.
  86068. * @returns the scene or null if undefined
  86069. */
  86070. getScene(): Nullable<Scene>;
  86071. /**
  86072. * Get the texture transform matrix used to offset tile the texture for istance.
  86073. * @returns the transformation matrix
  86074. */
  86075. getTextureMatrix(): Matrix;
  86076. /**
  86077. * Get the texture reflection matrix used to rotate/transform the reflection.
  86078. * @returns the reflection matrix
  86079. */
  86080. getReflectionTextureMatrix(): Matrix;
  86081. /**
  86082. * Get the underlying lower level texture from Babylon.
  86083. * @returns the insternal texture
  86084. */
  86085. getInternalTexture(): Nullable<InternalTexture>;
  86086. /**
  86087. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86088. * @returns true if ready or not blocking
  86089. */
  86090. isReadyOrNotBlocking(): boolean;
  86091. /**
  86092. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86093. * @returns true if fully ready
  86094. */
  86095. isReady(): boolean;
  86096. private _cachedSize;
  86097. /**
  86098. * Get the size of the texture.
  86099. * @returns the texture size.
  86100. */
  86101. getSize(): ISize;
  86102. /**
  86103. * Get the base size of the texture.
  86104. * It can be different from the size if the texture has been resized for POT for instance
  86105. * @returns the base size
  86106. */
  86107. getBaseSize(): ISize;
  86108. /**
  86109. * Update the sampling mode of the texture.
  86110. * Default is Trilinear mode.
  86111. *
  86112. * | Value | Type | Description |
  86113. * | ----- | ------------------ | ----------- |
  86114. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86115. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86116. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86117. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86118. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86119. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86120. * | 7 | NEAREST_LINEAR | |
  86121. * | 8 | NEAREST_NEAREST | |
  86122. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86123. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86124. * | 11 | LINEAR_LINEAR | |
  86125. * | 12 | LINEAR_NEAREST | |
  86126. *
  86127. * > _mag_: magnification filter (close to the viewer)
  86128. * > _min_: minification filter (far from the viewer)
  86129. * > _mip_: filter used between mip map levels
  86130. *@param samplingMode Define the new sampling mode of the texture
  86131. */
  86132. updateSamplingMode(samplingMode: number): void;
  86133. /**
  86134. * Scales the texture if is `canRescale()`
  86135. * @param ratio the resize factor we want to use to rescale
  86136. */
  86137. scale(ratio: number): void;
  86138. /**
  86139. * Get if the texture can rescale.
  86140. */
  86141. readonly canRescale: boolean;
  86142. /** @hidden */
  86143. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86144. /** @hidden */
  86145. _rebuild(): void;
  86146. /**
  86147. * Triggers the load sequence in delayed load mode.
  86148. */
  86149. delayLoad(): void;
  86150. /**
  86151. * Clones the texture.
  86152. * @returns the cloned texture
  86153. */
  86154. clone(): Nullable<BaseTexture>;
  86155. /**
  86156. * Get the texture underlying type (INT, FLOAT...)
  86157. */
  86158. readonly textureType: number;
  86159. /**
  86160. * Get the texture underlying format (RGB, RGBA...)
  86161. */
  86162. readonly textureFormat: number;
  86163. /**
  86164. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86165. * This will returns an RGBA array buffer containing either in values (0-255) or
  86166. * float values (0-1) depending of the underlying buffer type.
  86167. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86168. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86169. * @param buffer defines a user defined buffer to fill with data (can be null)
  86170. * @returns The Array buffer containing the pixels data.
  86171. */
  86172. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86173. /**
  86174. * Release and destroy the underlying lower level texture aka internalTexture.
  86175. */
  86176. releaseInternalTexture(): void;
  86177. /**
  86178. * Get the polynomial representation of the texture data.
  86179. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86180. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86181. */
  86182. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86183. /** @hidden */
  86184. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86185. /** @hidden */
  86186. readonly _lodTextureMid: Nullable<BaseTexture>;
  86187. /** @hidden */
  86188. readonly _lodTextureLow: Nullable<BaseTexture>;
  86189. /**
  86190. * Dispose the texture and release its associated resources.
  86191. */
  86192. dispose(): void;
  86193. /**
  86194. * Serialize the texture into a JSON representation that can be parsed later on.
  86195. * @returns the JSON representation of the texture
  86196. */
  86197. serialize(): any;
  86198. /**
  86199. * Helper function to be called back once a list of texture contains only ready textures.
  86200. * @param textures Define the list of textures to wait for
  86201. * @param callback Define the callback triggered once the entire list will be ready
  86202. */
  86203. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86204. }
  86205. }
  86206. declare module BABYLON {
  86207. /**
  86208. * Uniform buffer objects.
  86209. *
  86210. * Handles blocks of uniform on the GPU.
  86211. *
  86212. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86213. *
  86214. * For more information, please refer to :
  86215. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86216. */
  86217. export class UniformBuffer {
  86218. private _engine;
  86219. private _buffer;
  86220. private _data;
  86221. private _bufferData;
  86222. private _dynamic?;
  86223. private _uniformLocations;
  86224. private _uniformSizes;
  86225. private _uniformLocationPointer;
  86226. private _needSync;
  86227. private _noUBO;
  86228. private _currentEffect;
  86229. private static _MAX_UNIFORM_SIZE;
  86230. private static _tempBuffer;
  86231. /**
  86232. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86233. * This is dynamic to allow compat with webgl 1 and 2.
  86234. * You will need to pass the name of the uniform as well as the value.
  86235. */
  86236. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86237. /**
  86238. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86239. * This is dynamic to allow compat with webgl 1 and 2.
  86240. * You will need to pass the name of the uniform as well as the value.
  86241. */
  86242. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86243. /**
  86244. * Lambda to Update a single float in a uniform buffer.
  86245. * This is dynamic to allow compat with webgl 1 and 2.
  86246. * You will need to pass the name of the uniform as well as the value.
  86247. */
  86248. updateFloat: (name: string, x: number) => void;
  86249. /**
  86250. * Lambda to Update a vec2 of float in a uniform buffer.
  86251. * This is dynamic to allow compat with webgl 1 and 2.
  86252. * You will need to pass the name of the uniform as well as the value.
  86253. */
  86254. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86255. /**
  86256. * Lambda to Update a vec3 of float in a uniform buffer.
  86257. * This is dynamic to allow compat with webgl 1 and 2.
  86258. * You will need to pass the name of the uniform as well as the value.
  86259. */
  86260. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86261. /**
  86262. * Lambda to Update a vec4 of float in a uniform buffer.
  86263. * This is dynamic to allow compat with webgl 1 and 2.
  86264. * You will need to pass the name of the uniform as well as the value.
  86265. */
  86266. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86267. /**
  86268. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86269. * This is dynamic to allow compat with webgl 1 and 2.
  86270. * You will need to pass the name of the uniform as well as the value.
  86271. */
  86272. updateMatrix: (name: string, mat: Matrix) => void;
  86273. /**
  86274. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86275. * This is dynamic to allow compat with webgl 1 and 2.
  86276. * You will need to pass the name of the uniform as well as the value.
  86277. */
  86278. updateVector3: (name: string, vector: Vector3) => void;
  86279. /**
  86280. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86281. * This is dynamic to allow compat with webgl 1 and 2.
  86282. * You will need to pass the name of the uniform as well as the value.
  86283. */
  86284. updateVector4: (name: string, vector: Vector4) => void;
  86285. /**
  86286. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86287. * This is dynamic to allow compat with webgl 1 and 2.
  86288. * You will need to pass the name of the uniform as well as the value.
  86289. */
  86290. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86291. /**
  86292. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86293. * This is dynamic to allow compat with webgl 1 and 2.
  86294. * You will need to pass the name of the uniform as well as the value.
  86295. */
  86296. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86297. /**
  86298. * Instantiates a new Uniform buffer objects.
  86299. *
  86300. * Handles blocks of uniform on the GPU.
  86301. *
  86302. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86303. *
  86304. * For more information, please refer to :
  86305. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86306. * @param engine Define the engine the buffer is associated with
  86307. * @param data Define the data contained in the buffer
  86308. * @param dynamic Define if the buffer is updatable
  86309. */
  86310. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86311. /**
  86312. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86313. * or just falling back on setUniformXXX calls.
  86314. */
  86315. readonly useUbo: boolean;
  86316. /**
  86317. * Indicates if the WebGL underlying uniform buffer is in sync
  86318. * with the javascript cache data.
  86319. */
  86320. readonly isSync: boolean;
  86321. /**
  86322. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86323. * Also, a dynamic UniformBuffer will disable cache verification and always
  86324. * update the underlying WebGL uniform buffer to the GPU.
  86325. * @returns if Dynamic, otherwise false
  86326. */
  86327. isDynamic(): boolean;
  86328. /**
  86329. * The data cache on JS side.
  86330. * @returns the underlying data as a float array
  86331. */
  86332. getData(): Float32Array;
  86333. /**
  86334. * The underlying WebGL Uniform buffer.
  86335. * @returns the webgl buffer
  86336. */
  86337. getBuffer(): Nullable<DataBuffer>;
  86338. /**
  86339. * std140 layout specifies how to align data within an UBO structure.
  86340. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86341. * for specs.
  86342. */
  86343. private _fillAlignment;
  86344. /**
  86345. * Adds an uniform in the buffer.
  86346. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86347. * for the layout to be correct !
  86348. * @param name Name of the uniform, as used in the uniform block in the shader.
  86349. * @param size Data size, or data directly.
  86350. */
  86351. addUniform(name: string, size: number | number[]): void;
  86352. /**
  86353. * Adds a Matrix 4x4 to the uniform buffer.
  86354. * @param name Name of the uniform, as used in the uniform block in the shader.
  86355. * @param mat A 4x4 matrix.
  86356. */
  86357. addMatrix(name: string, mat: Matrix): void;
  86358. /**
  86359. * Adds a vec2 to the uniform buffer.
  86360. * @param name Name of the uniform, as used in the uniform block in the shader.
  86361. * @param x Define the x component value of the vec2
  86362. * @param y Define the y component value of the vec2
  86363. */
  86364. addFloat2(name: string, x: number, y: number): void;
  86365. /**
  86366. * Adds a vec3 to the uniform buffer.
  86367. * @param name Name of the uniform, as used in the uniform block in the shader.
  86368. * @param x Define the x component value of the vec3
  86369. * @param y Define the y component value of the vec3
  86370. * @param z Define the z component value of the vec3
  86371. */
  86372. addFloat3(name: string, x: number, y: number, z: number): void;
  86373. /**
  86374. * Adds a vec3 to the uniform buffer.
  86375. * @param name Name of the uniform, as used in the uniform block in the shader.
  86376. * @param color Define the vec3 from a Color
  86377. */
  86378. addColor3(name: string, color: Color3): void;
  86379. /**
  86380. * Adds a vec4 to the uniform buffer.
  86381. * @param name Name of the uniform, as used in the uniform block in the shader.
  86382. * @param color Define the rgb components from a Color
  86383. * @param alpha Define the a component of the vec4
  86384. */
  86385. addColor4(name: string, color: Color3, alpha: number): void;
  86386. /**
  86387. * Adds a vec3 to the uniform buffer.
  86388. * @param name Name of the uniform, as used in the uniform block in the shader.
  86389. * @param vector Define the vec3 components from a Vector
  86390. */
  86391. addVector3(name: string, vector: Vector3): void;
  86392. /**
  86393. * Adds a Matrix 3x3 to the uniform buffer.
  86394. * @param name Name of the uniform, as used in the uniform block in the shader.
  86395. */
  86396. addMatrix3x3(name: string): void;
  86397. /**
  86398. * Adds a Matrix 2x2 to the uniform buffer.
  86399. * @param name Name of the uniform, as used in the uniform block in the shader.
  86400. */
  86401. addMatrix2x2(name: string): void;
  86402. /**
  86403. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86404. */
  86405. create(): void;
  86406. /** @hidden */
  86407. _rebuild(): void;
  86408. /**
  86409. * Updates the WebGL Uniform Buffer on the GPU.
  86410. * If the `dynamic` flag is set to true, no cache comparison is done.
  86411. * Otherwise, the buffer will be updated only if the cache differs.
  86412. */
  86413. update(): void;
  86414. /**
  86415. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86416. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86417. * @param data Define the flattened data
  86418. * @param size Define the size of the data.
  86419. */
  86420. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86421. private _updateMatrix3x3ForUniform;
  86422. private _updateMatrix3x3ForEffect;
  86423. private _updateMatrix2x2ForEffect;
  86424. private _updateMatrix2x2ForUniform;
  86425. private _updateFloatForEffect;
  86426. private _updateFloatForUniform;
  86427. private _updateFloat2ForEffect;
  86428. private _updateFloat2ForUniform;
  86429. private _updateFloat3ForEffect;
  86430. private _updateFloat3ForUniform;
  86431. private _updateFloat4ForEffect;
  86432. private _updateFloat4ForUniform;
  86433. private _updateMatrixForEffect;
  86434. private _updateMatrixForUniform;
  86435. private _updateVector3ForEffect;
  86436. private _updateVector3ForUniform;
  86437. private _updateVector4ForEffect;
  86438. private _updateVector4ForUniform;
  86439. private _updateColor3ForEffect;
  86440. private _updateColor3ForUniform;
  86441. private _updateColor4ForEffect;
  86442. private _updateColor4ForUniform;
  86443. /**
  86444. * Sets a sampler uniform on the effect.
  86445. * @param name Define the name of the sampler.
  86446. * @param texture Define the texture to set in the sampler
  86447. */
  86448. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86449. /**
  86450. * Directly updates the value of the uniform in the cache AND on the GPU.
  86451. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86452. * @param data Define the flattened data
  86453. */
  86454. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86455. /**
  86456. * Binds this uniform buffer to an effect.
  86457. * @param effect Define the effect to bind the buffer to
  86458. * @param name Name of the uniform block in the shader.
  86459. */
  86460. bindToEffect(effect: Effect, name: string): void;
  86461. /**
  86462. * Disposes the uniform buffer.
  86463. */
  86464. dispose(): void;
  86465. }
  86466. }
  86467. declare module BABYLON {
  86468. /**
  86469. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86471. */
  86472. export class Analyser {
  86473. /**
  86474. * Gets or sets the smoothing
  86475. * @ignorenaming
  86476. */
  86477. SMOOTHING: number;
  86478. /**
  86479. * Gets or sets the FFT table size
  86480. * @ignorenaming
  86481. */
  86482. FFT_SIZE: number;
  86483. /**
  86484. * Gets or sets the bar graph amplitude
  86485. * @ignorenaming
  86486. */
  86487. BARGRAPHAMPLITUDE: number;
  86488. /**
  86489. * Gets or sets the position of the debug canvas
  86490. * @ignorenaming
  86491. */
  86492. DEBUGCANVASPOS: {
  86493. x: number;
  86494. y: number;
  86495. };
  86496. /**
  86497. * Gets or sets the debug canvas size
  86498. * @ignorenaming
  86499. */
  86500. DEBUGCANVASSIZE: {
  86501. width: number;
  86502. height: number;
  86503. };
  86504. private _byteFreqs;
  86505. private _byteTime;
  86506. private _floatFreqs;
  86507. private _webAudioAnalyser;
  86508. private _debugCanvas;
  86509. private _debugCanvasContext;
  86510. private _scene;
  86511. private _registerFunc;
  86512. private _audioEngine;
  86513. /**
  86514. * Creates a new analyser
  86515. * @param scene defines hosting scene
  86516. */
  86517. constructor(scene: Scene);
  86518. /**
  86519. * Get the number of data values you will have to play with for the visualization
  86520. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86521. * @returns a number
  86522. */
  86523. getFrequencyBinCount(): number;
  86524. /**
  86525. * Gets the current frequency data as a byte array
  86526. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86527. * @returns a Uint8Array
  86528. */
  86529. getByteFrequencyData(): Uint8Array;
  86530. /**
  86531. * Gets the current waveform as a byte array
  86532. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86533. * @returns a Uint8Array
  86534. */
  86535. getByteTimeDomainData(): Uint8Array;
  86536. /**
  86537. * Gets the current frequency data as a float array
  86538. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86539. * @returns a Float32Array
  86540. */
  86541. getFloatFrequencyData(): Float32Array;
  86542. /**
  86543. * Renders the debug canvas
  86544. */
  86545. drawDebugCanvas(): void;
  86546. /**
  86547. * Stops rendering the debug canvas and removes it
  86548. */
  86549. stopDebugCanvas(): void;
  86550. /**
  86551. * Connects two audio nodes
  86552. * @param inputAudioNode defines first node to connect
  86553. * @param outputAudioNode defines second node to connect
  86554. */
  86555. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86556. /**
  86557. * Releases all associated resources
  86558. */
  86559. dispose(): void;
  86560. }
  86561. }
  86562. declare module BABYLON {
  86563. /**
  86564. * This represents an audio engine and it is responsible
  86565. * to play, synchronize and analyse sounds throughout the application.
  86566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86567. */
  86568. export interface IAudioEngine extends IDisposable {
  86569. /**
  86570. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86571. */
  86572. readonly canUseWebAudio: boolean;
  86573. /**
  86574. * Gets the current AudioContext if available.
  86575. */
  86576. readonly audioContext: Nullable<AudioContext>;
  86577. /**
  86578. * The master gain node defines the global audio volume of your audio engine.
  86579. */
  86580. readonly masterGain: GainNode;
  86581. /**
  86582. * Gets whether or not mp3 are supported by your browser.
  86583. */
  86584. readonly isMP3supported: boolean;
  86585. /**
  86586. * Gets whether or not ogg are supported by your browser.
  86587. */
  86588. readonly isOGGsupported: boolean;
  86589. /**
  86590. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86591. * @ignoreNaming
  86592. */
  86593. WarnedWebAudioUnsupported: boolean;
  86594. /**
  86595. * Defines if the audio engine relies on a custom unlocked button.
  86596. * In this case, the embedded button will not be displayed.
  86597. */
  86598. useCustomUnlockedButton: boolean;
  86599. /**
  86600. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86601. */
  86602. readonly unlocked: boolean;
  86603. /**
  86604. * Event raised when audio has been unlocked on the browser.
  86605. */
  86606. onAudioUnlockedObservable: Observable<AudioEngine>;
  86607. /**
  86608. * Event raised when audio has been locked on the browser.
  86609. */
  86610. onAudioLockedObservable: Observable<AudioEngine>;
  86611. /**
  86612. * Flags the audio engine in Locked state.
  86613. * This happens due to new browser policies preventing audio to autoplay.
  86614. */
  86615. lock(): void;
  86616. /**
  86617. * Unlocks the audio engine once a user action has been done on the dom.
  86618. * This is helpful to resume play once browser policies have been satisfied.
  86619. */
  86620. unlock(): void;
  86621. }
  86622. /**
  86623. * This represents the default audio engine used in babylon.
  86624. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86626. */
  86627. export class AudioEngine implements IAudioEngine {
  86628. private _audioContext;
  86629. private _audioContextInitialized;
  86630. private _muteButton;
  86631. private _hostElement;
  86632. /**
  86633. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86634. */
  86635. canUseWebAudio: boolean;
  86636. /**
  86637. * The master gain node defines the global audio volume of your audio engine.
  86638. */
  86639. masterGain: GainNode;
  86640. /**
  86641. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86642. * @ignoreNaming
  86643. */
  86644. WarnedWebAudioUnsupported: boolean;
  86645. /**
  86646. * Gets whether or not mp3 are supported by your browser.
  86647. */
  86648. isMP3supported: boolean;
  86649. /**
  86650. * Gets whether or not ogg are supported by your browser.
  86651. */
  86652. isOGGsupported: boolean;
  86653. /**
  86654. * Gets whether audio has been unlocked on the device.
  86655. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86656. * a user interaction has happened.
  86657. */
  86658. unlocked: boolean;
  86659. /**
  86660. * Defines if the audio engine relies on a custom unlocked button.
  86661. * In this case, the embedded button will not be displayed.
  86662. */
  86663. useCustomUnlockedButton: boolean;
  86664. /**
  86665. * Event raised when audio has been unlocked on the browser.
  86666. */
  86667. onAudioUnlockedObservable: Observable<AudioEngine>;
  86668. /**
  86669. * Event raised when audio has been locked on the browser.
  86670. */
  86671. onAudioLockedObservable: Observable<AudioEngine>;
  86672. /**
  86673. * Gets the current AudioContext if available.
  86674. */
  86675. readonly audioContext: Nullable<AudioContext>;
  86676. private _connectedAnalyser;
  86677. /**
  86678. * Instantiates a new audio engine.
  86679. *
  86680. * There should be only one per page as some browsers restrict the number
  86681. * of audio contexts you can create.
  86682. * @param hostElement defines the host element where to display the mute icon if necessary
  86683. */
  86684. constructor(hostElement?: Nullable<HTMLElement>);
  86685. /**
  86686. * Flags the audio engine in Locked state.
  86687. * This happens due to new browser policies preventing audio to autoplay.
  86688. */
  86689. lock(): void;
  86690. /**
  86691. * Unlocks the audio engine once a user action has been done on the dom.
  86692. * This is helpful to resume play once browser policies have been satisfied.
  86693. */
  86694. unlock(): void;
  86695. private _resumeAudioContext;
  86696. private _initializeAudioContext;
  86697. private _tryToRun;
  86698. private _triggerRunningState;
  86699. private _triggerSuspendedState;
  86700. private _displayMuteButton;
  86701. private _moveButtonToTopLeft;
  86702. private _onResize;
  86703. private _hideMuteButton;
  86704. /**
  86705. * Destroy and release the resources associated with the audio ccontext.
  86706. */
  86707. dispose(): void;
  86708. /**
  86709. * Gets the global volume sets on the master gain.
  86710. * @returns the global volume if set or -1 otherwise
  86711. */
  86712. getGlobalVolume(): number;
  86713. /**
  86714. * Sets the global volume of your experience (sets on the master gain).
  86715. * @param newVolume Defines the new global volume of the application
  86716. */
  86717. setGlobalVolume(newVolume: number): void;
  86718. /**
  86719. * Connect the audio engine to an audio analyser allowing some amazing
  86720. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86722. * @param analyser The analyser to connect to the engine
  86723. */
  86724. connectToAnalyser(analyser: Analyser): void;
  86725. }
  86726. }
  86727. declare module BABYLON {
  86728. /**
  86729. * Interface used to present a loading screen while loading a scene
  86730. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86731. */
  86732. export interface ILoadingScreen {
  86733. /**
  86734. * Function called to display the loading screen
  86735. */
  86736. displayLoadingUI: () => void;
  86737. /**
  86738. * Function called to hide the loading screen
  86739. */
  86740. hideLoadingUI: () => void;
  86741. /**
  86742. * Gets or sets the color to use for the background
  86743. */
  86744. loadingUIBackgroundColor: string;
  86745. /**
  86746. * Gets or sets the text to display while loading
  86747. */
  86748. loadingUIText: string;
  86749. }
  86750. /**
  86751. * Class used for the default loading screen
  86752. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86753. */
  86754. export class DefaultLoadingScreen implements ILoadingScreen {
  86755. private _renderingCanvas;
  86756. private _loadingText;
  86757. private _loadingDivBackgroundColor;
  86758. private _loadingDiv;
  86759. private _loadingTextDiv;
  86760. /**
  86761. * Creates a new default loading screen
  86762. * @param _renderingCanvas defines the canvas used to render the scene
  86763. * @param _loadingText defines the default text to display
  86764. * @param _loadingDivBackgroundColor defines the default background color
  86765. */
  86766. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86767. /**
  86768. * Function called to display the loading screen
  86769. */
  86770. displayLoadingUI(): void;
  86771. /**
  86772. * Function called to hide the loading screen
  86773. */
  86774. hideLoadingUI(): void;
  86775. /**
  86776. * Gets or sets the text to display while loading
  86777. */
  86778. loadingUIText: string;
  86779. /**
  86780. * Gets or sets the color to use for the background
  86781. */
  86782. loadingUIBackgroundColor: string;
  86783. private _resizeLoadingUI;
  86784. }
  86785. }
  86786. declare module BABYLON {
  86787. /** @hidden */
  86788. export class WebGLPipelineContext implements IPipelineContext {
  86789. engine: Engine;
  86790. program: Nullable<WebGLProgram>;
  86791. context?: WebGLRenderingContext;
  86792. vertexShader?: WebGLShader;
  86793. fragmentShader?: WebGLShader;
  86794. isParallelCompiled: boolean;
  86795. onCompiled?: () => void;
  86796. transformFeedback?: WebGLTransformFeedback | null;
  86797. readonly isAsync: boolean;
  86798. readonly isReady: boolean;
  86799. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86800. }
  86801. }
  86802. declare module BABYLON {
  86803. /** @hidden */
  86804. export class WebGLDataBuffer extends DataBuffer {
  86805. private _buffer;
  86806. constructor(resource: WebGLBuffer);
  86807. readonly underlyingResource: any;
  86808. }
  86809. }
  86810. declare module BABYLON {
  86811. /**
  86812. * Settings for finer control over video usage
  86813. */
  86814. export interface VideoTextureSettings {
  86815. /**
  86816. * Applies `autoplay` to video, if specified
  86817. */
  86818. autoPlay?: boolean;
  86819. /**
  86820. * Applies `loop` to video, if specified
  86821. */
  86822. loop?: boolean;
  86823. /**
  86824. * Automatically updates internal texture from video at every frame in the render loop
  86825. */
  86826. autoUpdateTexture: boolean;
  86827. /**
  86828. * Image src displayed during the video loading or until the user interacts with the video.
  86829. */
  86830. poster?: string;
  86831. }
  86832. /**
  86833. * If you want to display a video in your scene, this is the special texture for that.
  86834. * This special texture works similar to other textures, with the exception of a few parameters.
  86835. * @see https://doc.babylonjs.com/how_to/video_texture
  86836. */
  86837. export class VideoTexture extends Texture {
  86838. /**
  86839. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86840. */
  86841. readonly autoUpdateTexture: boolean;
  86842. /**
  86843. * The video instance used by the texture internally
  86844. */
  86845. readonly video: HTMLVideoElement;
  86846. private _onUserActionRequestedObservable;
  86847. /**
  86848. * Event triggerd when a dom action is required by the user to play the video.
  86849. * This happens due to recent changes in browser policies preventing video to auto start.
  86850. */
  86851. readonly onUserActionRequestedObservable: Observable<Texture>;
  86852. private _generateMipMaps;
  86853. private _engine;
  86854. private _stillImageCaptured;
  86855. private _displayingPosterTexture;
  86856. private _settings;
  86857. private _createInternalTextureOnEvent;
  86858. /**
  86859. * Creates a video texture.
  86860. * If you want to display a video in your scene, this is the special texture for that.
  86861. * This special texture works similar to other textures, with the exception of a few parameters.
  86862. * @see https://doc.babylonjs.com/how_to/video_texture
  86863. * @param name optional name, will detect from video source, if not defined
  86864. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86865. * @param scene is obviously the current scene.
  86866. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86867. * @param invertY is false by default but can be used to invert video on Y axis
  86868. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86869. * @param settings allows finer control over video usage
  86870. */
  86871. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86872. private _getName;
  86873. private _getVideo;
  86874. private _createInternalTexture;
  86875. private reset;
  86876. /**
  86877. * @hidden Internal method to initiate `update`.
  86878. */
  86879. _rebuild(): void;
  86880. /**
  86881. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86882. */
  86883. update(): void;
  86884. /**
  86885. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86886. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86887. */
  86888. updateTexture(isVisible: boolean): void;
  86889. protected _updateInternalTexture: () => void;
  86890. /**
  86891. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86892. * @param url New url.
  86893. */
  86894. updateURL(url: string): void;
  86895. /**
  86896. * Dispose the texture and release its associated resources.
  86897. */
  86898. dispose(): void;
  86899. /**
  86900. * Creates a video texture straight from a stream.
  86901. * @param scene Define the scene the texture should be created in
  86902. * @param stream Define the stream the texture should be created from
  86903. * @returns The created video texture as a promise
  86904. */
  86905. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86906. /**
  86907. * Creates a video texture straight from your WebCam video feed.
  86908. * @param scene Define the scene the texture should be created in
  86909. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86910. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86911. * @returns The created video texture as a promise
  86912. */
  86913. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86914. minWidth: number;
  86915. maxWidth: number;
  86916. minHeight: number;
  86917. maxHeight: number;
  86918. deviceId: string;
  86919. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86920. /**
  86921. * Creates a video texture straight from your WebCam video feed.
  86922. * @param scene Define the scene the texture should be created in
  86923. * @param onReady Define a callback to triggered once the texture will be ready
  86924. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86925. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86926. */
  86927. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86928. minWidth: number;
  86929. maxWidth: number;
  86930. minHeight: number;
  86931. maxHeight: number;
  86932. deviceId: string;
  86933. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86934. }
  86935. }
  86936. declare module BABYLON {
  86937. /**
  86938. * Interface for attribute information associated with buffer instanciation
  86939. */
  86940. export class InstancingAttributeInfo {
  86941. /**
  86942. * Index/offset of the attribute in the vertex shader
  86943. */
  86944. index: number;
  86945. /**
  86946. * size of the attribute, 1, 2, 3 or 4
  86947. */
  86948. attributeSize: number;
  86949. /**
  86950. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86951. * default is FLOAT
  86952. */
  86953. attribyteType: number;
  86954. /**
  86955. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86956. */
  86957. normalized: boolean;
  86958. /**
  86959. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86960. */
  86961. offset: number;
  86962. /**
  86963. * Name of the GLSL attribute, for debugging purpose only
  86964. */
  86965. attributeName: string;
  86966. }
  86967. /**
  86968. * Define options used to create a depth texture
  86969. */
  86970. export class DepthTextureCreationOptions {
  86971. /** Specifies whether or not a stencil should be allocated in the texture */
  86972. generateStencil?: boolean;
  86973. /** Specifies whether or not bilinear filtering is enable on the texture */
  86974. bilinearFiltering?: boolean;
  86975. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86976. comparisonFunction?: number;
  86977. /** Specifies if the created texture is a cube texture */
  86978. isCube?: boolean;
  86979. }
  86980. /**
  86981. * Class used to describe the capabilities of the engine relatively to the current browser
  86982. */
  86983. export class EngineCapabilities {
  86984. /** Maximum textures units per fragment shader */
  86985. maxTexturesImageUnits: number;
  86986. /** Maximum texture units per vertex shader */
  86987. maxVertexTextureImageUnits: number;
  86988. /** Maximum textures units in the entire pipeline */
  86989. maxCombinedTexturesImageUnits: number;
  86990. /** Maximum texture size */
  86991. maxTextureSize: number;
  86992. /** Maximum cube texture size */
  86993. maxCubemapTextureSize: number;
  86994. /** Maximum render texture size */
  86995. maxRenderTextureSize: number;
  86996. /** Maximum number of vertex attributes */
  86997. maxVertexAttribs: number;
  86998. /** Maximum number of varyings */
  86999. maxVaryingVectors: number;
  87000. /** Maximum number of uniforms per vertex shader */
  87001. maxVertexUniformVectors: number;
  87002. /** Maximum number of uniforms per fragment shader */
  87003. maxFragmentUniformVectors: number;
  87004. /** Defines if standard derivates (dx/dy) are supported */
  87005. standardDerivatives: boolean;
  87006. /** Defines if s3tc texture compression is supported */
  87007. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  87008. /** Defines if pvrtc texture compression is supported */
  87009. pvrtc: any;
  87010. /** Defines if etc1 texture compression is supported */
  87011. etc1: any;
  87012. /** Defines if etc2 texture compression is supported */
  87013. etc2: any;
  87014. /** Defines if astc texture compression is supported */
  87015. astc: any;
  87016. /** Defines if float textures are supported */
  87017. textureFloat: boolean;
  87018. /** Defines if vertex array objects are supported */
  87019. vertexArrayObject: boolean;
  87020. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  87021. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  87022. /** Gets the maximum level of anisotropy supported */
  87023. maxAnisotropy: number;
  87024. /** Defines if instancing is supported */
  87025. instancedArrays: boolean;
  87026. /** Defines if 32 bits indices are supported */
  87027. uintIndices: boolean;
  87028. /** Defines if high precision shaders are supported */
  87029. highPrecisionShaderSupported: boolean;
  87030. /** Defines if depth reading in the fragment shader is supported */
  87031. fragmentDepthSupported: boolean;
  87032. /** Defines if float texture linear filtering is supported*/
  87033. textureFloatLinearFiltering: boolean;
  87034. /** Defines if rendering to float textures is supported */
  87035. textureFloatRender: boolean;
  87036. /** Defines if half float textures are supported*/
  87037. textureHalfFloat: boolean;
  87038. /** Defines if half float texture linear filtering is supported*/
  87039. textureHalfFloatLinearFiltering: boolean;
  87040. /** Defines if rendering to half float textures is supported */
  87041. textureHalfFloatRender: boolean;
  87042. /** Defines if textureLOD shader command is supported */
  87043. textureLOD: boolean;
  87044. /** Defines if draw buffers extension is supported */
  87045. drawBuffersExtension: boolean;
  87046. /** Defines if depth textures are supported */
  87047. depthTextureExtension: boolean;
  87048. /** Defines if float color buffer are supported */
  87049. colorBufferFloat: boolean;
  87050. /** Gets disjoint timer query extension (null if not supported) */
  87051. timerQuery: EXT_disjoint_timer_query;
  87052. /** Defines if timestamp can be used with timer query */
  87053. canUseTimestampForTimerQuery: boolean;
  87054. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87055. multiview: any;
  87056. /** Function used to let the system compiles shaders in background */
  87057. parallelShaderCompile: {
  87058. COMPLETION_STATUS_KHR: number;
  87059. };
  87060. }
  87061. /** Interface defining initialization parameters for Engine class */
  87062. export interface EngineOptions extends WebGLContextAttributes {
  87063. /**
  87064. * Defines if the engine should no exceed a specified device ratio
  87065. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87066. */
  87067. limitDeviceRatio?: number;
  87068. /**
  87069. * Defines if webvr should be enabled automatically
  87070. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87071. */
  87072. autoEnableWebVR?: boolean;
  87073. /**
  87074. * Defines if webgl2 should be turned off even if supported
  87075. * @see http://doc.babylonjs.com/features/webgl2
  87076. */
  87077. disableWebGL2Support?: boolean;
  87078. /**
  87079. * Defines if webaudio should be initialized as well
  87080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87081. */
  87082. audioEngine?: boolean;
  87083. /**
  87084. * Defines if animations should run using a deterministic lock step
  87085. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87086. */
  87087. deterministicLockstep?: boolean;
  87088. /** Defines the maximum steps to use with deterministic lock step mode */
  87089. lockstepMaxSteps?: number;
  87090. /**
  87091. * Defines that engine should ignore context lost events
  87092. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87093. */
  87094. doNotHandleContextLost?: boolean;
  87095. /**
  87096. * Defines that engine should ignore modifying touch action attribute and style
  87097. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87098. */
  87099. doNotHandleTouchAction?: boolean;
  87100. /**
  87101. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87102. */
  87103. useHighPrecisionFloats?: boolean;
  87104. }
  87105. /**
  87106. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87107. */
  87108. export class Engine {
  87109. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87110. static ExceptionList: ({
  87111. key: string;
  87112. capture: string;
  87113. captureConstraint: number;
  87114. targets: string[];
  87115. } | {
  87116. key: string;
  87117. capture: null;
  87118. captureConstraint: null;
  87119. targets: string[];
  87120. })[];
  87121. /** Gets the list of created engines */
  87122. static readonly Instances: Engine[];
  87123. /**
  87124. * Gets the latest created engine
  87125. */
  87126. static readonly LastCreatedEngine: Nullable<Engine>;
  87127. /**
  87128. * Gets the latest created scene
  87129. */
  87130. static readonly LastCreatedScene: Nullable<Scene>;
  87131. /**
  87132. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87133. * @param flag defines which part of the materials must be marked as dirty
  87134. * @param predicate defines a predicate used to filter which materials should be affected
  87135. */
  87136. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87137. /**
  87138. * Hidden
  87139. */
  87140. static _TextureLoaders: IInternalTextureLoader[];
  87141. /** Defines that alpha blending is disabled */
  87142. static readonly ALPHA_DISABLE: number;
  87143. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87144. static readonly ALPHA_ADD: number;
  87145. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87146. static readonly ALPHA_COMBINE: number;
  87147. /** Defines that alpha blending to DEST - SRC * DEST */
  87148. static readonly ALPHA_SUBTRACT: number;
  87149. /** Defines that alpha blending to SRC * DEST */
  87150. static readonly ALPHA_MULTIPLY: number;
  87151. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87152. static readonly ALPHA_MAXIMIZED: number;
  87153. /** Defines that alpha blending to SRC + DEST */
  87154. static readonly ALPHA_ONEONE: number;
  87155. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87156. static readonly ALPHA_PREMULTIPLIED: number;
  87157. /**
  87158. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87159. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87160. */
  87161. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87162. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87163. static readonly ALPHA_INTERPOLATE: number;
  87164. /**
  87165. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87166. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87167. */
  87168. static readonly ALPHA_SCREENMODE: number;
  87169. /** Defines that the ressource is not delayed*/
  87170. static readonly DELAYLOADSTATE_NONE: number;
  87171. /** Defines that the ressource was successfully delay loaded */
  87172. static readonly DELAYLOADSTATE_LOADED: number;
  87173. /** Defines that the ressource is currently delay loading */
  87174. static readonly DELAYLOADSTATE_LOADING: number;
  87175. /** Defines that the ressource is delayed and has not started loading */
  87176. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87177. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87178. static readonly NEVER: number;
  87179. /** 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 */
  87180. static readonly ALWAYS: number;
  87181. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87182. static readonly LESS: number;
  87183. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87184. static readonly EQUAL: number;
  87185. /** 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 */
  87186. static readonly LEQUAL: number;
  87187. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87188. static readonly GREATER: number;
  87189. /** 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 */
  87190. static readonly GEQUAL: number;
  87191. /** 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 */
  87192. static readonly NOTEQUAL: number;
  87193. /** Passed to stencilOperation to specify that stencil value must be kept */
  87194. static readonly KEEP: number;
  87195. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87196. static readonly REPLACE: number;
  87197. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87198. static readonly INCR: number;
  87199. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87200. static readonly DECR: number;
  87201. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87202. static readonly INVERT: number;
  87203. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87204. static readonly INCR_WRAP: number;
  87205. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87206. static readonly DECR_WRAP: number;
  87207. /** Texture is not repeating outside of 0..1 UVs */
  87208. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87209. /** Texture is repeating outside of 0..1 UVs */
  87210. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87211. /** Texture is repeating and mirrored */
  87212. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87213. /** ALPHA */
  87214. static readonly TEXTUREFORMAT_ALPHA: number;
  87215. /** LUMINANCE */
  87216. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87217. /** LUMINANCE_ALPHA */
  87218. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87219. /** RGB */
  87220. static readonly TEXTUREFORMAT_RGB: number;
  87221. /** RGBA */
  87222. static readonly TEXTUREFORMAT_RGBA: number;
  87223. /** RED */
  87224. static readonly TEXTUREFORMAT_RED: number;
  87225. /** RED (2nd reference) */
  87226. static readonly TEXTUREFORMAT_R: number;
  87227. /** RG */
  87228. static readonly TEXTUREFORMAT_RG: number;
  87229. /** RED_INTEGER */
  87230. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87231. /** RED_INTEGER (2nd reference) */
  87232. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87233. /** RG_INTEGER */
  87234. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87235. /** RGB_INTEGER */
  87236. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87237. /** RGBA_INTEGER */
  87238. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87239. /** UNSIGNED_BYTE */
  87240. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87241. /** UNSIGNED_BYTE (2nd reference) */
  87242. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87243. /** FLOAT */
  87244. static readonly TEXTURETYPE_FLOAT: number;
  87245. /** HALF_FLOAT */
  87246. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87247. /** BYTE */
  87248. static readonly TEXTURETYPE_BYTE: number;
  87249. /** SHORT */
  87250. static readonly TEXTURETYPE_SHORT: number;
  87251. /** UNSIGNED_SHORT */
  87252. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87253. /** INT */
  87254. static readonly TEXTURETYPE_INT: number;
  87255. /** UNSIGNED_INT */
  87256. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87257. /** UNSIGNED_SHORT_4_4_4_4 */
  87258. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87259. /** UNSIGNED_SHORT_5_5_5_1 */
  87260. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87261. /** UNSIGNED_SHORT_5_6_5 */
  87262. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87263. /** UNSIGNED_INT_2_10_10_10_REV */
  87264. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87265. /** UNSIGNED_INT_24_8 */
  87266. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87267. /** UNSIGNED_INT_10F_11F_11F_REV */
  87268. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87269. /** UNSIGNED_INT_5_9_9_9_REV */
  87270. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87271. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87272. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87273. /** nearest is mag = nearest and min = nearest and mip = linear */
  87274. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87275. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87276. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87277. /** Trilinear is mag = linear and min = linear and mip = linear */
  87278. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87279. /** nearest is mag = nearest and min = nearest and mip = linear */
  87280. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87281. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87282. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87283. /** Trilinear is mag = linear and min = linear and mip = linear */
  87284. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87285. /** mag = nearest and min = nearest and mip = nearest */
  87286. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87287. /** mag = nearest and min = linear and mip = nearest */
  87288. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87289. /** mag = nearest and min = linear and mip = linear */
  87290. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87291. /** mag = nearest and min = linear and mip = none */
  87292. static readonly TEXTURE_NEAREST_LINEAR: number;
  87293. /** mag = nearest and min = nearest and mip = none */
  87294. static readonly TEXTURE_NEAREST_NEAREST: number;
  87295. /** mag = linear and min = nearest and mip = nearest */
  87296. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87297. /** mag = linear and min = nearest and mip = linear */
  87298. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87299. /** mag = linear and min = linear and mip = none */
  87300. static readonly TEXTURE_LINEAR_LINEAR: number;
  87301. /** mag = linear and min = nearest and mip = none */
  87302. static readonly TEXTURE_LINEAR_NEAREST: number;
  87303. /** Explicit coordinates mode */
  87304. static readonly TEXTURE_EXPLICIT_MODE: number;
  87305. /** Spherical coordinates mode */
  87306. static readonly TEXTURE_SPHERICAL_MODE: number;
  87307. /** Planar coordinates mode */
  87308. static readonly TEXTURE_PLANAR_MODE: number;
  87309. /** Cubic coordinates mode */
  87310. static readonly TEXTURE_CUBIC_MODE: number;
  87311. /** Projection coordinates mode */
  87312. static readonly TEXTURE_PROJECTION_MODE: number;
  87313. /** Skybox coordinates mode */
  87314. static readonly TEXTURE_SKYBOX_MODE: number;
  87315. /** Inverse Cubic coordinates mode */
  87316. static readonly TEXTURE_INVCUBIC_MODE: number;
  87317. /** Equirectangular coordinates mode */
  87318. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87319. /** Equirectangular Fixed coordinates mode */
  87320. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87321. /** Equirectangular Fixed Mirrored coordinates mode */
  87322. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87323. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87324. static readonly SCALEMODE_FLOOR: number;
  87325. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87326. static readonly SCALEMODE_NEAREST: number;
  87327. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87328. static readonly SCALEMODE_CEILING: number;
  87329. /**
  87330. * Returns the current npm package of the sdk
  87331. */
  87332. static readonly NpmPackage: string;
  87333. /**
  87334. * Returns the current version of the framework
  87335. */
  87336. static readonly Version: string;
  87337. /**
  87338. * Returns a string describing the current engine
  87339. */
  87340. readonly description: string;
  87341. /**
  87342. * Gets or sets the epsilon value used by collision engine
  87343. */
  87344. static CollisionsEpsilon: number;
  87345. /**
  87346. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87347. */
  87348. static ShadersRepository: string;
  87349. /**
  87350. * Method called to create the default loading screen.
  87351. * This can be overriden in your own app.
  87352. * @param canvas The rendering canvas element
  87353. * @returns The loading screen
  87354. */
  87355. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87356. /**
  87357. * Method called to create the default rescale post process on each engine.
  87358. */
  87359. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87360. /**
  87361. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87362. */
  87363. forcePOTTextures: boolean;
  87364. /**
  87365. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87366. */
  87367. isFullscreen: boolean;
  87368. /**
  87369. * Gets a boolean indicating if the pointer is currently locked
  87370. */
  87371. isPointerLock: boolean;
  87372. /**
  87373. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87374. */
  87375. cullBackFaces: boolean;
  87376. /**
  87377. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87378. */
  87379. renderEvenInBackground: boolean;
  87380. /**
  87381. * Gets or sets a boolean indicating that cache can be kept between frames
  87382. */
  87383. preventCacheWipeBetweenFrames: boolean;
  87384. /**
  87385. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87386. **/
  87387. enableOfflineSupport: boolean;
  87388. /**
  87389. * 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)
  87390. **/
  87391. disableManifestCheck: boolean;
  87392. /**
  87393. * Gets the list of created scenes
  87394. */
  87395. scenes: Scene[];
  87396. /**
  87397. * Event raised when a new scene is created
  87398. */
  87399. onNewSceneAddedObservable: Observable<Scene>;
  87400. /**
  87401. * Gets the list of created postprocesses
  87402. */
  87403. postProcesses: PostProcess[];
  87404. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87405. validateShaderPrograms: boolean;
  87406. /**
  87407. * Observable event triggered each time the rendering canvas is resized
  87408. */
  87409. onResizeObservable: Observable<Engine>;
  87410. /**
  87411. * Observable event triggered each time the canvas loses focus
  87412. */
  87413. onCanvasBlurObservable: Observable<Engine>;
  87414. /**
  87415. * Observable event triggered each time the canvas gains focus
  87416. */
  87417. onCanvasFocusObservable: Observable<Engine>;
  87418. /**
  87419. * Observable event triggered each time the canvas receives pointerout event
  87420. */
  87421. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87422. /**
  87423. * Observable event triggered before each texture is initialized
  87424. */
  87425. onBeforeTextureInitObservable: Observable<Texture>;
  87426. /**
  87427. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87428. */
  87429. disableUniformBuffers: boolean;
  87430. /** @hidden */
  87431. _uniformBuffers: UniformBuffer[];
  87432. /**
  87433. * Gets a boolean indicating that the engine supports uniform buffers
  87434. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87435. */
  87436. readonly supportsUniformBuffers: boolean;
  87437. /**
  87438. * Observable raised when the engine begins a new frame
  87439. */
  87440. onBeginFrameObservable: Observable<Engine>;
  87441. /**
  87442. * If set, will be used to request the next animation frame for the render loop
  87443. */
  87444. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87445. /**
  87446. * Observable raised when the engine ends the current frame
  87447. */
  87448. onEndFrameObservable: Observable<Engine>;
  87449. /**
  87450. * Observable raised when the engine is about to compile a shader
  87451. */
  87452. onBeforeShaderCompilationObservable: Observable<Engine>;
  87453. /**
  87454. * Observable raised when the engine has jsut compiled a shader
  87455. */
  87456. onAfterShaderCompilationObservable: Observable<Engine>;
  87457. /** @hidden */
  87458. _gl: WebGLRenderingContext;
  87459. private _renderingCanvas;
  87460. private _windowIsBackground;
  87461. private _webGLVersion;
  87462. protected _highPrecisionShadersAllowed: boolean;
  87463. /** @hidden */
  87464. readonly _shouldUseHighPrecisionShader: boolean;
  87465. /**
  87466. * Gets a boolean indicating that only power of 2 textures are supported
  87467. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87468. */
  87469. readonly needPOTTextures: boolean;
  87470. /** @hidden */
  87471. _badOS: boolean;
  87472. /** @hidden */
  87473. _badDesktopOS: boolean;
  87474. /**
  87475. * Gets the audio engine
  87476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87477. * @ignorenaming
  87478. */
  87479. static audioEngine: IAudioEngine;
  87480. /**
  87481. * Default AudioEngine factory responsible of creating the Audio Engine.
  87482. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87483. */
  87484. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87485. /**
  87486. * Default offline support factory responsible of creating a tool used to store data locally.
  87487. * By default, this will create a Database object if the workload has been embedded.
  87488. */
  87489. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87490. private _onFocus;
  87491. private _onBlur;
  87492. private _onCanvasPointerOut;
  87493. private _onCanvasBlur;
  87494. private _onCanvasFocus;
  87495. private _onFullscreenChange;
  87496. private _onPointerLockChange;
  87497. private _hardwareScalingLevel;
  87498. /** @hidden */
  87499. _caps: EngineCapabilities;
  87500. private _pointerLockRequested;
  87501. private _isStencilEnable;
  87502. private _colorWrite;
  87503. private _loadingScreen;
  87504. /** @hidden */
  87505. _drawCalls: PerfCounter;
  87506. private _glVersion;
  87507. private _glRenderer;
  87508. private _glVendor;
  87509. private _videoTextureSupported;
  87510. private _renderingQueueLaunched;
  87511. private _activeRenderLoops;
  87512. private _deterministicLockstep;
  87513. private _lockstepMaxSteps;
  87514. /**
  87515. * Observable signaled when a context lost event is raised
  87516. */
  87517. onContextLostObservable: Observable<Engine>;
  87518. /**
  87519. * Observable signaled when a context restored event is raised
  87520. */
  87521. onContextRestoredObservable: Observable<Engine>;
  87522. private _onContextLost;
  87523. private _onContextRestored;
  87524. private _contextWasLost;
  87525. /** @hidden */
  87526. _doNotHandleContextLost: boolean;
  87527. /**
  87528. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87530. */
  87531. doNotHandleContextLost: boolean;
  87532. private _performanceMonitor;
  87533. private _fps;
  87534. private _deltaTime;
  87535. /**
  87536. * Turn this value on if you want to pause FPS computation when in background
  87537. */
  87538. disablePerformanceMonitorInBackground: boolean;
  87539. /**
  87540. * Gets the performance monitor attached to this engine
  87541. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87542. */
  87543. readonly performanceMonitor: PerformanceMonitor;
  87544. /**
  87545. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87546. */
  87547. disableVertexArrayObjects: boolean;
  87548. /** @hidden */
  87549. protected _depthCullingState: _DepthCullingState;
  87550. /** @hidden */
  87551. protected _stencilState: _StencilState;
  87552. /** @hidden */
  87553. protected _alphaState: _AlphaState;
  87554. /** @hidden */
  87555. protected _alphaMode: number;
  87556. /** @hidden */
  87557. _internalTexturesCache: InternalTexture[];
  87558. /** @hidden */
  87559. protected _activeChannel: number;
  87560. private _currentTextureChannel;
  87561. /** @hidden */
  87562. protected _boundTexturesCache: {
  87563. [key: string]: Nullable<InternalTexture>;
  87564. };
  87565. /** @hidden */
  87566. protected _currentEffect: Nullable<Effect>;
  87567. /** @hidden */
  87568. protected _currentProgram: Nullable<WebGLProgram>;
  87569. private _compiledEffects;
  87570. private _vertexAttribArraysEnabled;
  87571. /** @hidden */
  87572. protected _cachedViewport: Nullable<Viewport>;
  87573. private _cachedVertexArrayObject;
  87574. /** @hidden */
  87575. protected _cachedVertexBuffers: any;
  87576. /** @hidden */
  87577. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87578. /** @hidden */
  87579. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87580. /** @hidden */
  87581. _currentRenderTarget: Nullable<InternalTexture>;
  87582. private _uintIndicesCurrentlySet;
  87583. private _currentBoundBuffer;
  87584. /** @hidden */
  87585. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87586. private _currentBufferPointers;
  87587. private _currentInstanceLocations;
  87588. private _currentInstanceBuffers;
  87589. private _textureUnits;
  87590. /** @hidden */
  87591. _workingCanvas: Nullable<HTMLCanvasElement>;
  87592. /** @hidden */
  87593. _workingContext: Nullable<CanvasRenderingContext2D>;
  87594. private _rescalePostProcess;
  87595. private _dummyFramebuffer;
  87596. private _externalData;
  87597. /** @hidden */
  87598. _bindedRenderFunction: any;
  87599. private _vaoRecordInProgress;
  87600. private _mustWipeVertexAttributes;
  87601. private _emptyTexture;
  87602. private _emptyCubeTexture;
  87603. private _emptyTexture3D;
  87604. /** @hidden */
  87605. _frameHandler: number;
  87606. private _nextFreeTextureSlots;
  87607. private _maxSimultaneousTextures;
  87608. private _activeRequests;
  87609. private _texturesSupported;
  87610. /** @hidden */
  87611. _textureFormatInUse: Nullable<string>;
  87612. /**
  87613. * Gets the list of texture formats supported
  87614. */
  87615. readonly texturesSupported: Array<string>;
  87616. /**
  87617. * Gets the list of texture formats in use
  87618. */
  87619. readonly textureFormatInUse: Nullable<string>;
  87620. /**
  87621. * Gets the current viewport
  87622. */
  87623. readonly currentViewport: Nullable<Viewport>;
  87624. /**
  87625. * Gets the default empty texture
  87626. */
  87627. readonly emptyTexture: InternalTexture;
  87628. /**
  87629. * Gets the default empty 3D texture
  87630. */
  87631. readonly emptyTexture3D: InternalTexture;
  87632. /**
  87633. * Gets the default empty cube texture
  87634. */
  87635. readonly emptyCubeTexture: InternalTexture;
  87636. /**
  87637. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87638. */
  87639. readonly premultipliedAlpha: boolean;
  87640. /**
  87641. * Creates a new engine
  87642. * @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
  87643. * @param antialias defines enable antialiasing (default: false)
  87644. * @param options defines further options to be sent to the getContext() function
  87645. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87646. */
  87647. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87648. /**
  87649. * Initializes a webVR display and starts listening to display change events
  87650. * The onVRDisplayChangedObservable will be notified upon these changes
  87651. * @returns The onVRDisplayChangedObservable
  87652. */
  87653. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87654. /** @hidden */
  87655. _prepareVRComponent(): void;
  87656. /** @hidden */
  87657. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87658. /** @hidden */
  87659. _submitVRFrame(): void;
  87660. /**
  87661. * Call this function to leave webVR mode
  87662. * Will do nothing if webVR is not supported or if there is no webVR device
  87663. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87664. */
  87665. disableVR(): void;
  87666. /**
  87667. * Gets a boolean indicating that the system is in VR mode and is presenting
  87668. * @returns true if VR mode is engaged
  87669. */
  87670. isVRPresenting(): boolean;
  87671. /** @hidden */
  87672. _requestVRFrame(): void;
  87673. private _disableTouchAction;
  87674. private _rebuildInternalTextures;
  87675. private _rebuildEffects;
  87676. /**
  87677. * Gets a boolean indicating if all created effects are ready
  87678. * @returns true if all effects are ready
  87679. */
  87680. areAllEffectsReady(): boolean;
  87681. private _rebuildBuffers;
  87682. private _initGLContext;
  87683. /**
  87684. * Gets version of the current webGL context
  87685. */
  87686. readonly webGLVersion: number;
  87687. /**
  87688. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87689. */
  87690. readonly isStencilEnable: boolean;
  87691. /** @hidden */
  87692. _prepareWorkingCanvas(): void;
  87693. /**
  87694. * Reset the texture cache to empty state
  87695. */
  87696. resetTextureCache(): void;
  87697. /**
  87698. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87699. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87700. * @returns true if engine is in deterministic lock step mode
  87701. */
  87702. isDeterministicLockStep(): boolean;
  87703. /**
  87704. * Gets the max steps when engine is running in deterministic lock step
  87705. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87706. * @returns the max steps
  87707. */
  87708. getLockstepMaxSteps(): number;
  87709. /**
  87710. * Gets an object containing information about the current webGL context
  87711. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87712. */
  87713. getGlInfo(): {
  87714. vendor: string;
  87715. renderer: string;
  87716. version: string;
  87717. };
  87718. /**
  87719. * Gets current aspect ratio
  87720. * @param camera defines the camera to use to get the aspect ratio
  87721. * @param useScreen defines if screen size must be used (or the current render target if any)
  87722. * @returns a number defining the aspect ratio
  87723. */
  87724. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87725. /**
  87726. * Gets current screen aspect ratio
  87727. * @returns a number defining the aspect ratio
  87728. */
  87729. getScreenAspectRatio(): number;
  87730. /**
  87731. * Gets the current render width
  87732. * @param useScreen defines if screen size must be used (or the current render target if any)
  87733. * @returns a number defining the current render width
  87734. */
  87735. getRenderWidth(useScreen?: boolean): number;
  87736. /**
  87737. * Gets the current render height
  87738. * @param useScreen defines if screen size must be used (or the current render target if any)
  87739. * @returns a number defining the current render height
  87740. */
  87741. getRenderHeight(useScreen?: boolean): number;
  87742. /**
  87743. * Gets the HTML canvas attached with the current webGL context
  87744. * @returns a HTML canvas
  87745. */
  87746. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87747. /**
  87748. * Gets the client rect of the HTML canvas attached with the current webGL context
  87749. * @returns a client rectanglee
  87750. */
  87751. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87752. /**
  87753. * Defines the hardware scaling level.
  87754. * By default the hardware scaling level is computed from the window device ratio.
  87755. * 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.
  87756. * @param level defines the level to use
  87757. */
  87758. setHardwareScalingLevel(level: number): void;
  87759. /**
  87760. * Gets the current hardware scaling level.
  87761. * By default the hardware scaling level is computed from the window device ratio.
  87762. * 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.
  87763. * @returns a number indicating the current hardware scaling level
  87764. */
  87765. getHardwareScalingLevel(): number;
  87766. /**
  87767. * Gets the list of loaded textures
  87768. * @returns an array containing all loaded textures
  87769. */
  87770. getLoadedTexturesCache(): InternalTexture[];
  87771. /**
  87772. * Gets the object containing all engine capabilities
  87773. * @returns the EngineCapabilities object
  87774. */
  87775. getCaps(): EngineCapabilities;
  87776. /**
  87777. * Gets the current depth function
  87778. * @returns a number defining the depth function
  87779. */
  87780. getDepthFunction(): Nullable<number>;
  87781. /**
  87782. * Sets the current depth function
  87783. * @param depthFunc defines the function to use
  87784. */
  87785. setDepthFunction(depthFunc: number): void;
  87786. /**
  87787. * Sets the current depth function to GREATER
  87788. */
  87789. setDepthFunctionToGreater(): void;
  87790. /**
  87791. * Sets the current depth function to GEQUAL
  87792. */
  87793. setDepthFunctionToGreaterOrEqual(): void;
  87794. /**
  87795. * Sets the current depth function to LESS
  87796. */
  87797. setDepthFunctionToLess(): void;
  87798. private _cachedStencilBuffer;
  87799. private _cachedStencilFunction;
  87800. private _cachedStencilMask;
  87801. private _cachedStencilOperationPass;
  87802. private _cachedStencilOperationFail;
  87803. private _cachedStencilOperationDepthFail;
  87804. private _cachedStencilReference;
  87805. /**
  87806. * Caches the the state of the stencil buffer
  87807. */
  87808. cacheStencilState(): void;
  87809. /**
  87810. * Restores the state of the stencil buffer
  87811. */
  87812. restoreStencilState(): void;
  87813. /**
  87814. * Sets the current depth function to LEQUAL
  87815. */
  87816. setDepthFunctionToLessOrEqual(): void;
  87817. /**
  87818. * Gets a boolean indicating if stencil buffer is enabled
  87819. * @returns the current stencil buffer state
  87820. */
  87821. getStencilBuffer(): boolean;
  87822. /**
  87823. * Enable or disable the stencil buffer
  87824. * @param enable defines if the stencil buffer must be enabled or disabled
  87825. */
  87826. setStencilBuffer(enable: boolean): void;
  87827. /**
  87828. * Gets the current stencil mask
  87829. * @returns a number defining the new stencil mask to use
  87830. */
  87831. getStencilMask(): number;
  87832. /**
  87833. * Sets the current stencil mask
  87834. * @param mask defines the new stencil mask to use
  87835. */
  87836. setStencilMask(mask: number): void;
  87837. /**
  87838. * Gets the current stencil function
  87839. * @returns a number defining the stencil function to use
  87840. */
  87841. getStencilFunction(): number;
  87842. /**
  87843. * Gets the current stencil reference value
  87844. * @returns a number defining the stencil reference value to use
  87845. */
  87846. getStencilFunctionReference(): number;
  87847. /**
  87848. * Gets the current stencil mask
  87849. * @returns a number defining the stencil mask to use
  87850. */
  87851. getStencilFunctionMask(): number;
  87852. /**
  87853. * Sets the current stencil function
  87854. * @param stencilFunc defines the new stencil function to use
  87855. */
  87856. setStencilFunction(stencilFunc: number): void;
  87857. /**
  87858. * Sets the current stencil reference
  87859. * @param reference defines the new stencil reference to use
  87860. */
  87861. setStencilFunctionReference(reference: number): void;
  87862. /**
  87863. * Sets the current stencil mask
  87864. * @param mask defines the new stencil mask to use
  87865. */
  87866. setStencilFunctionMask(mask: number): void;
  87867. /**
  87868. * Gets the current stencil operation when stencil fails
  87869. * @returns a number defining stencil operation to use when stencil fails
  87870. */
  87871. getStencilOperationFail(): number;
  87872. /**
  87873. * Gets the current stencil operation when depth fails
  87874. * @returns a number defining stencil operation to use when depth fails
  87875. */
  87876. getStencilOperationDepthFail(): number;
  87877. /**
  87878. * Gets the current stencil operation when stencil passes
  87879. * @returns a number defining stencil operation to use when stencil passes
  87880. */
  87881. getStencilOperationPass(): number;
  87882. /**
  87883. * Sets the stencil operation to use when stencil fails
  87884. * @param operation defines the stencil operation to use when stencil fails
  87885. */
  87886. setStencilOperationFail(operation: number): void;
  87887. /**
  87888. * Sets the stencil operation to use when depth fails
  87889. * @param operation defines the stencil operation to use when depth fails
  87890. */
  87891. setStencilOperationDepthFail(operation: number): void;
  87892. /**
  87893. * Sets the stencil operation to use when stencil passes
  87894. * @param operation defines the stencil operation to use when stencil passes
  87895. */
  87896. setStencilOperationPass(operation: number): void;
  87897. /**
  87898. * Sets a boolean indicating if the dithering state is enabled or disabled
  87899. * @param value defines the dithering state
  87900. */
  87901. setDitheringState(value: boolean): void;
  87902. /**
  87903. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87904. * @param value defines the rasterizer state
  87905. */
  87906. setRasterizerState(value: boolean): void;
  87907. /**
  87908. * stop executing a render loop function and remove it from the execution array
  87909. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87910. */
  87911. stopRenderLoop(renderFunction?: () => void): void;
  87912. /** @hidden */
  87913. _renderLoop(): void;
  87914. /**
  87915. * Register and execute a render loop. The engine can have more than one render function
  87916. * @param renderFunction defines the function to continuously execute
  87917. */
  87918. runRenderLoop(renderFunction: () => void): void;
  87919. /**
  87920. * Toggle full screen mode
  87921. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87922. */
  87923. switchFullscreen(requestPointerLock: boolean): void;
  87924. /**
  87925. * Enters full screen mode
  87926. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87927. */
  87928. enterFullscreen(requestPointerLock: boolean): void;
  87929. /**
  87930. * Exits full screen mode
  87931. */
  87932. exitFullscreen(): void;
  87933. /**
  87934. * Clear the current render buffer or the current render target (if any is set up)
  87935. * @param color defines the color to use
  87936. * @param backBuffer defines if the back buffer must be cleared
  87937. * @param depth defines if the depth buffer must be cleared
  87938. * @param stencil defines if the stencil buffer must be cleared
  87939. */
  87940. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87941. /**
  87942. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87943. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87944. * @param y defines the y-coordinate of the corner of the clear rectangle
  87945. * @param width defines the width of the clear rectangle
  87946. * @param height defines the height of the clear rectangle
  87947. * @param clearColor defines the clear color
  87948. */
  87949. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87950. /**
  87951. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87952. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87953. * @param y defines the y-coordinate of the corner of the clear rectangle
  87954. * @param width defines the width of the clear rectangle
  87955. * @param height defines the height of the clear rectangle
  87956. */
  87957. enableScissor(x: number, y: number, width: number, height: number): void;
  87958. /**
  87959. * Disable previously set scissor test rectangle
  87960. */
  87961. disableScissor(): void;
  87962. private _viewportCached;
  87963. /** @hidden */
  87964. _viewport(x: number, y: number, width: number, height: number): void;
  87965. /**
  87966. * Set the WebGL's viewport
  87967. * @param viewport defines the viewport element to be used
  87968. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87969. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87970. */
  87971. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87972. /**
  87973. * Directly set the WebGL Viewport
  87974. * @param x defines the x coordinate of the viewport (in screen space)
  87975. * @param y defines the y coordinate of the viewport (in screen space)
  87976. * @param width defines the width of the viewport (in screen space)
  87977. * @param height defines the height of the viewport (in screen space)
  87978. * @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
  87979. */
  87980. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87981. /**
  87982. * Begin a new frame
  87983. */
  87984. beginFrame(): void;
  87985. /**
  87986. * Enf the current frame
  87987. */
  87988. endFrame(): void;
  87989. /**
  87990. * Resize the view according to the canvas' size
  87991. */
  87992. resize(): void;
  87993. /**
  87994. * Force a specific size of the canvas
  87995. * @param width defines the new canvas' width
  87996. * @param height defines the new canvas' height
  87997. */
  87998. setSize(width: number, height: number): void;
  87999. /**
  88000. * Binds the frame buffer to the specified texture.
  88001. * @param texture The texture to render to or null for the default canvas
  88002. * @param faceIndex The face of the texture to render to in case of cube texture
  88003. * @param requiredWidth The width of the target to render to
  88004. * @param requiredHeight The height of the target to render to
  88005. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  88006. * @param depthStencilTexture The depth stencil texture to use to render
  88007. * @param lodLevel defines le lod level to bind to the frame buffer
  88008. */
  88009. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  88010. /** @hidden */
  88011. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  88012. /**
  88013. * Unbind the current render target texture from the webGL context
  88014. * @param texture defines the render target texture to unbind
  88015. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  88016. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  88017. */
  88018. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  88019. /**
  88020. * Force the mipmap generation for the given render target texture
  88021. * @param texture defines the render target texture to use
  88022. */
  88023. generateMipMapsForCubemap(texture: InternalTexture): void;
  88024. /**
  88025. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  88026. */
  88027. flushFramebuffer(): void;
  88028. /**
  88029. * Unbind the current render target and bind the default framebuffer
  88030. */
  88031. restoreDefaultFramebuffer(): void;
  88032. /**
  88033. * Create an uniform buffer
  88034. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88035. * @param elements defines the content of the uniform buffer
  88036. * @returns the webGL uniform buffer
  88037. */
  88038. createUniformBuffer(elements: FloatArray): DataBuffer;
  88039. /**
  88040. * Create a dynamic uniform buffer
  88041. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88042. * @param elements defines the content of the uniform buffer
  88043. * @returns the webGL uniform buffer
  88044. */
  88045. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88046. /**
  88047. * Update an existing uniform buffer
  88048. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88049. * @param uniformBuffer defines the target uniform buffer
  88050. * @param elements defines the content to update
  88051. * @param offset defines the offset in the uniform buffer where update should start
  88052. * @param count defines the size of the data to update
  88053. */
  88054. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88055. private _resetVertexBufferBinding;
  88056. /**
  88057. * Creates a vertex buffer
  88058. * @param data the data for the vertex buffer
  88059. * @returns the new WebGL static buffer
  88060. */
  88061. createVertexBuffer(data: DataArray): DataBuffer;
  88062. /**
  88063. * Creates a dynamic vertex buffer
  88064. * @param data the data for the dynamic vertex buffer
  88065. * @returns the new WebGL dynamic buffer
  88066. */
  88067. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88068. /**
  88069. * Update a dynamic index buffer
  88070. * @param indexBuffer defines the target index buffer
  88071. * @param indices defines the data to update
  88072. * @param offset defines the offset in the target index buffer where update should start
  88073. */
  88074. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88075. /**
  88076. * Updates a dynamic vertex buffer.
  88077. * @param vertexBuffer the vertex buffer to update
  88078. * @param data the data used to update the vertex buffer
  88079. * @param byteOffset the byte offset of the data
  88080. * @param byteLength the byte length of the data
  88081. */
  88082. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88083. private _resetIndexBufferBinding;
  88084. /**
  88085. * Creates a new index buffer
  88086. * @param indices defines the content of the index buffer
  88087. * @param updatable defines if the index buffer must be updatable
  88088. * @returns a new webGL buffer
  88089. */
  88090. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88091. /**
  88092. * Bind a webGL buffer to the webGL context
  88093. * @param buffer defines the buffer to bind
  88094. */
  88095. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88096. /**
  88097. * Bind an uniform buffer to the current webGL context
  88098. * @param buffer defines the buffer to bind
  88099. */
  88100. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88101. /**
  88102. * Bind a buffer to the current webGL context at a given location
  88103. * @param buffer defines the buffer to bind
  88104. * @param location defines the index where to bind the buffer
  88105. */
  88106. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88107. /**
  88108. * Bind a specific block at a given index in a specific shader program
  88109. * @param pipelineContext defines the pipeline context to use
  88110. * @param blockName defines the block name
  88111. * @param index defines the index where to bind the block
  88112. */
  88113. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88114. private bindIndexBuffer;
  88115. private bindBuffer;
  88116. /**
  88117. * update the bound buffer with the given data
  88118. * @param data defines the data to update
  88119. */
  88120. updateArrayBuffer(data: Float32Array): void;
  88121. private _vertexAttribPointer;
  88122. private _bindIndexBufferWithCache;
  88123. private _bindVertexBuffersAttributes;
  88124. /**
  88125. * Records a vertex array object
  88126. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88127. * @param vertexBuffers defines the list of vertex buffers to store
  88128. * @param indexBuffer defines the index buffer to store
  88129. * @param effect defines the effect to store
  88130. * @returns the new vertex array object
  88131. */
  88132. recordVertexArrayObject(vertexBuffers: {
  88133. [key: string]: VertexBuffer;
  88134. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88135. /**
  88136. * Bind a specific vertex array object
  88137. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88138. * @param vertexArrayObject defines the vertex array object to bind
  88139. * @param indexBuffer defines the index buffer to bind
  88140. */
  88141. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88142. /**
  88143. * Bind webGl buffers directly to the webGL context
  88144. * @param vertexBuffer defines the vertex buffer to bind
  88145. * @param indexBuffer defines the index buffer to bind
  88146. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88147. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88148. * @param effect defines the effect associated with the vertex buffer
  88149. */
  88150. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88151. private _unbindVertexArrayObject;
  88152. /**
  88153. * Bind a list of vertex buffers to the webGL context
  88154. * @param vertexBuffers defines the list of vertex buffers to bind
  88155. * @param indexBuffer defines the index buffer to bind
  88156. * @param effect defines the effect associated with the vertex buffers
  88157. */
  88158. bindBuffers(vertexBuffers: {
  88159. [key: string]: Nullable<VertexBuffer>;
  88160. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88161. /**
  88162. * Unbind all instance attributes
  88163. */
  88164. unbindInstanceAttributes(): void;
  88165. /**
  88166. * Release and free the memory of a vertex array object
  88167. * @param vao defines the vertex array object to delete
  88168. */
  88169. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88170. /** @hidden */
  88171. _releaseBuffer(buffer: DataBuffer): boolean;
  88172. /**
  88173. * Creates a webGL buffer to use with instanciation
  88174. * @param capacity defines the size of the buffer
  88175. * @returns the webGL buffer
  88176. */
  88177. createInstancesBuffer(capacity: number): DataBuffer;
  88178. /**
  88179. * Delete a webGL buffer used with instanciation
  88180. * @param buffer defines the webGL buffer to delete
  88181. */
  88182. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88183. /**
  88184. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88185. * @param instancesBuffer defines the webGL buffer to update and bind
  88186. * @param data defines the data to store in the buffer
  88187. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88188. */
  88189. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88190. /**
  88191. * Apply all cached states (depth, culling, stencil and alpha)
  88192. */
  88193. applyStates(): void;
  88194. /**
  88195. * Send a draw order
  88196. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88197. * @param indexStart defines the starting index
  88198. * @param indexCount defines the number of index to draw
  88199. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88200. */
  88201. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88202. /**
  88203. * Draw a list of points
  88204. * @param verticesStart defines the index of first vertex to draw
  88205. * @param verticesCount defines the count of vertices to draw
  88206. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88207. */
  88208. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88209. /**
  88210. * Draw a list of unindexed primitives
  88211. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88212. * @param verticesStart defines the index of first vertex to draw
  88213. * @param verticesCount defines the count of vertices to draw
  88214. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88215. */
  88216. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88217. /**
  88218. * Draw a list of indexed primitives
  88219. * @param fillMode defines the primitive to use
  88220. * @param indexStart defines the starting index
  88221. * @param indexCount defines the number of index to draw
  88222. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88223. */
  88224. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88225. /**
  88226. * Draw a list of unindexed primitives
  88227. * @param fillMode defines the primitive to use
  88228. * @param verticesStart defines the index of first vertex to draw
  88229. * @param verticesCount defines the count of vertices to draw
  88230. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88231. */
  88232. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88233. private _drawMode;
  88234. /** @hidden */
  88235. _releaseEffect(effect: Effect): void;
  88236. /** @hidden */
  88237. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88238. /**
  88239. * Create a new effect (used to store vertex/fragment shaders)
  88240. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88241. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88242. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88243. * @param samplers defines an array of string used to represent textures
  88244. * @param defines defines the string containing the defines to use to compile the shaders
  88245. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88246. * @param onCompiled defines a function to call when the effect creation is successful
  88247. * @param onError defines a function to call when the effect creation has failed
  88248. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88249. * @returns the new Effect
  88250. */
  88251. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  88252. private _compileShader;
  88253. private _compileRawShader;
  88254. /**
  88255. * Directly creates a webGL program
  88256. * @param pipelineContext defines the pipeline context to attach to
  88257. * @param vertexCode defines the vertex shader code to use
  88258. * @param fragmentCode defines the fragment shader code to use
  88259. * @param context defines the webGL context to use (if not set, the current one will be used)
  88260. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88261. * @returns the new webGL program
  88262. */
  88263. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88264. /**
  88265. * Creates a webGL program
  88266. * @param pipelineContext defines the pipeline context to attach to
  88267. * @param vertexCode defines the vertex shader code to use
  88268. * @param fragmentCode defines the fragment shader code to use
  88269. * @param defines defines the string containing the defines to use to compile the shaders
  88270. * @param context defines the webGL context to use (if not set, the current one will be used)
  88271. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88272. * @returns the new webGL program
  88273. */
  88274. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88275. /**
  88276. * Creates a new pipeline context
  88277. * @returns the new pipeline
  88278. */
  88279. createPipelineContext(): WebGLPipelineContext;
  88280. private _createShaderProgram;
  88281. private _finalizePipelineContext;
  88282. /** @hidden */
  88283. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88284. /** @hidden */
  88285. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88286. /** @hidden */
  88287. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88288. /**
  88289. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88290. * @param pipelineContext defines the pipeline context to use
  88291. * @param uniformsNames defines the list of uniform names
  88292. * @returns an array of webGL uniform locations
  88293. */
  88294. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88295. /**
  88296. * Gets the lsit of active attributes for a given webGL program
  88297. * @param pipelineContext defines the pipeline context to use
  88298. * @param attributesNames defines the list of attribute names to get
  88299. * @returns an array of indices indicating the offset of each attribute
  88300. */
  88301. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88302. /**
  88303. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88304. * @param effect defines the effect to activate
  88305. */
  88306. enableEffect(effect: Nullable<Effect>): void;
  88307. /**
  88308. * Set the value of an uniform to an array of int32
  88309. * @param uniform defines the webGL uniform location where to store the value
  88310. * @param array defines the array of int32 to store
  88311. */
  88312. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88313. /**
  88314. * Set the value of an uniform to an array of int32 (stored as vec2)
  88315. * @param uniform defines the webGL uniform location where to store the value
  88316. * @param array defines the array of int32 to store
  88317. */
  88318. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88319. /**
  88320. * Set the value of an uniform to an array of int32 (stored as vec3)
  88321. * @param uniform defines the webGL uniform location where to store the value
  88322. * @param array defines the array of int32 to store
  88323. */
  88324. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88325. /**
  88326. * Set the value of an uniform to an array of int32 (stored as vec4)
  88327. * @param uniform defines the webGL uniform location where to store the value
  88328. * @param array defines the array of int32 to store
  88329. */
  88330. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88331. /**
  88332. * Set the value of an uniform to an array of float32
  88333. * @param uniform defines the webGL uniform location where to store the value
  88334. * @param array defines the array of float32 to store
  88335. */
  88336. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88337. /**
  88338. * Set the value of an uniform to an array of float32 (stored as vec2)
  88339. * @param uniform defines the webGL uniform location where to store the value
  88340. * @param array defines the array of float32 to store
  88341. */
  88342. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88343. /**
  88344. * Set the value of an uniform to an array of float32 (stored as vec3)
  88345. * @param uniform defines the webGL uniform location where to store the value
  88346. * @param array defines the array of float32 to store
  88347. */
  88348. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88349. /**
  88350. * Set the value of an uniform to an array of float32 (stored as vec4)
  88351. * @param uniform defines the webGL uniform location where to store the value
  88352. * @param array defines the array of float32 to store
  88353. */
  88354. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88355. /**
  88356. * Set the value of an uniform to an array of number
  88357. * @param uniform defines the webGL uniform location where to store the value
  88358. * @param array defines the array of number to store
  88359. */
  88360. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88361. /**
  88362. * Set the value of an uniform to an array of number (stored as vec2)
  88363. * @param uniform defines the webGL uniform location where to store the value
  88364. * @param array defines the array of number to store
  88365. */
  88366. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88367. /**
  88368. * Set the value of an uniform to an array of number (stored as vec3)
  88369. * @param uniform defines the webGL uniform location where to store the value
  88370. * @param array defines the array of number to store
  88371. */
  88372. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88373. /**
  88374. * Set the value of an uniform to an array of number (stored as vec4)
  88375. * @param uniform defines the webGL uniform location where to store the value
  88376. * @param array defines the array of number to store
  88377. */
  88378. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88379. /**
  88380. * Set the value of an uniform to an array of float32 (stored as matrices)
  88381. * @param uniform defines the webGL uniform location where to store the value
  88382. * @param matrices defines the array of float32 to store
  88383. */
  88384. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88385. /**
  88386. * Set the value of an uniform to a matrix
  88387. * @param uniform defines the webGL uniform location where to store the value
  88388. * @param matrix defines the matrix to store
  88389. */
  88390. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88391. /**
  88392. * Set the value of an uniform to a matrix (3x3)
  88393. * @param uniform defines the webGL uniform location where to store the value
  88394. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88395. */
  88396. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88397. /**
  88398. * Set the value of an uniform to a matrix (2x2)
  88399. * @param uniform defines the webGL uniform location where to store the value
  88400. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88401. */
  88402. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88403. /**
  88404. * Set the value of an uniform to a number (int)
  88405. * @param uniform defines the webGL uniform location where to store the value
  88406. * @param value defines the int number to store
  88407. */
  88408. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88409. /**
  88410. * Set the value of an uniform to a number (float)
  88411. * @param uniform defines the webGL uniform location where to store the value
  88412. * @param value defines the float number to store
  88413. */
  88414. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88415. /**
  88416. * Set the value of an uniform to a vec2
  88417. * @param uniform defines the webGL uniform location where to store the value
  88418. * @param x defines the 1st component of the value
  88419. * @param y defines the 2nd component of the value
  88420. */
  88421. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88422. /**
  88423. * Set the value of an uniform to a vec3
  88424. * @param uniform defines the webGL uniform location where to store the value
  88425. * @param x defines the 1st component of the value
  88426. * @param y defines the 2nd component of the value
  88427. * @param z defines the 3rd component of the value
  88428. */
  88429. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88430. /**
  88431. * Set the value of an uniform to a boolean
  88432. * @param uniform defines the webGL uniform location where to store the value
  88433. * @param bool defines the boolean to store
  88434. */
  88435. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88436. /**
  88437. * Set the value of an uniform to a vec4
  88438. * @param uniform defines the webGL uniform location where to store the value
  88439. * @param x defines the 1st component of the value
  88440. * @param y defines the 2nd component of the value
  88441. * @param z defines the 3rd component of the value
  88442. * @param w defines the 4th component of the value
  88443. */
  88444. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88445. /**
  88446. * Set the value of an uniform to a Color3
  88447. * @param uniform defines the webGL uniform location where to store the value
  88448. * @param color3 defines the color to store
  88449. */
  88450. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88451. /**
  88452. * Set the value of an uniform to a Color3 and an alpha value
  88453. * @param uniform defines the webGL uniform location where to store the value
  88454. * @param color3 defines the color to store
  88455. * @param alpha defines the alpha component to store
  88456. */
  88457. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88458. /**
  88459. * Sets a Color4 on a uniform variable
  88460. * @param uniform defines the uniform location
  88461. * @param color4 defines the value to be set
  88462. */
  88463. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88464. /**
  88465. * Set various states to the webGL context
  88466. * @param culling defines backface culling state
  88467. * @param zOffset defines the value to apply to zOffset (0 by default)
  88468. * @param force defines if states must be applied even if cache is up to date
  88469. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88470. */
  88471. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88472. /**
  88473. * Set the z offset to apply to current rendering
  88474. * @param value defines the offset to apply
  88475. */
  88476. setZOffset(value: number): void;
  88477. /**
  88478. * Gets the current value of the zOffset
  88479. * @returns the current zOffset state
  88480. */
  88481. getZOffset(): number;
  88482. /**
  88483. * Enable or disable depth buffering
  88484. * @param enable defines the state to set
  88485. */
  88486. setDepthBuffer(enable: boolean): void;
  88487. /**
  88488. * Gets a boolean indicating if depth writing is enabled
  88489. * @returns the current depth writing state
  88490. */
  88491. getDepthWrite(): boolean;
  88492. /**
  88493. * Enable or disable depth writing
  88494. * @param enable defines the state to set
  88495. */
  88496. setDepthWrite(enable: boolean): void;
  88497. /**
  88498. * Enable or disable color writing
  88499. * @param enable defines the state to set
  88500. */
  88501. setColorWrite(enable: boolean): void;
  88502. /**
  88503. * Gets a boolean indicating if color writing is enabled
  88504. * @returns the current color writing state
  88505. */
  88506. getColorWrite(): boolean;
  88507. /**
  88508. * Sets alpha constants used by some alpha blending modes
  88509. * @param r defines the red component
  88510. * @param g defines the green component
  88511. * @param b defines the blue component
  88512. * @param a defines the alpha component
  88513. */
  88514. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88515. /**
  88516. * Sets the current alpha mode
  88517. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88518. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88519. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88520. */
  88521. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88522. /**
  88523. * Gets the current alpha mode
  88524. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88525. * @returns the current alpha mode
  88526. */
  88527. getAlphaMode(): number;
  88528. /**
  88529. * Clears the list of texture accessible through engine.
  88530. * This can help preventing texture load conflict due to name collision.
  88531. */
  88532. clearInternalTexturesCache(): void;
  88533. /**
  88534. * Force the entire cache to be cleared
  88535. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88536. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88537. */
  88538. wipeCaches(bruteForce?: boolean): void;
  88539. /**
  88540. * Set the compressed texture format to use, based on the formats you have, and the formats
  88541. * supported by the hardware / browser.
  88542. *
  88543. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88544. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88545. * to API arguments needed to compressed textures. This puts the burden on the container
  88546. * generator to house the arcane code for determining these for current & future formats.
  88547. *
  88548. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88549. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88550. *
  88551. * Note: The result of this call is not taken into account when a texture is base64.
  88552. *
  88553. * @param formatsAvailable defines the list of those format families you have created
  88554. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88555. *
  88556. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88557. * @returns The extension selected.
  88558. */
  88559. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88560. /** @hidden */
  88561. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88562. min: number;
  88563. mag: number;
  88564. };
  88565. /** @hidden */
  88566. _createTexture(): WebGLTexture;
  88567. /**
  88568. * Usually called from Texture.ts.
  88569. * Passed information to create a WebGLTexture
  88570. * @param urlArg defines a value which contains one of the following:
  88571. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88572. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88573. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88575. * @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)
  88576. * @param scene needed for loading to the correct scene
  88577. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88578. * @param onLoad optional callback to be called upon successful completion
  88579. * @param onError optional callback to be called upon failure
  88580. * @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
  88581. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88582. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88583. * @param forcedExtension defines the extension to use to pick the right loader
  88584. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88585. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88586. */
  88587. 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;
  88588. private _rescaleTexture;
  88589. private _unpackFlipYCached;
  88590. /**
  88591. * In case you are sharing the context with other applications, it might
  88592. * be interested to not cache the unpack flip y state to ensure a consistent
  88593. * value would be set.
  88594. */
  88595. enableUnpackFlipYCached: boolean;
  88596. /** @hidden */
  88597. _unpackFlipY(value: boolean): void;
  88598. /** @hidden */
  88599. _getUnpackAlignement(): number;
  88600. /**
  88601. * Creates a dynamic texture
  88602. * @param width defines the width of the texture
  88603. * @param height defines the height of the texture
  88604. * @param generateMipMaps defines if the engine should generate the mip levels
  88605. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88606. * @returns the dynamic texture inside an InternalTexture
  88607. */
  88608. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88609. /**
  88610. * Update the sampling mode of a given texture
  88611. * @param samplingMode defines the required sampling mode
  88612. * @param texture defines the texture to update
  88613. */
  88614. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88615. /**
  88616. * Update the content of a dynamic texture
  88617. * @param texture defines the texture to update
  88618. * @param canvas defines the canvas containing the source
  88619. * @param invertY defines if data must be stored with Y axis inverted
  88620. * @param premulAlpha defines if alpha is stored as premultiplied
  88621. * @param format defines the format of the data
  88622. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88623. */
  88624. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88625. /**
  88626. * Update a video texture
  88627. * @param texture defines the texture to update
  88628. * @param video defines the video element to use
  88629. * @param invertY defines if data must be stored with Y axis inverted
  88630. */
  88631. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88632. /**
  88633. * Updates a depth texture Comparison Mode and Function.
  88634. * If the comparison Function is equal to 0, the mode will be set to none.
  88635. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88636. * @param texture The texture to set the comparison function for
  88637. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88638. */
  88639. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88640. /** @hidden */
  88641. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88642. width: number;
  88643. height: number;
  88644. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88645. /**
  88646. * Creates a depth stencil texture.
  88647. * This is only available in WebGL 2 or with the depth texture extension available.
  88648. * @param size The size of face edge in the texture.
  88649. * @param options The options defining the texture.
  88650. * @returns The texture
  88651. */
  88652. createDepthStencilTexture(size: number | {
  88653. width: number;
  88654. height: number;
  88655. }, options: DepthTextureCreationOptions): InternalTexture;
  88656. /**
  88657. * Creates a depth stencil texture.
  88658. * This is only available in WebGL 2 or with the depth texture extension available.
  88659. * @param size The size of face edge in the texture.
  88660. * @param options The options defining the texture.
  88661. * @returns The texture
  88662. */
  88663. private _createDepthStencilTexture;
  88664. /**
  88665. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88666. * @param renderTarget The render target to set the frame buffer for
  88667. */
  88668. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88669. /**
  88670. * Creates a new render target texture
  88671. * @param size defines the size of the texture
  88672. * @param options defines the options used to create the texture
  88673. * @returns a new render target texture stored in an InternalTexture
  88674. */
  88675. createRenderTargetTexture(size: number | {
  88676. width: number;
  88677. height: number;
  88678. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88679. /** @hidden */
  88680. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88681. /**
  88682. * Updates the sample count of a render target texture
  88683. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88684. * @param texture defines the texture to update
  88685. * @param samples defines the sample count to set
  88686. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88687. */
  88688. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88689. /** @hidden */
  88690. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88691. /** @hidden */
  88692. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88693. /** @hidden */
  88694. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88695. /** @hidden */
  88696. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88697. /**
  88698. * @hidden
  88699. */
  88700. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88701. private _prepareWebGLTextureContinuation;
  88702. private _prepareWebGLTexture;
  88703. /** @hidden */
  88704. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88705. /** @hidden */
  88706. _releaseFramebufferObjects(texture: InternalTexture): void;
  88707. /** @hidden */
  88708. _releaseTexture(texture: InternalTexture): void;
  88709. private setProgram;
  88710. private _boundUniforms;
  88711. /**
  88712. * Binds an effect to the webGL context
  88713. * @param effect defines the effect to bind
  88714. */
  88715. bindSamplers(effect: Effect): void;
  88716. private _activateCurrentTexture;
  88717. /** @hidden */
  88718. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88719. /** @hidden */
  88720. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88721. /**
  88722. * Sets a texture to the webGL context from a postprocess
  88723. * @param channel defines the channel to use
  88724. * @param postProcess defines the source postprocess
  88725. */
  88726. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88727. /**
  88728. * Binds the output of the passed in post process to the texture channel specified
  88729. * @param channel The channel the texture should be bound to
  88730. * @param postProcess The post process which's output should be bound
  88731. */
  88732. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88733. /**
  88734. * Unbind all textures from the webGL context
  88735. */
  88736. unbindAllTextures(): void;
  88737. /**
  88738. * Sets a texture to the according uniform.
  88739. * @param channel The texture channel
  88740. * @param uniform The uniform to set
  88741. * @param texture The texture to apply
  88742. */
  88743. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88744. /**
  88745. * Sets a depth stencil texture from a render target to the according uniform.
  88746. * @param channel The texture channel
  88747. * @param uniform The uniform to set
  88748. * @param texture The render target texture containing the depth stencil texture to apply
  88749. */
  88750. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88751. private _bindSamplerUniformToChannel;
  88752. private _getTextureWrapMode;
  88753. private _setTexture;
  88754. /**
  88755. * Sets an array of texture to the webGL context
  88756. * @param channel defines the channel where the texture array must be set
  88757. * @param uniform defines the associated uniform location
  88758. * @param textures defines the array of textures to bind
  88759. */
  88760. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88761. /** @hidden */
  88762. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88763. private _setTextureParameterFloat;
  88764. private _setTextureParameterInteger;
  88765. /**
  88766. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88767. * @param x defines the x coordinate of the rectangle where pixels must be read
  88768. * @param y defines the y coordinate of the rectangle where pixels must be read
  88769. * @param width defines the width of the rectangle where pixels must be read
  88770. * @param height defines the height of the rectangle where pixels must be read
  88771. * @returns a Uint8Array containing RGBA colors
  88772. */
  88773. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88774. /**
  88775. * Add an externaly attached data from its key.
  88776. * This method call will fail and return false, if such key already exists.
  88777. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88778. * @param key the unique key that identifies the data
  88779. * @param data the data object to associate to the key for this Engine instance
  88780. * @return true if no such key were already present and the data was added successfully, false otherwise
  88781. */
  88782. addExternalData<T>(key: string, data: T): boolean;
  88783. /**
  88784. * Get an externaly attached data from its key
  88785. * @param key the unique key that identifies the data
  88786. * @return the associated data, if present (can be null), or undefined if not present
  88787. */
  88788. getExternalData<T>(key: string): T;
  88789. /**
  88790. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88791. * @param key the unique key that identifies the data
  88792. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88793. * @return the associated data, can be null if the factory returned null.
  88794. */
  88795. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88796. /**
  88797. * Remove an externaly attached data from the Engine instance
  88798. * @param key the unique key that identifies the data
  88799. * @return true if the data was successfully removed, false if it doesn't exist
  88800. */
  88801. removeExternalData(key: string): boolean;
  88802. /**
  88803. * Unbind all vertex attributes from the webGL context
  88804. */
  88805. unbindAllAttributes(): void;
  88806. /**
  88807. * 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
  88808. */
  88809. releaseEffects(): void;
  88810. /**
  88811. * Dispose and release all associated resources
  88812. */
  88813. dispose(): void;
  88814. /**
  88815. * Display the loading screen
  88816. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88817. */
  88818. displayLoadingUI(): void;
  88819. /**
  88820. * Hide the loading screen
  88821. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88822. */
  88823. hideLoadingUI(): void;
  88824. /**
  88825. * Gets the current loading screen object
  88826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88827. */
  88828. /**
  88829. * Sets the current loading screen object
  88830. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88831. */
  88832. loadingScreen: ILoadingScreen;
  88833. /**
  88834. * Sets the current loading screen text
  88835. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88836. */
  88837. loadingUIText: string;
  88838. /**
  88839. * Sets the current loading screen background color
  88840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88841. */
  88842. loadingUIBackgroundColor: string;
  88843. /**
  88844. * Attach a new callback raised when context lost event is fired
  88845. * @param callback defines the callback to call
  88846. */
  88847. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88848. /**
  88849. * Attach a new callback raised when context restored event is fired
  88850. * @param callback defines the callback to call
  88851. */
  88852. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88853. /**
  88854. * Gets the source code of the vertex shader associated with a specific webGL program
  88855. * @param program defines the program to use
  88856. * @returns a string containing the source code of the vertex shader associated with the program
  88857. */
  88858. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88859. /**
  88860. * Gets the source code of the fragment shader associated with a specific webGL program
  88861. * @param program defines the program to use
  88862. * @returns a string containing the source code of the fragment shader associated with the program
  88863. */
  88864. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88865. /**
  88866. * Get the current error code of the webGL context
  88867. * @returns the error code
  88868. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88869. */
  88870. getError(): number;
  88871. /**
  88872. * Gets the current framerate
  88873. * @returns a number representing the framerate
  88874. */
  88875. getFps(): number;
  88876. /**
  88877. * Gets the time spent between current and previous frame
  88878. * @returns a number representing the delta time in ms
  88879. */
  88880. getDeltaTime(): number;
  88881. private _measureFps;
  88882. /** @hidden */
  88883. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88884. private _canRenderToFloatFramebuffer;
  88885. private _canRenderToHalfFloatFramebuffer;
  88886. private _canRenderToFramebuffer;
  88887. /** @hidden */
  88888. _getWebGLTextureType(type: number): number;
  88889. /** @hidden */
  88890. _getInternalFormat(format: number): number;
  88891. /** @hidden */
  88892. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88893. /** @hidden */
  88894. _getRGBAMultiSampleBufferFormat(type: number): number;
  88895. /** @hidden */
  88896. _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;
  88897. /** @hidden */
  88898. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88899. /**
  88900. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88901. * @returns true if the engine can be created
  88902. * @ignorenaming
  88903. */
  88904. static isSupported(): boolean;
  88905. }
  88906. }
  88907. declare module BABYLON {
  88908. /**
  88909. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88910. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88911. */
  88912. export class EffectFallbacks {
  88913. private _defines;
  88914. private _currentRank;
  88915. private _maxRank;
  88916. private _mesh;
  88917. /**
  88918. * Removes the fallback from the bound mesh.
  88919. */
  88920. unBindMesh(): void;
  88921. /**
  88922. * Adds a fallback on the specified property.
  88923. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88924. * @param define The name of the define in the shader
  88925. */
  88926. addFallback(rank: number, define: string): void;
  88927. /**
  88928. * Sets the mesh to use CPU skinning when needing to fallback.
  88929. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88930. * @param mesh The mesh to use the fallbacks.
  88931. */
  88932. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88933. /**
  88934. * Checks to see if more fallbacks are still availible.
  88935. */
  88936. readonly isMoreFallbacks: boolean;
  88937. /**
  88938. * Removes the defines that shoould be removed when falling back.
  88939. * @param currentDefines defines the current define statements for the shader.
  88940. * @param effect defines the current effect we try to compile
  88941. * @returns The resulting defines with defines of the current rank removed.
  88942. */
  88943. reduce(currentDefines: string, effect: Effect): string;
  88944. }
  88945. /**
  88946. * Options to be used when creating an effect.
  88947. */
  88948. export class EffectCreationOptions {
  88949. /**
  88950. * Atrributes that will be used in the shader.
  88951. */
  88952. attributes: string[];
  88953. /**
  88954. * Uniform varible names that will be set in the shader.
  88955. */
  88956. uniformsNames: string[];
  88957. /**
  88958. * Uniform buffer varible names that will be set in the shader.
  88959. */
  88960. uniformBuffersNames: string[];
  88961. /**
  88962. * Sampler texture variable names that will be set in the shader.
  88963. */
  88964. samplers: string[];
  88965. /**
  88966. * Define statements that will be set in the shader.
  88967. */
  88968. defines: any;
  88969. /**
  88970. * Possible fallbacks for this effect to improve performance when needed.
  88971. */
  88972. fallbacks: Nullable<EffectFallbacks>;
  88973. /**
  88974. * Callback that will be called when the shader is compiled.
  88975. */
  88976. onCompiled: Nullable<(effect: Effect) => void>;
  88977. /**
  88978. * Callback that will be called if an error occurs during shader compilation.
  88979. */
  88980. onError: Nullable<(effect: Effect, errors: string) => void>;
  88981. /**
  88982. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88983. */
  88984. indexParameters: any;
  88985. /**
  88986. * Max number of lights that can be used in the shader.
  88987. */
  88988. maxSimultaneousLights: number;
  88989. /**
  88990. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88991. */
  88992. transformFeedbackVaryings: Nullable<string[]>;
  88993. }
  88994. /**
  88995. * Effect containing vertex and fragment shader that can be executed on an object.
  88996. */
  88997. export class Effect implements IDisposable {
  88998. /**
  88999. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  89000. */
  89001. static ShadersRepository: string;
  89002. /**
  89003. * Name of the effect.
  89004. */
  89005. name: any;
  89006. /**
  89007. * String container all the define statements that should be set on the shader.
  89008. */
  89009. defines: string;
  89010. /**
  89011. * Callback that will be called when the shader is compiled.
  89012. */
  89013. onCompiled: Nullable<(effect: Effect) => void>;
  89014. /**
  89015. * Callback that will be called if an error occurs during shader compilation.
  89016. */
  89017. onError: Nullable<(effect: Effect, errors: string) => void>;
  89018. /**
  89019. * Callback that will be called when effect is bound.
  89020. */
  89021. onBind: Nullable<(effect: Effect) => void>;
  89022. /**
  89023. * Unique ID of the effect.
  89024. */
  89025. uniqueId: number;
  89026. /**
  89027. * Observable that will be called when the shader is compiled.
  89028. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89029. */
  89030. onCompileObservable: Observable<Effect>;
  89031. /**
  89032. * Observable that will be called if an error occurs during shader compilation.
  89033. */
  89034. onErrorObservable: Observable<Effect>;
  89035. /** @hidden */
  89036. _onBindObservable: Nullable<Observable<Effect>>;
  89037. /**
  89038. * Observable that will be called when effect is bound.
  89039. */
  89040. readonly onBindObservable: Observable<Effect>;
  89041. /** @hidden */
  89042. _bonesComputationForcedToCPU: boolean;
  89043. private static _uniqueIdSeed;
  89044. private _engine;
  89045. private _uniformBuffersNames;
  89046. private _uniformsNames;
  89047. private _samplerList;
  89048. private _samplers;
  89049. private _isReady;
  89050. private _compilationError;
  89051. private _attributesNames;
  89052. private _attributes;
  89053. private _uniforms;
  89054. /**
  89055. * Key for the effect.
  89056. * @hidden
  89057. */
  89058. _key: string;
  89059. private _indexParameters;
  89060. private _fallbacks;
  89061. private _vertexSourceCode;
  89062. private _fragmentSourceCode;
  89063. private _vertexSourceCodeOverride;
  89064. private _fragmentSourceCodeOverride;
  89065. private _transformFeedbackVaryings;
  89066. /**
  89067. * Compiled shader to webGL program.
  89068. * @hidden
  89069. */
  89070. _pipelineContext: Nullable<IPipelineContext>;
  89071. private _valueCache;
  89072. private static _baseCache;
  89073. /**
  89074. * Instantiates an effect.
  89075. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89076. * @param baseName Name of the effect.
  89077. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89078. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89079. * @param samplers List of sampler variables that will be passed to the shader.
  89080. * @param engine Engine to be used to render the effect
  89081. * @param defines Define statements to be added to the shader.
  89082. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89083. * @param onCompiled Callback that will be called when the shader is compiled.
  89084. * @param onError Callback that will be called if an error occurs during shader compilation.
  89085. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89086. */
  89087. 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);
  89088. /**
  89089. * Unique key for this effect
  89090. */
  89091. readonly key: string;
  89092. /**
  89093. * If the effect has been compiled and prepared.
  89094. * @returns if the effect is compiled and prepared.
  89095. */
  89096. isReady(): boolean;
  89097. /**
  89098. * The engine the effect was initialized with.
  89099. * @returns the engine.
  89100. */
  89101. getEngine(): Engine;
  89102. /**
  89103. * The pipeline context for this effect
  89104. * @returns the associated pipeline context
  89105. */
  89106. getPipelineContext(): Nullable<IPipelineContext>;
  89107. /**
  89108. * The set of names of attribute variables for the shader.
  89109. * @returns An array of attribute names.
  89110. */
  89111. getAttributesNames(): string[];
  89112. /**
  89113. * Returns the attribute at the given index.
  89114. * @param index The index of the attribute.
  89115. * @returns The location of the attribute.
  89116. */
  89117. getAttributeLocation(index: number): number;
  89118. /**
  89119. * Returns the attribute based on the name of the variable.
  89120. * @param name of the attribute to look up.
  89121. * @returns the attribute location.
  89122. */
  89123. getAttributeLocationByName(name: string): number;
  89124. /**
  89125. * The number of attributes.
  89126. * @returns the numnber of attributes.
  89127. */
  89128. getAttributesCount(): number;
  89129. /**
  89130. * Gets the index of a uniform variable.
  89131. * @param uniformName of the uniform to look up.
  89132. * @returns the index.
  89133. */
  89134. getUniformIndex(uniformName: string): number;
  89135. /**
  89136. * Returns the attribute based on the name of the variable.
  89137. * @param uniformName of the uniform to look up.
  89138. * @returns the location of the uniform.
  89139. */
  89140. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89141. /**
  89142. * Returns an array of sampler variable names
  89143. * @returns The array of sampler variable neames.
  89144. */
  89145. getSamplers(): string[];
  89146. /**
  89147. * The error from the last compilation.
  89148. * @returns the error string.
  89149. */
  89150. getCompilationError(): string;
  89151. /**
  89152. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89153. * @param func The callback to be used.
  89154. */
  89155. executeWhenCompiled(func: (effect: Effect) => void): void;
  89156. private _checkIsReady;
  89157. /** @hidden */
  89158. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89159. /** @hidden */
  89160. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89161. /** @hidden */
  89162. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89163. private _processShaderConversion;
  89164. private _processIncludes;
  89165. private _processPrecision;
  89166. /**
  89167. * Recompiles the webGL program
  89168. * @param vertexSourceCode The source code for the vertex shader.
  89169. * @param fragmentSourceCode The source code for the fragment shader.
  89170. * @param onCompiled Callback called when completed.
  89171. * @param onError Callback called on error.
  89172. * @hidden
  89173. */
  89174. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89175. /**
  89176. * Prepares the effect
  89177. * @hidden
  89178. */
  89179. _prepareEffect(): void;
  89180. /**
  89181. * Checks if the effect is supported. (Must be called after compilation)
  89182. */
  89183. readonly isSupported: boolean;
  89184. /**
  89185. * Binds a texture to the engine to be used as output of the shader.
  89186. * @param channel Name of the output variable.
  89187. * @param texture Texture to bind.
  89188. * @hidden
  89189. */
  89190. _bindTexture(channel: string, texture: InternalTexture): void;
  89191. /**
  89192. * Sets a texture on the engine to be used in the shader.
  89193. * @param channel Name of the sampler variable.
  89194. * @param texture Texture to set.
  89195. */
  89196. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89197. /**
  89198. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89199. * @param channel Name of the sampler variable.
  89200. * @param texture Texture to set.
  89201. */
  89202. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89203. /**
  89204. * Sets an array of textures on the engine to be used in the shader.
  89205. * @param channel Name of the variable.
  89206. * @param textures Textures to set.
  89207. */
  89208. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89209. /**
  89210. * 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)
  89211. * @param channel Name of the sampler variable.
  89212. * @param postProcess Post process to get the input texture from.
  89213. */
  89214. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89215. /**
  89216. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89217. * 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)
  89218. * @param channel Name of the sampler variable.
  89219. * @param postProcess Post process to get the output texture from.
  89220. */
  89221. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89222. /** @hidden */
  89223. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89224. /** @hidden */
  89225. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89226. /** @hidden */
  89227. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89228. /** @hidden */
  89229. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89230. /**
  89231. * Binds a buffer to a uniform.
  89232. * @param buffer Buffer to bind.
  89233. * @param name Name of the uniform variable to bind to.
  89234. */
  89235. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89236. /**
  89237. * Binds block to a uniform.
  89238. * @param blockName Name of the block to bind.
  89239. * @param index Index to bind.
  89240. */
  89241. bindUniformBlock(blockName: string, index: number): void;
  89242. /**
  89243. * Sets an interger value on a uniform variable.
  89244. * @param uniformName Name of the variable.
  89245. * @param value Value to be set.
  89246. * @returns this effect.
  89247. */
  89248. setInt(uniformName: string, value: number): Effect;
  89249. /**
  89250. * Sets an int array on a uniform variable.
  89251. * @param uniformName Name of the variable.
  89252. * @param array array to be set.
  89253. * @returns this effect.
  89254. */
  89255. setIntArray(uniformName: string, array: Int32Array): Effect;
  89256. /**
  89257. * 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)
  89258. * @param uniformName Name of the variable.
  89259. * @param array array to be set.
  89260. * @returns this effect.
  89261. */
  89262. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89263. /**
  89264. * 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)
  89265. * @param uniformName Name of the variable.
  89266. * @param array array to be set.
  89267. * @returns this effect.
  89268. */
  89269. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89270. /**
  89271. * 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)
  89272. * @param uniformName Name of the variable.
  89273. * @param array array to be set.
  89274. * @returns this effect.
  89275. */
  89276. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89277. /**
  89278. * Sets an float array on a uniform variable.
  89279. * @param uniformName Name of the variable.
  89280. * @param array array to be set.
  89281. * @returns this effect.
  89282. */
  89283. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89284. /**
  89285. * 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)
  89286. * @param uniformName Name of the variable.
  89287. * @param array array to be set.
  89288. * @returns this effect.
  89289. */
  89290. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89291. /**
  89292. * 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)
  89293. * @param uniformName Name of the variable.
  89294. * @param array array to be set.
  89295. * @returns this effect.
  89296. */
  89297. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89298. /**
  89299. * 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)
  89300. * @param uniformName Name of the variable.
  89301. * @param array array to be set.
  89302. * @returns this effect.
  89303. */
  89304. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89305. /**
  89306. * Sets an array on a uniform variable.
  89307. * @param uniformName Name of the variable.
  89308. * @param array array to be set.
  89309. * @returns this effect.
  89310. */
  89311. setArray(uniformName: string, array: number[]): Effect;
  89312. /**
  89313. * 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)
  89314. * @param uniformName Name of the variable.
  89315. * @param array array to be set.
  89316. * @returns this effect.
  89317. */
  89318. setArray2(uniformName: string, array: number[]): Effect;
  89319. /**
  89320. * 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)
  89321. * @param uniformName Name of the variable.
  89322. * @param array array to be set.
  89323. * @returns this effect.
  89324. */
  89325. setArray3(uniformName: string, array: number[]): Effect;
  89326. /**
  89327. * 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)
  89328. * @param uniformName Name of the variable.
  89329. * @param array array to be set.
  89330. * @returns this effect.
  89331. */
  89332. setArray4(uniformName: string, array: number[]): Effect;
  89333. /**
  89334. * Sets matrices on a uniform variable.
  89335. * @param uniformName Name of the variable.
  89336. * @param matrices matrices to be set.
  89337. * @returns this effect.
  89338. */
  89339. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89340. /**
  89341. * Sets matrix on a uniform variable.
  89342. * @param uniformName Name of the variable.
  89343. * @param matrix matrix to be set.
  89344. * @returns this effect.
  89345. */
  89346. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89347. /**
  89348. * 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)
  89349. * @param uniformName Name of the variable.
  89350. * @param matrix matrix to be set.
  89351. * @returns this effect.
  89352. */
  89353. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89354. /**
  89355. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89356. * @param uniformName Name of the variable.
  89357. * @param matrix matrix to be set.
  89358. * @returns this effect.
  89359. */
  89360. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89361. /**
  89362. * Sets a float on a uniform variable.
  89363. * @param uniformName Name of the variable.
  89364. * @param value value to be set.
  89365. * @returns this effect.
  89366. */
  89367. setFloat(uniformName: string, value: number): Effect;
  89368. /**
  89369. * Sets a boolean on a uniform variable.
  89370. * @param uniformName Name of the variable.
  89371. * @param bool value to be set.
  89372. * @returns this effect.
  89373. */
  89374. setBool(uniformName: string, bool: boolean): Effect;
  89375. /**
  89376. * Sets a Vector2 on a uniform variable.
  89377. * @param uniformName Name of the variable.
  89378. * @param vector2 vector2 to be set.
  89379. * @returns this effect.
  89380. */
  89381. setVector2(uniformName: string, vector2: Vector2): Effect;
  89382. /**
  89383. * Sets a float2 on a uniform variable.
  89384. * @param uniformName Name of the variable.
  89385. * @param x First float in float2.
  89386. * @param y Second float in float2.
  89387. * @returns this effect.
  89388. */
  89389. setFloat2(uniformName: string, x: number, y: number): Effect;
  89390. /**
  89391. * Sets a Vector3 on a uniform variable.
  89392. * @param uniformName Name of the variable.
  89393. * @param vector3 Value to be set.
  89394. * @returns this effect.
  89395. */
  89396. setVector3(uniformName: string, vector3: Vector3): Effect;
  89397. /**
  89398. * Sets a float3 on a uniform variable.
  89399. * @param uniformName Name of the variable.
  89400. * @param x First float in float3.
  89401. * @param y Second float in float3.
  89402. * @param z Third float in float3.
  89403. * @returns this effect.
  89404. */
  89405. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89406. /**
  89407. * Sets a Vector4 on a uniform variable.
  89408. * @param uniformName Name of the variable.
  89409. * @param vector4 Value to be set.
  89410. * @returns this effect.
  89411. */
  89412. setVector4(uniformName: string, vector4: Vector4): Effect;
  89413. /**
  89414. * Sets a float4 on a uniform variable.
  89415. * @param uniformName Name of the variable.
  89416. * @param x First float in float4.
  89417. * @param y Second float in float4.
  89418. * @param z Third float in float4.
  89419. * @param w Fourth float in float4.
  89420. * @returns this effect.
  89421. */
  89422. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89423. /**
  89424. * Sets a Color3 on a uniform variable.
  89425. * @param uniformName Name of the variable.
  89426. * @param color3 Value to be set.
  89427. * @returns this effect.
  89428. */
  89429. setColor3(uniformName: string, color3: Color3): Effect;
  89430. /**
  89431. * Sets a Color4 on a uniform variable.
  89432. * @param uniformName Name of the variable.
  89433. * @param color3 Value to be set.
  89434. * @param alpha Alpha value to be set.
  89435. * @returns this effect.
  89436. */
  89437. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89438. /**
  89439. * Sets a Color4 on a uniform variable
  89440. * @param uniformName defines the name of the variable
  89441. * @param color4 defines the value to be set
  89442. * @returns this effect.
  89443. */
  89444. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89445. /** Release all associated resources */
  89446. dispose(): void;
  89447. /**
  89448. * This function will add a new shader to the shader store
  89449. * @param name the name of the shader
  89450. * @param pixelShader optional pixel shader content
  89451. * @param vertexShader optional vertex shader content
  89452. */
  89453. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89454. /**
  89455. * Store of each shader (The can be looked up using effect.key)
  89456. */
  89457. static ShadersStore: {
  89458. [key: string]: string;
  89459. };
  89460. /**
  89461. * Store of each included file for a shader (The can be looked up using effect.key)
  89462. */
  89463. static IncludesShadersStore: {
  89464. [key: string]: string;
  89465. };
  89466. /**
  89467. * Resets the cache of effects.
  89468. */
  89469. static ResetCache(): void;
  89470. }
  89471. }
  89472. declare module BABYLON {
  89473. /**
  89474. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89475. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89476. * 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;
  89477. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89478. */
  89479. export class ColorCurves {
  89480. private _dirty;
  89481. private _tempColor;
  89482. private _globalCurve;
  89483. private _highlightsCurve;
  89484. private _midtonesCurve;
  89485. private _shadowsCurve;
  89486. private _positiveCurve;
  89487. private _negativeCurve;
  89488. private _globalHue;
  89489. private _globalDensity;
  89490. private _globalSaturation;
  89491. private _globalExposure;
  89492. /**
  89493. * Gets the global Hue value.
  89494. * 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).
  89495. */
  89496. /**
  89497. * Sets the global Hue value.
  89498. * 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).
  89499. */
  89500. globalHue: number;
  89501. /**
  89502. * Gets the global Density value.
  89503. * 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.
  89504. * Values less than zero provide a filter of opposite hue.
  89505. */
  89506. /**
  89507. * Sets the global Density value.
  89508. * 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.
  89509. * Values less than zero provide a filter of opposite hue.
  89510. */
  89511. globalDensity: number;
  89512. /**
  89513. * Gets the global Saturation value.
  89514. * 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.
  89515. */
  89516. /**
  89517. * Sets the global Saturation value.
  89518. * 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.
  89519. */
  89520. globalSaturation: number;
  89521. /**
  89522. * Gets the global Exposure value.
  89523. * 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.
  89524. */
  89525. /**
  89526. * Sets the global Exposure value.
  89527. * 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.
  89528. */
  89529. globalExposure: number;
  89530. private _highlightsHue;
  89531. private _highlightsDensity;
  89532. private _highlightsSaturation;
  89533. private _highlightsExposure;
  89534. /**
  89535. * Gets the highlights Hue value.
  89536. * 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).
  89537. */
  89538. /**
  89539. * Sets the highlights Hue value.
  89540. * 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).
  89541. */
  89542. highlightsHue: number;
  89543. /**
  89544. * Gets the highlights Density value.
  89545. * 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.
  89546. * Values less than zero provide a filter of opposite hue.
  89547. */
  89548. /**
  89549. * Sets the highlights Density value.
  89550. * 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.
  89551. * Values less than zero provide a filter of opposite hue.
  89552. */
  89553. highlightsDensity: number;
  89554. /**
  89555. * Gets the highlights Saturation value.
  89556. * 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.
  89557. */
  89558. /**
  89559. * Sets the highlights Saturation value.
  89560. * 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.
  89561. */
  89562. highlightsSaturation: number;
  89563. /**
  89564. * Gets the highlights Exposure value.
  89565. * 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.
  89566. */
  89567. /**
  89568. * Sets the highlights Exposure value.
  89569. * 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.
  89570. */
  89571. highlightsExposure: number;
  89572. private _midtonesHue;
  89573. private _midtonesDensity;
  89574. private _midtonesSaturation;
  89575. private _midtonesExposure;
  89576. /**
  89577. * Gets the midtones Hue value.
  89578. * 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).
  89579. */
  89580. /**
  89581. * Sets the midtones Hue value.
  89582. * 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).
  89583. */
  89584. midtonesHue: number;
  89585. /**
  89586. * Gets the midtones Density value.
  89587. * 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.
  89588. * Values less than zero provide a filter of opposite hue.
  89589. */
  89590. /**
  89591. * Sets the midtones Density value.
  89592. * 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.
  89593. * Values less than zero provide a filter of opposite hue.
  89594. */
  89595. midtonesDensity: number;
  89596. /**
  89597. * Gets the midtones Saturation value.
  89598. * 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.
  89599. */
  89600. /**
  89601. * Sets the midtones Saturation value.
  89602. * 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.
  89603. */
  89604. midtonesSaturation: number;
  89605. /**
  89606. * Gets the midtones Exposure value.
  89607. * 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.
  89608. */
  89609. /**
  89610. * Sets the midtones Exposure value.
  89611. * 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.
  89612. */
  89613. midtonesExposure: number;
  89614. private _shadowsHue;
  89615. private _shadowsDensity;
  89616. private _shadowsSaturation;
  89617. private _shadowsExposure;
  89618. /**
  89619. * Gets the shadows Hue value.
  89620. * 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).
  89621. */
  89622. /**
  89623. * Sets the shadows Hue value.
  89624. * 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).
  89625. */
  89626. shadowsHue: number;
  89627. /**
  89628. * Gets the shadows Density value.
  89629. * 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.
  89630. * Values less than zero provide a filter of opposite hue.
  89631. */
  89632. /**
  89633. * Sets the shadows Density value.
  89634. * 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.
  89635. * Values less than zero provide a filter of opposite hue.
  89636. */
  89637. shadowsDensity: number;
  89638. /**
  89639. * Gets the shadows Saturation value.
  89640. * 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.
  89641. */
  89642. /**
  89643. * Sets the shadows Saturation value.
  89644. * 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.
  89645. */
  89646. shadowsSaturation: number;
  89647. /**
  89648. * Gets the shadows Exposure value.
  89649. * 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.
  89650. */
  89651. /**
  89652. * Sets the shadows Exposure value.
  89653. * 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.
  89654. */
  89655. shadowsExposure: number;
  89656. /**
  89657. * Returns the class name
  89658. * @returns The class name
  89659. */
  89660. getClassName(): string;
  89661. /**
  89662. * Binds the color curves to the shader.
  89663. * @param colorCurves The color curve to bind
  89664. * @param effect The effect to bind to
  89665. * @param positiveUniform The positive uniform shader parameter
  89666. * @param neutralUniform The neutral uniform shader parameter
  89667. * @param negativeUniform The negative uniform shader parameter
  89668. */
  89669. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89670. /**
  89671. * Prepare the list of uniforms associated with the ColorCurves effects.
  89672. * @param uniformsList The list of uniforms used in the effect
  89673. */
  89674. static PrepareUniforms(uniformsList: string[]): void;
  89675. /**
  89676. * Returns color grading data based on a hue, density, saturation and exposure value.
  89677. * @param filterHue The hue of the color filter.
  89678. * @param filterDensity The density of the color filter.
  89679. * @param saturation The saturation.
  89680. * @param exposure The exposure.
  89681. * @param result The result data container.
  89682. */
  89683. private getColorGradingDataToRef;
  89684. /**
  89685. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89686. * @param value The input slider value in range [-100,100].
  89687. * @returns Adjusted value.
  89688. */
  89689. private static applyColorGradingSliderNonlinear;
  89690. /**
  89691. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89692. * @param hue The hue (H) input.
  89693. * @param saturation The saturation (S) input.
  89694. * @param brightness The brightness (B) input.
  89695. * @result An RGBA color represented as Vector4.
  89696. */
  89697. private static fromHSBToRef;
  89698. /**
  89699. * Returns a value clamped between min and max
  89700. * @param value The value to clamp
  89701. * @param min The minimum of value
  89702. * @param max The maximum of value
  89703. * @returns The clamped value.
  89704. */
  89705. private static clamp;
  89706. /**
  89707. * Clones the current color curve instance.
  89708. * @return The cloned curves
  89709. */
  89710. clone(): ColorCurves;
  89711. /**
  89712. * Serializes the current color curve instance to a json representation.
  89713. * @return a JSON representation
  89714. */
  89715. serialize(): any;
  89716. /**
  89717. * Parses the color curve from a json representation.
  89718. * @param source the JSON source to parse
  89719. * @return The parsed curves
  89720. */
  89721. static Parse(source: any): ColorCurves;
  89722. }
  89723. }
  89724. declare module BABYLON {
  89725. /**
  89726. * Interface to follow in your material defines to integrate easily the
  89727. * Image proccessing functions.
  89728. * @hidden
  89729. */
  89730. export interface IImageProcessingConfigurationDefines {
  89731. IMAGEPROCESSING: boolean;
  89732. VIGNETTE: boolean;
  89733. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89734. VIGNETTEBLENDMODEOPAQUE: boolean;
  89735. TONEMAPPING: boolean;
  89736. TONEMAPPING_ACES: boolean;
  89737. CONTRAST: boolean;
  89738. EXPOSURE: boolean;
  89739. COLORCURVES: boolean;
  89740. COLORGRADING: boolean;
  89741. COLORGRADING3D: boolean;
  89742. SAMPLER3DGREENDEPTH: boolean;
  89743. SAMPLER3DBGRMAP: boolean;
  89744. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89745. }
  89746. /**
  89747. * @hidden
  89748. */
  89749. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89750. IMAGEPROCESSING: boolean;
  89751. VIGNETTE: boolean;
  89752. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89753. VIGNETTEBLENDMODEOPAQUE: boolean;
  89754. TONEMAPPING: boolean;
  89755. TONEMAPPING_ACES: boolean;
  89756. CONTRAST: boolean;
  89757. COLORCURVES: boolean;
  89758. COLORGRADING: boolean;
  89759. COLORGRADING3D: boolean;
  89760. SAMPLER3DGREENDEPTH: boolean;
  89761. SAMPLER3DBGRMAP: boolean;
  89762. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89763. EXPOSURE: boolean;
  89764. constructor();
  89765. }
  89766. /**
  89767. * This groups together the common properties used for image processing either in direct forward pass
  89768. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89769. * or not.
  89770. */
  89771. export class ImageProcessingConfiguration {
  89772. /**
  89773. * Default tone mapping applied in BabylonJS.
  89774. */
  89775. static readonly TONEMAPPING_STANDARD: number;
  89776. /**
  89777. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89778. * to other engines rendering to increase portability.
  89779. */
  89780. static readonly TONEMAPPING_ACES: number;
  89781. /**
  89782. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89783. */
  89784. colorCurves: Nullable<ColorCurves>;
  89785. private _colorCurvesEnabled;
  89786. /**
  89787. * Gets wether the color curves effect is enabled.
  89788. */
  89789. /**
  89790. * Sets wether the color curves effect is enabled.
  89791. */
  89792. colorCurvesEnabled: boolean;
  89793. private _colorGradingTexture;
  89794. /**
  89795. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89796. */
  89797. /**
  89798. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89799. */
  89800. colorGradingTexture: Nullable<BaseTexture>;
  89801. private _colorGradingEnabled;
  89802. /**
  89803. * Gets wether the color grading effect is enabled.
  89804. */
  89805. /**
  89806. * Sets wether the color grading effect is enabled.
  89807. */
  89808. colorGradingEnabled: boolean;
  89809. private _colorGradingWithGreenDepth;
  89810. /**
  89811. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89812. */
  89813. /**
  89814. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89815. */
  89816. colorGradingWithGreenDepth: boolean;
  89817. private _colorGradingBGR;
  89818. /**
  89819. * Gets wether the color grading texture contains BGR values.
  89820. */
  89821. /**
  89822. * Sets wether the color grading texture contains BGR values.
  89823. */
  89824. colorGradingBGR: boolean;
  89825. /** @hidden */
  89826. _exposure: number;
  89827. /**
  89828. * Gets the Exposure used in the effect.
  89829. */
  89830. /**
  89831. * Sets the Exposure used in the effect.
  89832. */
  89833. exposure: number;
  89834. private _toneMappingEnabled;
  89835. /**
  89836. * Gets wether the tone mapping effect is enabled.
  89837. */
  89838. /**
  89839. * Sets wether the tone mapping effect is enabled.
  89840. */
  89841. toneMappingEnabled: boolean;
  89842. private _toneMappingType;
  89843. /**
  89844. * Gets the type of tone mapping effect.
  89845. */
  89846. /**
  89847. * Sets the type of tone mapping effect used in BabylonJS.
  89848. */
  89849. toneMappingType: number;
  89850. protected _contrast: number;
  89851. /**
  89852. * Gets the contrast used in the effect.
  89853. */
  89854. /**
  89855. * Sets the contrast used in the effect.
  89856. */
  89857. contrast: number;
  89858. /**
  89859. * Vignette stretch size.
  89860. */
  89861. vignetteStretch: number;
  89862. /**
  89863. * Vignette centre X Offset.
  89864. */
  89865. vignetteCentreX: number;
  89866. /**
  89867. * Vignette centre Y Offset.
  89868. */
  89869. vignetteCentreY: number;
  89870. /**
  89871. * Vignette weight or intensity of the vignette effect.
  89872. */
  89873. vignetteWeight: number;
  89874. /**
  89875. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89876. * if vignetteEnabled is set to true.
  89877. */
  89878. vignetteColor: Color4;
  89879. /**
  89880. * Camera field of view used by the Vignette effect.
  89881. */
  89882. vignetteCameraFov: number;
  89883. private _vignetteBlendMode;
  89884. /**
  89885. * Gets the vignette blend mode allowing different kind of effect.
  89886. */
  89887. /**
  89888. * Sets the vignette blend mode allowing different kind of effect.
  89889. */
  89890. vignetteBlendMode: number;
  89891. private _vignetteEnabled;
  89892. /**
  89893. * Gets wether the vignette effect is enabled.
  89894. */
  89895. /**
  89896. * Sets wether the vignette effect is enabled.
  89897. */
  89898. vignetteEnabled: boolean;
  89899. private _applyByPostProcess;
  89900. /**
  89901. * Gets wether the image processing is applied through a post process or not.
  89902. */
  89903. /**
  89904. * Sets wether the image processing is applied through a post process or not.
  89905. */
  89906. applyByPostProcess: boolean;
  89907. private _isEnabled;
  89908. /**
  89909. * Gets wether the image processing is enabled or not.
  89910. */
  89911. /**
  89912. * Sets wether the image processing is enabled or not.
  89913. */
  89914. isEnabled: boolean;
  89915. /**
  89916. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89917. */
  89918. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89919. /**
  89920. * Method called each time the image processing information changes requires to recompile the effect.
  89921. */
  89922. protected _updateParameters(): void;
  89923. /**
  89924. * Gets the current class name.
  89925. * @return "ImageProcessingConfiguration"
  89926. */
  89927. getClassName(): string;
  89928. /**
  89929. * Prepare the list of uniforms associated with the Image Processing effects.
  89930. * @param uniforms The list of uniforms used in the effect
  89931. * @param defines the list of defines currently in use
  89932. */
  89933. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89934. /**
  89935. * Prepare the list of samplers associated with the Image Processing effects.
  89936. * @param samplersList The list of uniforms used in the effect
  89937. * @param defines the list of defines currently in use
  89938. */
  89939. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89940. /**
  89941. * Prepare the list of defines associated to the shader.
  89942. * @param defines the list of defines to complete
  89943. * @param forPostProcess Define if we are currently in post process mode or not
  89944. */
  89945. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89946. /**
  89947. * Returns true if all the image processing information are ready.
  89948. * @returns True if ready, otherwise, false
  89949. */
  89950. isReady(): boolean;
  89951. /**
  89952. * Binds the image processing to the shader.
  89953. * @param effect The effect to bind to
  89954. * @param aspectRatio Define the current aspect ratio of the effect
  89955. */
  89956. bind(effect: Effect, aspectRatio?: number): void;
  89957. /**
  89958. * Clones the current image processing instance.
  89959. * @return The cloned image processing
  89960. */
  89961. clone(): ImageProcessingConfiguration;
  89962. /**
  89963. * Serializes the current image processing instance to a json representation.
  89964. * @return a JSON representation
  89965. */
  89966. serialize(): any;
  89967. /**
  89968. * Parses the image processing from a json representation.
  89969. * @param source the JSON source to parse
  89970. * @return The parsed image processing
  89971. */
  89972. static Parse(source: any): ImageProcessingConfiguration;
  89973. private static _VIGNETTEMODE_MULTIPLY;
  89974. private static _VIGNETTEMODE_OPAQUE;
  89975. /**
  89976. * Used to apply the vignette as a mix with the pixel color.
  89977. */
  89978. static readonly VIGNETTEMODE_MULTIPLY: number;
  89979. /**
  89980. * Used to apply the vignette as a replacement of the pixel color.
  89981. */
  89982. static readonly VIGNETTEMODE_OPAQUE: number;
  89983. }
  89984. }
  89985. declare module BABYLON {
  89986. /**
  89987. * This represents all the required information to add a fresnel effect on a material:
  89988. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89989. */
  89990. export class FresnelParameters {
  89991. private _isEnabled;
  89992. /**
  89993. * Define if the fresnel effect is enable or not.
  89994. */
  89995. isEnabled: boolean;
  89996. /**
  89997. * Define the color used on edges (grazing angle)
  89998. */
  89999. leftColor: Color3;
  90000. /**
  90001. * Define the color used on center
  90002. */
  90003. rightColor: Color3;
  90004. /**
  90005. * Define bias applied to computed fresnel term
  90006. */
  90007. bias: number;
  90008. /**
  90009. * Defined the power exponent applied to fresnel term
  90010. */
  90011. power: number;
  90012. /**
  90013. * Clones the current fresnel and its valuues
  90014. * @returns a clone fresnel configuration
  90015. */
  90016. clone(): FresnelParameters;
  90017. /**
  90018. * Serializes the current fresnel parameters to a JSON representation.
  90019. * @return the JSON serialization
  90020. */
  90021. serialize(): any;
  90022. /**
  90023. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90024. * @param parsedFresnelParameters Define the JSON representation
  90025. * @returns the parsed parameters
  90026. */
  90027. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90028. }
  90029. }
  90030. declare module BABYLON {
  90031. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90032. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90033. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90034. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90035. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90036. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90037. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90038. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90039. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90040. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90041. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90042. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90043. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90044. /**
  90045. * Decorator used to define property that can be serialized as reference to a camera
  90046. * @param sourceName defines the name of the property to decorate
  90047. */
  90048. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90049. /**
  90050. * Class used to help serialization objects
  90051. */
  90052. export class SerializationHelper {
  90053. /** hidden */
  90054. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90055. /** hidden */
  90056. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90057. /** hidden */
  90058. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90059. /** hidden */
  90060. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90061. /**
  90062. * Appends the serialized animations from the source animations
  90063. * @param source Source containing the animations
  90064. * @param destination Target to store the animations
  90065. */
  90066. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90067. /**
  90068. * Static function used to serialized a specific entity
  90069. * @param entity defines the entity to serialize
  90070. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90071. * @returns a JSON compatible object representing the serialization of the entity
  90072. */
  90073. static Serialize<T>(entity: T, serializationObject?: any): any;
  90074. /**
  90075. * Creates a new entity from a serialization data object
  90076. * @param creationFunction defines a function used to instanciated the new entity
  90077. * @param source defines the source serialization data
  90078. * @param scene defines the hosting scene
  90079. * @param rootUrl defines the root url for resources
  90080. * @returns a new entity
  90081. */
  90082. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90083. /**
  90084. * Clones an object
  90085. * @param creationFunction defines the function used to instanciate the new object
  90086. * @param source defines the source object
  90087. * @returns the cloned object
  90088. */
  90089. static Clone<T>(creationFunction: () => T, source: T): T;
  90090. /**
  90091. * Instanciates a new object based on a source one (some data will be shared between both object)
  90092. * @param creationFunction defines the function used to instanciate the new object
  90093. * @param source defines the source object
  90094. * @returns the new object
  90095. */
  90096. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90097. }
  90098. }
  90099. declare module BABYLON {
  90100. /**
  90101. * This is the base class of all the camera used in the application.
  90102. * @see http://doc.babylonjs.com/features/cameras
  90103. */
  90104. export class Camera extends Node {
  90105. /** @hidden */
  90106. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90107. /**
  90108. * This is the default projection mode used by the cameras.
  90109. * It helps recreating a feeling of perspective and better appreciate depth.
  90110. * This is the best way to simulate real life cameras.
  90111. */
  90112. static readonly PERSPECTIVE_CAMERA: number;
  90113. /**
  90114. * This helps creating camera with an orthographic mode.
  90115. * 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.
  90116. */
  90117. static readonly ORTHOGRAPHIC_CAMERA: number;
  90118. /**
  90119. * This is the default FOV mode for perspective cameras.
  90120. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90121. */
  90122. static readonly FOVMODE_VERTICAL_FIXED: number;
  90123. /**
  90124. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90125. */
  90126. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90127. /**
  90128. * This specifies ther is no need for a camera rig.
  90129. * Basically only one eye is rendered corresponding to the camera.
  90130. */
  90131. static readonly RIG_MODE_NONE: number;
  90132. /**
  90133. * Simulates a camera Rig with one blue eye and one red eye.
  90134. * This can be use with 3d blue and red glasses.
  90135. */
  90136. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90137. /**
  90138. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90139. */
  90140. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90141. /**
  90142. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90143. */
  90144. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90145. /**
  90146. * Defines that both eyes of the camera will be rendered over under each other.
  90147. */
  90148. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90149. /**
  90150. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90151. */
  90152. static readonly RIG_MODE_VR: number;
  90153. /**
  90154. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90155. */
  90156. static readonly RIG_MODE_WEBVR: number;
  90157. /**
  90158. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90159. */
  90160. static readonly RIG_MODE_CUSTOM: number;
  90161. /**
  90162. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90163. */
  90164. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90165. /**
  90166. * Define the input manager associated with the camera.
  90167. */
  90168. inputs: CameraInputsManager<Camera>;
  90169. /** @hidden */
  90170. _position: Vector3;
  90171. /**
  90172. * Define the current local position of the camera in the scene
  90173. */
  90174. position: Vector3;
  90175. /**
  90176. * The vector the camera should consider as up.
  90177. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90178. */
  90179. upVector: Vector3;
  90180. /**
  90181. * Define the current limit on the left side for an orthographic camera
  90182. * In scene unit
  90183. */
  90184. orthoLeft: Nullable<number>;
  90185. /**
  90186. * Define the current limit on the right side for an orthographic camera
  90187. * In scene unit
  90188. */
  90189. orthoRight: Nullable<number>;
  90190. /**
  90191. * Define the current limit on the bottom side for an orthographic camera
  90192. * In scene unit
  90193. */
  90194. orthoBottom: Nullable<number>;
  90195. /**
  90196. * Define the current limit on the top side for an orthographic camera
  90197. * In scene unit
  90198. */
  90199. orthoTop: Nullable<number>;
  90200. /**
  90201. * Field Of View is set in Radians. (default is 0.8)
  90202. */
  90203. fov: number;
  90204. /**
  90205. * Define the minimum distance the camera can see from.
  90206. * This is important to note that the depth buffer are not infinite and the closer it starts
  90207. * the more your scene might encounter depth fighting issue.
  90208. */
  90209. minZ: number;
  90210. /**
  90211. * Define the maximum distance the camera can see to.
  90212. * This is important to note that the depth buffer are not infinite and the further it end
  90213. * the more your scene might encounter depth fighting issue.
  90214. */
  90215. maxZ: number;
  90216. /**
  90217. * Define the default inertia of the camera.
  90218. * This helps giving a smooth feeling to the camera movement.
  90219. */
  90220. inertia: number;
  90221. /**
  90222. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90223. */
  90224. mode: number;
  90225. /**
  90226. * Define wether the camera is intermediate.
  90227. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90228. */
  90229. isIntermediate: boolean;
  90230. /**
  90231. * Define the viewport of the camera.
  90232. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90233. */
  90234. viewport: Viewport;
  90235. /**
  90236. * Restricts the camera to viewing objects with the same layerMask.
  90237. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90238. */
  90239. layerMask: number;
  90240. /**
  90241. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90242. */
  90243. fovMode: number;
  90244. /**
  90245. * Rig mode of the camera.
  90246. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90247. * This is normally controlled byt the camera themselves as internal use.
  90248. */
  90249. cameraRigMode: number;
  90250. /**
  90251. * Defines the distance between both "eyes" in case of a RIG
  90252. */
  90253. interaxialDistance: number;
  90254. /**
  90255. * Defines if stereoscopic rendering is done side by side or over under.
  90256. */
  90257. isStereoscopicSideBySide: boolean;
  90258. /**
  90259. * 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
  90260. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90261. * else in the scene.
  90262. */
  90263. customRenderTargets: RenderTargetTexture[];
  90264. /**
  90265. * When set, the camera will render to this render target instead of the default canvas
  90266. */
  90267. outputRenderTarget: Nullable<RenderTargetTexture>;
  90268. /**
  90269. * Observable triggered when the camera view matrix has changed.
  90270. */
  90271. onViewMatrixChangedObservable: Observable<Camera>;
  90272. /**
  90273. * Observable triggered when the camera Projection matrix has changed.
  90274. */
  90275. onProjectionMatrixChangedObservable: Observable<Camera>;
  90276. /**
  90277. * Observable triggered when the inputs have been processed.
  90278. */
  90279. onAfterCheckInputsObservable: Observable<Camera>;
  90280. /**
  90281. * Observable triggered when reset has been called and applied to the camera.
  90282. */
  90283. onRestoreStateObservable: Observable<Camera>;
  90284. /** @hidden */
  90285. _cameraRigParams: any;
  90286. /** @hidden */
  90287. _rigCameras: Camera[];
  90288. /** @hidden */
  90289. _rigPostProcess: Nullable<PostProcess>;
  90290. protected _webvrViewMatrix: Matrix;
  90291. /** @hidden */
  90292. _skipRendering: boolean;
  90293. /** @hidden */
  90294. _projectionMatrix: Matrix;
  90295. /** @hidden */
  90296. _postProcesses: Nullable<PostProcess>[];
  90297. /** @hidden */
  90298. _activeMeshes: SmartArray<AbstractMesh>;
  90299. protected _globalPosition: Vector3;
  90300. /** hidden */
  90301. _computedViewMatrix: Matrix;
  90302. private _doNotComputeProjectionMatrix;
  90303. private _transformMatrix;
  90304. private _frustumPlanes;
  90305. private _refreshFrustumPlanes;
  90306. private _storedFov;
  90307. private _stateStored;
  90308. /**
  90309. * Instantiates a new camera object.
  90310. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90311. * @see http://doc.babylonjs.com/features/cameras
  90312. * @param name Defines the name of the camera in the scene
  90313. * @param position Defines the position of the camera
  90314. * @param scene Defines the scene the camera belongs too
  90315. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90316. */
  90317. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90318. /**
  90319. * Store current camera state (fov, position, etc..)
  90320. * @returns the camera
  90321. */
  90322. storeState(): Camera;
  90323. /**
  90324. * Restores the camera state values if it has been stored. You must call storeState() first
  90325. */
  90326. protected _restoreStateValues(): boolean;
  90327. /**
  90328. * Restored camera state. You must call storeState() first.
  90329. * @returns true if restored and false otherwise
  90330. */
  90331. restoreState(): boolean;
  90332. /**
  90333. * Gets the class name of the camera.
  90334. * @returns the class name
  90335. */
  90336. getClassName(): string;
  90337. /** @hidden */
  90338. readonly _isCamera: boolean;
  90339. /**
  90340. * Gets a string representation of the camera useful for debug purpose.
  90341. * @param fullDetails Defines that a more verboe level of logging is required
  90342. * @returns the string representation
  90343. */
  90344. toString(fullDetails?: boolean): string;
  90345. /**
  90346. * Gets the current world space position of the camera.
  90347. */
  90348. readonly globalPosition: Vector3;
  90349. /**
  90350. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90351. * @returns the active meshe list
  90352. */
  90353. getActiveMeshes(): SmartArray<AbstractMesh>;
  90354. /**
  90355. * Check wether a mesh is part of the current active mesh list of the camera
  90356. * @param mesh Defines the mesh to check
  90357. * @returns true if active, false otherwise
  90358. */
  90359. isActiveMesh(mesh: Mesh): boolean;
  90360. /**
  90361. * Is this camera ready to be used/rendered
  90362. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90363. * @return true if the camera is ready
  90364. */
  90365. isReady(completeCheck?: boolean): boolean;
  90366. /** @hidden */
  90367. _initCache(): void;
  90368. /** @hidden */
  90369. _updateCache(ignoreParentClass?: boolean): void;
  90370. /** @hidden */
  90371. _isSynchronized(): boolean;
  90372. /** @hidden */
  90373. _isSynchronizedViewMatrix(): boolean;
  90374. /** @hidden */
  90375. _isSynchronizedProjectionMatrix(): boolean;
  90376. /**
  90377. * Attach the input controls to a specific dom element to get the input from.
  90378. * @param element Defines the element the controls should be listened from
  90379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90380. */
  90381. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90382. /**
  90383. * Detach the current controls from the specified dom element.
  90384. * @param element Defines the element to stop listening the inputs from
  90385. */
  90386. detachControl(element: HTMLElement): void;
  90387. /**
  90388. * Update the camera state according to the different inputs gathered during the frame.
  90389. */
  90390. update(): void;
  90391. /** @hidden */
  90392. _checkInputs(): void;
  90393. /** @hidden */
  90394. readonly rigCameras: Camera[];
  90395. /**
  90396. * Gets the post process used by the rig cameras
  90397. */
  90398. readonly rigPostProcess: Nullable<PostProcess>;
  90399. /**
  90400. * Internal, gets the first post proces.
  90401. * @returns the first post process to be run on this camera.
  90402. */
  90403. _getFirstPostProcess(): Nullable<PostProcess>;
  90404. private _cascadePostProcessesToRigCams;
  90405. /**
  90406. * Attach a post process to the camera.
  90407. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90408. * @param postProcess The post process to attach to the camera
  90409. * @param insertAt The position of the post process in case several of them are in use in the scene
  90410. * @returns the position the post process has been inserted at
  90411. */
  90412. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90413. /**
  90414. * Detach a post process to the camera.
  90415. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90416. * @param postProcess The post process to detach from the camera
  90417. */
  90418. detachPostProcess(postProcess: PostProcess): void;
  90419. /**
  90420. * Gets the current world matrix of the camera
  90421. */
  90422. getWorldMatrix(): Matrix;
  90423. /** @hidden */
  90424. _getViewMatrix(): Matrix;
  90425. /**
  90426. * Gets the current view matrix of the camera.
  90427. * @param force forces the camera to recompute the matrix without looking at the cached state
  90428. * @returns the view matrix
  90429. */
  90430. getViewMatrix(force?: boolean): Matrix;
  90431. /**
  90432. * Freeze the projection matrix.
  90433. * It will prevent the cache check of the camera projection compute and can speed up perf
  90434. * if no parameter of the camera are meant to change
  90435. * @param projection Defines manually a projection if necessary
  90436. */
  90437. freezeProjectionMatrix(projection?: Matrix): void;
  90438. /**
  90439. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90440. */
  90441. unfreezeProjectionMatrix(): void;
  90442. /**
  90443. * Gets the current projection matrix of the camera.
  90444. * @param force forces the camera to recompute the matrix without looking at the cached state
  90445. * @returns the projection matrix
  90446. */
  90447. getProjectionMatrix(force?: boolean): Matrix;
  90448. /**
  90449. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90450. * @returns a Matrix
  90451. */
  90452. getTransformationMatrix(): Matrix;
  90453. private _updateFrustumPlanes;
  90454. /**
  90455. * Checks if a cullable object (mesh...) is in the camera frustum
  90456. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90457. * @param target The object to check
  90458. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90459. * @returns true if the object is in frustum otherwise false
  90460. */
  90461. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90462. /**
  90463. * Checks if a cullable object (mesh...) is in the camera frustum
  90464. * Unlike isInFrustum this cheks the full bounding box
  90465. * @param target The object to check
  90466. * @returns true if the object is in frustum otherwise false
  90467. */
  90468. isCompletelyInFrustum(target: ICullable): boolean;
  90469. /**
  90470. * Gets a ray in the forward direction from the camera.
  90471. * @param length Defines the length of the ray to create
  90472. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90473. * @param origin Defines the start point of the ray which defaults to the camera position
  90474. * @returns the forward ray
  90475. */
  90476. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90477. /**
  90478. * Releases resources associated with this node.
  90479. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90480. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90481. */
  90482. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90483. /** @hidden */
  90484. _isLeftCamera: boolean;
  90485. /**
  90486. * Gets the left camera of a rig setup in case of Rigged Camera
  90487. */
  90488. readonly isLeftCamera: boolean;
  90489. /** @hidden */
  90490. _isRightCamera: boolean;
  90491. /**
  90492. * Gets the right camera of a rig setup in case of Rigged Camera
  90493. */
  90494. readonly isRightCamera: boolean;
  90495. /**
  90496. * Gets the left camera of a rig setup in case of Rigged Camera
  90497. */
  90498. readonly leftCamera: Nullable<FreeCamera>;
  90499. /**
  90500. * Gets the right camera of a rig setup in case of Rigged Camera
  90501. */
  90502. readonly rightCamera: Nullable<FreeCamera>;
  90503. /**
  90504. * Gets the left camera target of a rig setup in case of Rigged Camera
  90505. * @returns the target position
  90506. */
  90507. getLeftTarget(): Nullable<Vector3>;
  90508. /**
  90509. * Gets the right camera target of a rig setup in case of Rigged Camera
  90510. * @returns the target position
  90511. */
  90512. getRightTarget(): Nullable<Vector3>;
  90513. /**
  90514. * @hidden
  90515. */
  90516. setCameraRigMode(mode: number, rigParams: any): void;
  90517. /** @hidden */
  90518. static _setStereoscopicRigMode(camera: Camera): void;
  90519. /** @hidden */
  90520. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90521. /** @hidden */
  90522. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90523. /** @hidden */
  90524. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90525. /** @hidden */
  90526. _getVRProjectionMatrix(): Matrix;
  90527. protected _updateCameraRotationMatrix(): void;
  90528. protected _updateWebVRCameraRotationMatrix(): void;
  90529. /**
  90530. * This function MUST be overwritten by the different WebVR cameras available.
  90531. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90532. * @hidden
  90533. */
  90534. _getWebVRProjectionMatrix(): Matrix;
  90535. /**
  90536. * This function MUST be overwritten by the different WebVR cameras available.
  90537. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90538. * @hidden
  90539. */
  90540. _getWebVRViewMatrix(): Matrix;
  90541. /** @hidden */
  90542. setCameraRigParameter(name: string, value: any): void;
  90543. /**
  90544. * needs to be overridden by children so sub has required properties to be copied
  90545. * @hidden
  90546. */
  90547. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90548. /**
  90549. * May need to be overridden by children
  90550. * @hidden
  90551. */
  90552. _updateRigCameras(): void;
  90553. /** @hidden */
  90554. _setupInputs(): void;
  90555. /**
  90556. * Serialiaze the camera setup to a json represention
  90557. * @returns the JSON representation
  90558. */
  90559. serialize(): any;
  90560. /**
  90561. * Clones the current camera.
  90562. * @param name The cloned camera name
  90563. * @returns the cloned camera
  90564. */
  90565. clone(name: string): Camera;
  90566. /**
  90567. * Gets the direction of the camera relative to a given local axis.
  90568. * @param localAxis Defines the reference axis to provide a relative direction.
  90569. * @return the direction
  90570. */
  90571. getDirection(localAxis: Vector3): Vector3;
  90572. /**
  90573. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90574. * @param localAxis Defines the reference axis to provide a relative direction.
  90575. * @param result Defines the vector to store the result in
  90576. */
  90577. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90578. /**
  90579. * Gets a camera constructor for a given camera type
  90580. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90581. * @param name The name of the camera the result will be able to instantiate
  90582. * @param scene The scene the result will construct the camera in
  90583. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90584. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90585. * @returns a factory method to construc the camera
  90586. */
  90587. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90588. /**
  90589. * Compute the world matrix of the camera.
  90590. * @returns the camera workd matrix
  90591. */
  90592. computeWorldMatrix(): Matrix;
  90593. /**
  90594. * Parse a JSON and creates the camera from the parsed information
  90595. * @param parsedCamera The JSON to parse
  90596. * @param scene The scene to instantiate the camera in
  90597. * @returns the newly constructed camera
  90598. */
  90599. static Parse(parsedCamera: any, scene: Scene): Camera;
  90600. }
  90601. }
  90602. declare module BABYLON {
  90603. /**
  90604. * Interface for any object that can request an animation frame
  90605. */
  90606. export interface ICustomAnimationFrameRequester {
  90607. /**
  90608. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90609. */
  90610. renderFunction?: Function;
  90611. /**
  90612. * Called to request the next frame to render to
  90613. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90614. */
  90615. requestAnimationFrame: Function;
  90616. /**
  90617. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90618. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90619. */
  90620. requestID?: number;
  90621. }
  90622. /**
  90623. * Interface containing an array of animations
  90624. */
  90625. export interface IAnimatable {
  90626. /**
  90627. * Array of animations
  90628. */
  90629. animations: Nullable<Array<Animation>>;
  90630. }
  90631. /** Interface used by value gradients (color, factor, ...) */
  90632. export interface IValueGradient {
  90633. /**
  90634. * Gets or sets the gradient value (between 0 and 1)
  90635. */
  90636. gradient: number;
  90637. }
  90638. /** Class used to store color4 gradient */
  90639. export class ColorGradient implements IValueGradient {
  90640. /**
  90641. * Gets or sets the gradient value (between 0 and 1)
  90642. */
  90643. gradient: number;
  90644. /**
  90645. * Gets or sets first associated color
  90646. */
  90647. color1: Color4;
  90648. /**
  90649. * Gets or sets second associated color
  90650. */
  90651. color2?: Color4;
  90652. /**
  90653. * Will get a color picked randomly between color1 and color2.
  90654. * If color2 is undefined then color1 will be used
  90655. * @param result defines the target Color4 to store the result in
  90656. */
  90657. getColorToRef(result: Color4): void;
  90658. }
  90659. /** Class used to store color 3 gradient */
  90660. export class Color3Gradient implements IValueGradient {
  90661. /**
  90662. * Gets or sets the gradient value (between 0 and 1)
  90663. */
  90664. gradient: number;
  90665. /**
  90666. * Gets or sets the associated color
  90667. */
  90668. color: Color3;
  90669. }
  90670. /** Class used to store factor gradient */
  90671. export class FactorGradient implements IValueGradient {
  90672. /**
  90673. * Gets or sets the gradient value (between 0 and 1)
  90674. */
  90675. gradient: number;
  90676. /**
  90677. * Gets or sets first associated factor
  90678. */
  90679. factor1: number;
  90680. /**
  90681. * Gets or sets second associated factor
  90682. */
  90683. factor2?: number;
  90684. /**
  90685. * Will get a number picked randomly between factor1 and factor2.
  90686. * If factor2 is undefined then factor1 will be used
  90687. * @returns the picked number
  90688. */
  90689. getFactor(): number;
  90690. }
  90691. /**
  90692. * @ignore
  90693. * Application error to support additional information when loading a file
  90694. */
  90695. export class LoadFileError extends Error {
  90696. /** defines the optional web request */
  90697. request?: WebRequest | undefined;
  90698. private static _setPrototypeOf;
  90699. /**
  90700. * Creates a new LoadFileError
  90701. * @param message defines the message of the error
  90702. * @param request defines the optional web request
  90703. */
  90704. constructor(message: string,
  90705. /** defines the optional web request */
  90706. request?: WebRequest | undefined);
  90707. }
  90708. /**
  90709. * Class used to define a retry strategy when error happens while loading assets
  90710. */
  90711. export class RetryStrategy {
  90712. /**
  90713. * Function used to defines an exponential back off strategy
  90714. * @param maxRetries defines the maximum number of retries (3 by default)
  90715. * @param baseInterval defines the interval between retries
  90716. * @returns the strategy function to use
  90717. */
  90718. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90719. }
  90720. /**
  90721. * File request interface
  90722. */
  90723. export interface IFileRequest {
  90724. /**
  90725. * Raised when the request is complete (success or error).
  90726. */
  90727. onCompleteObservable: Observable<IFileRequest>;
  90728. /**
  90729. * Aborts the request for a file.
  90730. */
  90731. abort: () => void;
  90732. }
  90733. /**
  90734. * Class containing a set of static utilities functions
  90735. */
  90736. export class Tools {
  90737. /**
  90738. * Gets or sets the base URL to use to load assets
  90739. */
  90740. static BaseUrl: string;
  90741. /**
  90742. * Enable/Disable Custom HTTP Request Headers globally.
  90743. * default = false
  90744. * @see CustomRequestHeaders
  90745. */
  90746. static UseCustomRequestHeaders: boolean;
  90747. /**
  90748. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90749. * i.e. when loading files, where the server/service expects an Authorization header
  90750. */
  90751. static CustomRequestHeaders: {
  90752. [key: string]: string;
  90753. };
  90754. /**
  90755. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90756. */
  90757. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90758. /**
  90759. * Default behaviour for cors in the application.
  90760. * It can be a string if the expected behavior is identical in the entire app.
  90761. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90762. */
  90763. static CorsBehavior: string | ((url: string | string[]) => string);
  90764. /**
  90765. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90766. * @ignorenaming
  90767. */
  90768. static UseFallbackTexture: boolean;
  90769. /**
  90770. * Use this object to register external classes like custom textures or material
  90771. * to allow the laoders to instantiate them
  90772. */
  90773. static RegisteredExternalClasses: {
  90774. [key: string]: Object;
  90775. };
  90776. /**
  90777. * Texture content used if a texture cannot loaded
  90778. * @ignorenaming
  90779. */
  90780. static fallbackTexture: string;
  90781. /**
  90782. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90783. * @param u defines the coordinate on X axis
  90784. * @param v defines the coordinate on Y axis
  90785. * @param width defines the width of the source data
  90786. * @param height defines the height of the source data
  90787. * @param pixels defines the source byte array
  90788. * @param color defines the output color
  90789. */
  90790. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90791. /**
  90792. * Interpolates between a and b via alpha
  90793. * @param a The lower value (returned when alpha = 0)
  90794. * @param b The upper value (returned when alpha = 1)
  90795. * @param alpha The interpolation-factor
  90796. * @return The mixed value
  90797. */
  90798. static Mix(a: number, b: number, alpha: number): number;
  90799. /**
  90800. * Tries to instantiate a new object from a given class name
  90801. * @param className defines the class name to instantiate
  90802. * @returns the new object or null if the system was not able to do the instantiation
  90803. */
  90804. static Instantiate(className: string): any;
  90805. /**
  90806. * Provides a slice function that will work even on IE
  90807. * @param data defines the array to slice
  90808. * @param start defines the start of the data (optional)
  90809. * @param end defines the end of the data (optional)
  90810. * @returns the new sliced array
  90811. */
  90812. static Slice<T>(data: T, start?: number, end?: number): T;
  90813. /**
  90814. * Polyfill for setImmediate
  90815. * @param action defines the action to execute after the current execution block
  90816. */
  90817. static SetImmediate(action: () => void): void;
  90818. /**
  90819. * Function indicating if a number is an exponent of 2
  90820. * @param value defines the value to test
  90821. * @returns true if the value is an exponent of 2
  90822. */
  90823. static IsExponentOfTwo(value: number): boolean;
  90824. private static _tmpFloatArray;
  90825. /**
  90826. * Returns the nearest 32-bit single precision float representation of a Number
  90827. * @param value A Number. If the parameter is of a different type, it will get converted
  90828. * to a number or to NaN if it cannot be converted
  90829. * @returns number
  90830. */
  90831. static FloatRound(value: number): number;
  90832. /**
  90833. * Find the next highest power of two.
  90834. * @param x Number to start search from.
  90835. * @return Next highest power of two.
  90836. */
  90837. static CeilingPOT(x: number): number;
  90838. /**
  90839. * Find the next lowest power of two.
  90840. * @param x Number to start search from.
  90841. * @return Next lowest power of two.
  90842. */
  90843. static FloorPOT(x: number): number;
  90844. /**
  90845. * Find the nearest power of two.
  90846. * @param x Number to start search from.
  90847. * @return Next nearest power of two.
  90848. */
  90849. static NearestPOT(x: number): number;
  90850. /**
  90851. * Get the closest exponent of two
  90852. * @param value defines the value to approximate
  90853. * @param max defines the maximum value to return
  90854. * @param mode defines how to define the closest value
  90855. * @returns closest exponent of two of the given value
  90856. */
  90857. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90858. /**
  90859. * Extracts the filename from a path
  90860. * @param path defines the path to use
  90861. * @returns the filename
  90862. */
  90863. static GetFilename(path: string): string;
  90864. /**
  90865. * Extracts the "folder" part of a path (everything before the filename).
  90866. * @param uri The URI to extract the info from
  90867. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90868. * @returns The "folder" part of the path
  90869. */
  90870. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90871. /**
  90872. * Extracts text content from a DOM element hierarchy
  90873. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90874. */
  90875. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90876. /**
  90877. * Convert an angle in radians to degrees
  90878. * @param angle defines the angle to convert
  90879. * @returns the angle in degrees
  90880. */
  90881. static ToDegrees(angle: number): number;
  90882. /**
  90883. * Convert an angle in degrees to radians
  90884. * @param angle defines the angle to convert
  90885. * @returns the angle in radians
  90886. */
  90887. static ToRadians(angle: number): number;
  90888. /**
  90889. * Encode a buffer to a base64 string
  90890. * @param buffer defines the buffer to encode
  90891. * @returns the encoded string
  90892. */
  90893. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90894. /**
  90895. * Extracts minimum and maximum values from a list of indexed positions
  90896. * @param positions defines the positions to use
  90897. * @param indices defines the indices to the positions
  90898. * @param indexStart defines the start index
  90899. * @param indexCount defines the end index
  90900. * @param bias defines bias value to add to the result
  90901. * @return minimum and maximum values
  90902. */
  90903. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90904. minimum: Vector3;
  90905. maximum: Vector3;
  90906. };
  90907. /**
  90908. * Extracts minimum and maximum values from a list of positions
  90909. * @param positions defines the positions to use
  90910. * @param start defines the start index in the positions array
  90911. * @param count defines the number of positions to handle
  90912. * @param bias defines bias value to add to the result
  90913. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90914. * @return minimum and maximum values
  90915. */
  90916. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90917. minimum: Vector3;
  90918. maximum: Vector3;
  90919. };
  90920. /**
  90921. * Returns an array if obj is not an array
  90922. * @param obj defines the object to evaluate as an array
  90923. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90924. * @returns either obj directly if obj is an array or a new array containing obj
  90925. */
  90926. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90927. /**
  90928. * Gets the pointer prefix to use
  90929. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90930. */
  90931. static GetPointerPrefix(): string;
  90932. /**
  90933. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90934. * @param func - the function to be called
  90935. * @param requester - the object that will request the next frame. Falls back to window.
  90936. * @returns frame number
  90937. */
  90938. static QueueNewFrame(func: () => void, requester?: any): number;
  90939. /**
  90940. * Ask the browser to promote the current element to fullscreen rendering mode
  90941. * @param element defines the DOM element to promote
  90942. */
  90943. static RequestFullscreen(element: HTMLElement): void;
  90944. /**
  90945. * Asks the browser to exit fullscreen mode
  90946. */
  90947. static ExitFullscreen(): void;
  90948. /**
  90949. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90950. * @param url define the url we are trying
  90951. * @param element define the dom element where to configure the cors policy
  90952. */
  90953. static SetCorsBehavior(url: string | string[], element: {
  90954. crossOrigin: string | null;
  90955. }): void;
  90956. /**
  90957. * Removes unwanted characters from an url
  90958. * @param url defines the url to clean
  90959. * @returns the cleaned url
  90960. */
  90961. static CleanUrl(url: string): string;
  90962. /**
  90963. * Gets or sets a function used to pre-process url before using them to load assets
  90964. */
  90965. static PreprocessUrl: (url: string) => string;
  90966. /**
  90967. * Loads an image as an HTMLImageElement.
  90968. * @param input url string, ArrayBuffer, or Blob to load
  90969. * @param onLoad callback called when the image successfully loads
  90970. * @param onError callback called when the image fails to load
  90971. * @param offlineProvider offline provider for caching
  90972. * @returns the HTMLImageElement of the loaded image
  90973. */
  90974. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90975. /**
  90976. * Loads a file
  90977. * @param url url string, ArrayBuffer, or Blob to load
  90978. * @param onSuccess callback called when the file successfully loads
  90979. * @param onProgress callback called while file is loading (if the server supports this mode)
  90980. * @param offlineProvider defines the offline provider for caching
  90981. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90982. * @param onError callback called when the file fails to load
  90983. * @returns a file request object
  90984. */
  90985. 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;
  90986. /**
  90987. * Load a script (identified by an url). When the url returns, the
  90988. * content of this file is added into a new script element, attached to the DOM (body element)
  90989. * @param scriptUrl defines the url of the script to laod
  90990. * @param onSuccess defines the callback called when the script is loaded
  90991. * @param onError defines the callback to call if an error occurs
  90992. * @param scriptId defines the id of the script element
  90993. */
  90994. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90995. /**
  90996. * Load an asynchronous script (identified by an url). When the url returns, the
  90997. * content of this file is added into a new script element, attached to the DOM (body element)
  90998. * @param scriptUrl defines the url of the script to laod
  90999. * @param scriptId defines the id of the script element
  91000. * @returns a promise request object
  91001. */
  91002. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  91003. /**
  91004. * Loads a file from a blob
  91005. * @param fileToLoad defines the blob to use
  91006. * @param callback defines the callback to call when data is loaded
  91007. * @param progressCallback defines the callback to call during loading process
  91008. * @returns a file request object
  91009. */
  91010. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  91011. /**
  91012. * Loads a file
  91013. * @param fileToLoad defines the file to load
  91014. * @param callback defines the callback to call when data is loaded
  91015. * @param progressCallBack defines the callback to call during loading process
  91016. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  91017. * @returns a file request object
  91018. */
  91019. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  91020. /**
  91021. * Creates a data url from a given string content
  91022. * @param content defines the content to convert
  91023. * @returns the new data url link
  91024. */
  91025. static FileAsURL(content: string): string;
  91026. /**
  91027. * Format the given number to a specific decimal format
  91028. * @param value defines the number to format
  91029. * @param decimals defines the number of decimals to use
  91030. * @returns the formatted string
  91031. */
  91032. static Format(value: number, decimals?: number): string;
  91033. /**
  91034. * Checks if a given vector is inside a specific range
  91035. * @param v defines the vector to test
  91036. * @param min defines the minimum range
  91037. * @param max defines the maximum range
  91038. */
  91039. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91040. /**
  91041. * Tries to copy an object by duplicating every property
  91042. * @param source defines the source object
  91043. * @param destination defines the target object
  91044. * @param doNotCopyList defines a list of properties to avoid
  91045. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91046. */
  91047. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91048. /**
  91049. * Gets a boolean indicating if the given object has no own property
  91050. * @param obj defines the object to test
  91051. * @returns true if object has no own property
  91052. */
  91053. static IsEmpty(obj: any): boolean;
  91054. /**
  91055. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91056. * @param str Source string
  91057. * @param suffix Suffix to search for in the source string
  91058. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91059. */
  91060. static EndsWith(str: string, suffix: string): boolean;
  91061. /**
  91062. * Function used to register events at window level
  91063. * @param events defines the events to register
  91064. */
  91065. static RegisterTopRootEvents(events: {
  91066. name: string;
  91067. handler: Nullable<(e: FocusEvent) => any>;
  91068. }[]): void;
  91069. /**
  91070. * Function used to unregister events from window level
  91071. * @param events defines the events to unregister
  91072. */
  91073. static UnregisterTopRootEvents(events: {
  91074. name: string;
  91075. handler: Nullable<(e: FocusEvent) => any>;
  91076. }[]): void;
  91077. /**
  91078. * @ignore
  91079. */
  91080. static _ScreenshotCanvas: HTMLCanvasElement;
  91081. /**
  91082. * Dumps the current bound framebuffer
  91083. * @param width defines the rendering width
  91084. * @param height defines the rendering height
  91085. * @param engine defines the hosting engine
  91086. * @param successCallback defines the callback triggered once the data are available
  91087. * @param mimeType defines the mime type of the result
  91088. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91089. */
  91090. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91091. /**
  91092. * Converts the canvas data to blob.
  91093. * This acts as a polyfill for browsers not supporting the to blob function.
  91094. * @param canvas Defines the canvas to extract the data from
  91095. * @param successCallback Defines the callback triggered once the data are available
  91096. * @param mimeType Defines the mime type of the result
  91097. */
  91098. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91099. /**
  91100. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91101. * @param successCallback defines the callback triggered once the data are available
  91102. * @param mimeType defines the mime type of the result
  91103. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91104. */
  91105. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91106. /**
  91107. * Downloads a blob in the browser
  91108. * @param blob defines the blob to download
  91109. * @param fileName defines the name of the downloaded file
  91110. */
  91111. static Download(blob: Blob, fileName: string): void;
  91112. /**
  91113. * Captures a screenshot of the current rendering
  91114. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91115. * @param engine defines the rendering engine
  91116. * @param camera defines the source camera
  91117. * @param size This parameter can be set to a single number or to an object with the
  91118. * following (optional) properties: precision, width, height. If a single number is passed,
  91119. * it will be used for both width and height. If an object is passed, the screenshot size
  91120. * will be derived from the parameters. The precision property is a multiplier allowing
  91121. * rendering at a higher or lower resolution
  91122. * @param successCallback defines the callback receives a single parameter which contains the
  91123. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91124. * src parameter of an <img> to display it
  91125. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91126. * Check your browser for supported MIME types
  91127. */
  91128. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91129. /**
  91130. * Generates an image screenshot from the specified camera.
  91131. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91132. * @param engine The engine to use for rendering
  91133. * @param camera The camera to use for rendering
  91134. * @param size This parameter can be set to a single number or to an object with the
  91135. * following (optional) properties: precision, width, height. If a single number is passed,
  91136. * it will be used for both width and height. If an object is passed, the screenshot size
  91137. * will be derived from the parameters. The precision property is a multiplier allowing
  91138. * rendering at a higher or lower resolution
  91139. * @param successCallback The callback receives a single parameter which contains the
  91140. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91141. * src parameter of an <img> to display it
  91142. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91143. * Check your browser for supported MIME types
  91144. * @param samples Texture samples (default: 1)
  91145. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91146. * @param fileName A name for for the downloaded file.
  91147. */
  91148. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91149. /**
  91150. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91151. * Be aware Math.random() could cause collisions, but:
  91152. * "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"
  91153. * @returns a pseudo random id
  91154. */
  91155. static RandomId(): string;
  91156. /**
  91157. * Test if the given uri is a base64 string
  91158. * @param uri The uri to test
  91159. * @return True if the uri is a base64 string or false otherwise
  91160. */
  91161. static IsBase64(uri: string): boolean;
  91162. /**
  91163. * Decode the given base64 uri.
  91164. * @param uri The uri to decode
  91165. * @return The decoded base64 data.
  91166. */
  91167. static DecodeBase64(uri: string): ArrayBuffer;
  91168. /**
  91169. * Gets the absolute url.
  91170. * @param url the input url
  91171. * @return the absolute url
  91172. */
  91173. static GetAbsoluteUrl(url: string): string;
  91174. /**
  91175. * No log
  91176. */
  91177. static readonly NoneLogLevel: number;
  91178. /**
  91179. * Only message logs
  91180. */
  91181. static readonly MessageLogLevel: number;
  91182. /**
  91183. * Only warning logs
  91184. */
  91185. static readonly WarningLogLevel: number;
  91186. /**
  91187. * Only error logs
  91188. */
  91189. static readonly ErrorLogLevel: number;
  91190. /**
  91191. * All logs
  91192. */
  91193. static readonly AllLogLevel: number;
  91194. /**
  91195. * Gets a value indicating the number of loading errors
  91196. * @ignorenaming
  91197. */
  91198. static readonly errorsCount: number;
  91199. /**
  91200. * Callback called when a new log is added
  91201. */
  91202. static OnNewCacheEntry: (entry: string) => void;
  91203. /**
  91204. * Log a message to the console
  91205. * @param message defines the message to log
  91206. */
  91207. static Log(message: string): void;
  91208. /**
  91209. * Write a warning message to the console
  91210. * @param message defines the message to log
  91211. */
  91212. static Warn(message: string): void;
  91213. /**
  91214. * Write an error message to the console
  91215. * @param message defines the message to log
  91216. */
  91217. static Error(message: string): void;
  91218. /**
  91219. * Gets current log cache (list of logs)
  91220. */
  91221. static readonly LogCache: string;
  91222. /**
  91223. * Clears the log cache
  91224. */
  91225. static ClearLogCache(): void;
  91226. /**
  91227. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91228. */
  91229. static LogLevels: number;
  91230. /**
  91231. * Checks if the loaded document was accessed via `file:`-Protocol.
  91232. * @returns boolean
  91233. */
  91234. static IsFileURL(): boolean;
  91235. /**
  91236. * Checks if the window object exists
  91237. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91238. */
  91239. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91240. /**
  91241. * No performance log
  91242. */
  91243. static readonly PerformanceNoneLogLevel: number;
  91244. /**
  91245. * Use user marks to log performance
  91246. */
  91247. static readonly PerformanceUserMarkLogLevel: number;
  91248. /**
  91249. * Log performance to the console
  91250. */
  91251. static readonly PerformanceConsoleLogLevel: number;
  91252. private static _performance;
  91253. /**
  91254. * Sets the current performance log level
  91255. */
  91256. static PerformanceLogLevel: number;
  91257. private static _StartPerformanceCounterDisabled;
  91258. private static _EndPerformanceCounterDisabled;
  91259. private static _StartUserMark;
  91260. private static _EndUserMark;
  91261. private static _StartPerformanceConsole;
  91262. private static _EndPerformanceConsole;
  91263. /**
  91264. * Starts a performance counter
  91265. */
  91266. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91267. /**
  91268. * Ends a specific performance coutner
  91269. */
  91270. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91271. /**
  91272. * Gets either window.performance.now() if supported or Date.now() else
  91273. */
  91274. static readonly Now: number;
  91275. /**
  91276. * This method will return the name of the class used to create the instance of the given object.
  91277. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91278. * @param object the object to get the class name from
  91279. * @param isType defines if the object is actually a type
  91280. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91281. */
  91282. static GetClassName(object: any, isType?: boolean): string;
  91283. /**
  91284. * Gets the first element of an array satisfying a given predicate
  91285. * @param array defines the array to browse
  91286. * @param predicate defines the predicate to use
  91287. * @returns null if not found or the element
  91288. */
  91289. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91290. /**
  91291. * This method will return the name of the full name of the class, including its owning module (if any).
  91292. * 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).
  91293. * @param object the object to get the class name from
  91294. * @param isType defines if the object is actually a type
  91295. * @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.
  91296. * @ignorenaming
  91297. */
  91298. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91299. /**
  91300. * Returns a promise that resolves after the given amount of time.
  91301. * @param delay Number of milliseconds to delay
  91302. * @returns Promise that resolves after the given amount of time
  91303. */
  91304. static DelayAsync(delay: number): Promise<void>;
  91305. /**
  91306. * Gets the current gradient from an array of IValueGradient
  91307. * @param ratio defines the current ratio to get
  91308. * @param gradients defines the array of IValueGradient
  91309. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91310. */
  91311. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91312. }
  91313. /**
  91314. * This class is used to track a performance counter which is number based.
  91315. * The user has access to many properties which give statistics of different nature.
  91316. *
  91317. * The implementer can track two kinds of Performance Counter: time and count.
  91318. * 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.
  91319. * 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.
  91320. */
  91321. export class PerfCounter {
  91322. /**
  91323. * Gets or sets a global boolean to turn on and off all the counters
  91324. */
  91325. static Enabled: boolean;
  91326. /**
  91327. * Returns the smallest value ever
  91328. */
  91329. readonly min: number;
  91330. /**
  91331. * Returns the biggest value ever
  91332. */
  91333. readonly max: number;
  91334. /**
  91335. * Returns the average value since the performance counter is running
  91336. */
  91337. readonly average: number;
  91338. /**
  91339. * Returns the average value of the last second the counter was monitored
  91340. */
  91341. readonly lastSecAverage: number;
  91342. /**
  91343. * Returns the current value
  91344. */
  91345. readonly current: number;
  91346. /**
  91347. * Gets the accumulated total
  91348. */
  91349. readonly total: number;
  91350. /**
  91351. * Gets the total value count
  91352. */
  91353. readonly count: number;
  91354. /**
  91355. * Creates a new counter
  91356. */
  91357. constructor();
  91358. /**
  91359. * Call this method to start monitoring a new frame.
  91360. * 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.
  91361. */
  91362. fetchNewFrame(): void;
  91363. /**
  91364. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91365. * @param newCount the count value to add to the monitored count
  91366. * @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.
  91367. */
  91368. addCount(newCount: number, fetchResult: boolean): void;
  91369. /**
  91370. * Start monitoring this performance counter
  91371. */
  91372. beginMonitoring(): void;
  91373. /**
  91374. * Compute the time lapsed since the previous beginMonitoring() call.
  91375. * @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
  91376. */
  91377. endMonitoring(newFrame?: boolean): void;
  91378. private _fetchResult;
  91379. private _startMonitoringTime;
  91380. private _min;
  91381. private _max;
  91382. private _average;
  91383. private _current;
  91384. private _totalValueCount;
  91385. private _totalAccumulated;
  91386. private _lastSecAverage;
  91387. private _lastSecAccumulated;
  91388. private _lastSecTime;
  91389. private _lastSecValueCount;
  91390. }
  91391. /**
  91392. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91393. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91394. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91395. * @param name The name of the class, case should be preserved
  91396. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91397. */
  91398. export function className(name: string, module?: string): (target: Object) => void;
  91399. /**
  91400. * An implementation of a loop for asynchronous functions.
  91401. */
  91402. export class AsyncLoop {
  91403. /**
  91404. * Defines the number of iterations for the loop
  91405. */
  91406. iterations: number;
  91407. /**
  91408. * Defines the current index of the loop.
  91409. */
  91410. index: number;
  91411. private _done;
  91412. private _fn;
  91413. private _successCallback;
  91414. /**
  91415. * Constructor.
  91416. * @param iterations the number of iterations.
  91417. * @param func the function to run each iteration
  91418. * @param successCallback the callback that will be called upon succesful execution
  91419. * @param offset starting offset.
  91420. */
  91421. constructor(
  91422. /**
  91423. * Defines the number of iterations for the loop
  91424. */
  91425. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91426. /**
  91427. * Execute the next iteration. Must be called after the last iteration was finished.
  91428. */
  91429. executeNext(): void;
  91430. /**
  91431. * Break the loop and run the success callback.
  91432. */
  91433. breakLoop(): void;
  91434. /**
  91435. * Create and run an async loop.
  91436. * @param iterations the number of iterations.
  91437. * @param fn the function to run each iteration
  91438. * @param successCallback the callback that will be called upon succesful execution
  91439. * @param offset starting offset.
  91440. * @returns the created async loop object
  91441. */
  91442. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91443. /**
  91444. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91445. * @param iterations total number of iterations
  91446. * @param syncedIterations number of synchronous iterations in each async iteration.
  91447. * @param fn the function to call each iteration.
  91448. * @param callback a success call back that will be called when iterating stops.
  91449. * @param breakFunction a break condition (optional)
  91450. * @param timeout timeout settings for the setTimeout function. default - 0.
  91451. * @returns the created async loop object
  91452. */
  91453. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91454. }
  91455. }
  91456. declare module BABYLON {
  91457. /** @hidden */
  91458. export interface ICollisionCoordinator {
  91459. createCollider(): Collider;
  91460. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91461. init(scene: Scene): void;
  91462. }
  91463. /** @hidden */
  91464. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91465. private _scene;
  91466. private _scaledPosition;
  91467. private _scaledVelocity;
  91468. private _finalPosition;
  91469. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91470. createCollider(): Collider;
  91471. init(scene: Scene): void;
  91472. private _collideWithWorld;
  91473. }
  91474. }
  91475. declare module BABYLON {
  91476. /**
  91477. * Class used to manage all inputs for the scene.
  91478. */
  91479. export class InputManager {
  91480. /** The distance in pixel that you have to move to prevent some events */
  91481. static DragMovementThreshold: number;
  91482. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91483. static LongPressDelay: number;
  91484. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91485. static DoubleClickDelay: number;
  91486. /** If you need to check double click without raising a single click at first click, enable this flag */
  91487. static ExclusiveDoubleClickMode: boolean;
  91488. private _wheelEventName;
  91489. private _onPointerMove;
  91490. private _onPointerDown;
  91491. private _onPointerUp;
  91492. private _initClickEvent;
  91493. private _initActionManager;
  91494. private _delayedSimpleClick;
  91495. private _delayedSimpleClickTimeout;
  91496. private _previousDelayedSimpleClickTimeout;
  91497. private _meshPickProceed;
  91498. private _previousButtonPressed;
  91499. private _currentPickResult;
  91500. private _previousPickResult;
  91501. private _totalPointersPressed;
  91502. private _doubleClickOccured;
  91503. private _pointerOverMesh;
  91504. private _pickedDownMesh;
  91505. private _pickedUpMesh;
  91506. private _pointerX;
  91507. private _pointerY;
  91508. private _unTranslatedPointerX;
  91509. private _unTranslatedPointerY;
  91510. private _startingPointerPosition;
  91511. private _previousStartingPointerPosition;
  91512. private _startingPointerTime;
  91513. private _previousStartingPointerTime;
  91514. private _pointerCaptures;
  91515. private _onKeyDown;
  91516. private _onKeyUp;
  91517. private _onCanvasFocusObserver;
  91518. private _onCanvasBlurObserver;
  91519. private _scene;
  91520. /**
  91521. * Creates a new InputManager
  91522. * @param scene defines the hosting scene
  91523. */
  91524. constructor(scene: Scene);
  91525. /**
  91526. * Gets the mesh that is currently under the pointer
  91527. */
  91528. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91529. /**
  91530. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91531. */
  91532. readonly unTranslatedPointer: Vector2;
  91533. /**
  91534. * Gets or sets the current on-screen X position of the pointer
  91535. */
  91536. pointerX: number;
  91537. /**
  91538. * Gets or sets the current on-screen Y position of the pointer
  91539. */
  91540. pointerY: number;
  91541. private _updatePointerPosition;
  91542. private _processPointerMove;
  91543. private _setRayOnPointerInfo;
  91544. private _checkPrePointerObservable;
  91545. /**
  91546. * Use this method to simulate a pointer move on a mesh
  91547. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91548. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91549. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91550. */
  91551. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91552. /**
  91553. * Use this method to simulate a pointer down on a mesh
  91554. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91555. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91556. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91557. */
  91558. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91559. private _processPointerDown;
  91560. /** @hidden */
  91561. _isPointerSwiping(): boolean;
  91562. /**
  91563. * Use this method to simulate a pointer up on a mesh
  91564. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91565. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91566. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91567. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91568. */
  91569. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91570. private _processPointerUp;
  91571. /**
  91572. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91573. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91574. * @returns true if the pointer was captured
  91575. */
  91576. isPointerCaptured(pointerId?: number): boolean;
  91577. /**
  91578. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91579. * @param attachUp defines if you want to attach events to pointerup
  91580. * @param attachDown defines if you want to attach events to pointerdown
  91581. * @param attachMove defines if you want to attach events to pointermove
  91582. */
  91583. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91584. /**
  91585. * Detaches all event handlers
  91586. */
  91587. detachControl(): void;
  91588. /**
  91589. * Force the value of meshUnderPointer
  91590. * @param mesh defines the mesh to use
  91591. */
  91592. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91593. /**
  91594. * Gets the mesh under the pointer
  91595. * @returns a Mesh or null if no mesh is under the pointer
  91596. */
  91597. getPointerOverMesh(): Nullable<AbstractMesh>;
  91598. }
  91599. }
  91600. declare module BABYLON {
  91601. /**
  91602. * This class defines the direct association between an animation and a target
  91603. */
  91604. export class TargetedAnimation {
  91605. /**
  91606. * Animation to perform
  91607. */
  91608. animation: Animation;
  91609. /**
  91610. * Target to animate
  91611. */
  91612. target: any;
  91613. }
  91614. /**
  91615. * Use this class to create coordinated animations on multiple targets
  91616. */
  91617. export class AnimationGroup implements IDisposable {
  91618. /** The name of the animation group */
  91619. name: string;
  91620. private _scene;
  91621. private _targetedAnimations;
  91622. private _animatables;
  91623. private _from;
  91624. private _to;
  91625. private _isStarted;
  91626. private _isPaused;
  91627. private _speedRatio;
  91628. /**
  91629. * Gets or sets the unique id of the node
  91630. */
  91631. uniqueId: number;
  91632. /**
  91633. * This observable will notify when one animation have ended
  91634. */
  91635. onAnimationEndObservable: Observable<TargetedAnimation>;
  91636. /**
  91637. * Observer raised when one animation loops
  91638. */
  91639. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91640. /**
  91641. * This observable will notify when all animations have ended.
  91642. */
  91643. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91644. /**
  91645. * This observable will notify when all animations have paused.
  91646. */
  91647. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91648. /**
  91649. * This observable will notify when all animations are playing.
  91650. */
  91651. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91652. /**
  91653. * Gets the first frame
  91654. */
  91655. readonly from: number;
  91656. /**
  91657. * Gets the last frame
  91658. */
  91659. readonly to: number;
  91660. /**
  91661. * Define if the animations are started
  91662. */
  91663. readonly isStarted: boolean;
  91664. /**
  91665. * Gets a value indicating that the current group is playing
  91666. */
  91667. readonly isPlaying: boolean;
  91668. /**
  91669. * Gets or sets the speed ratio to use for all animations
  91670. */
  91671. /**
  91672. * Gets or sets the speed ratio to use for all animations
  91673. */
  91674. speedRatio: number;
  91675. /**
  91676. * Gets the targeted animations for this animation group
  91677. */
  91678. readonly targetedAnimations: Array<TargetedAnimation>;
  91679. /**
  91680. * returning the list of animatables controlled by this animation group.
  91681. */
  91682. readonly animatables: Array<Animatable>;
  91683. /**
  91684. * Instantiates a new Animation Group.
  91685. * This helps managing several animations at once.
  91686. * @see http://doc.babylonjs.com/how_to/group
  91687. * @param name Defines the name of the group
  91688. * @param scene Defines the scene the group belongs to
  91689. */
  91690. constructor(
  91691. /** The name of the animation group */
  91692. name: string, scene?: Nullable<Scene>);
  91693. /**
  91694. * Add an animation (with its target) in the group
  91695. * @param animation defines the animation we want to add
  91696. * @param target defines the target of the animation
  91697. * @returns the TargetedAnimation object
  91698. */
  91699. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91700. /**
  91701. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91702. * It can add constant keys at begin or end
  91703. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91704. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91705. * @returns the animation group
  91706. */
  91707. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91708. /**
  91709. * Start all animations on given targets
  91710. * @param loop defines if animations must loop
  91711. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91712. * @param from defines the from key (optional)
  91713. * @param to defines the to key (optional)
  91714. * @returns the current animation group
  91715. */
  91716. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91717. /**
  91718. * Pause all animations
  91719. * @returns the animation group
  91720. */
  91721. pause(): AnimationGroup;
  91722. /**
  91723. * Play all animations to initial state
  91724. * This function will start() the animations if they were not started or will restart() them if they were paused
  91725. * @param loop defines if animations must loop
  91726. * @returns the animation group
  91727. */
  91728. play(loop?: boolean): AnimationGroup;
  91729. /**
  91730. * Reset all animations to initial state
  91731. * @returns the animation group
  91732. */
  91733. reset(): AnimationGroup;
  91734. /**
  91735. * Restart animations from key 0
  91736. * @returns the animation group
  91737. */
  91738. restart(): AnimationGroup;
  91739. /**
  91740. * Stop all animations
  91741. * @returns the animation group
  91742. */
  91743. stop(): AnimationGroup;
  91744. /**
  91745. * Set animation weight for all animatables
  91746. * @param weight defines the weight to use
  91747. * @return the animationGroup
  91748. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91749. */
  91750. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91751. /**
  91752. * Synchronize and normalize all animatables with a source animatable
  91753. * @param root defines the root animatable to synchronize with
  91754. * @return the animationGroup
  91755. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91756. */
  91757. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91758. /**
  91759. * Goes to a specific frame in this animation group
  91760. * @param frame the frame number to go to
  91761. * @return the animationGroup
  91762. */
  91763. goToFrame(frame: number): AnimationGroup;
  91764. /**
  91765. * Dispose all associated resources
  91766. */
  91767. dispose(): void;
  91768. private _checkAnimationGroupEnded;
  91769. /**
  91770. * Clone the current animation group and returns a copy
  91771. * @param newName defines the name of the new group
  91772. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91773. * @returns the new aniamtion group
  91774. */
  91775. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91776. /**
  91777. * Returns a new AnimationGroup object parsed from the source provided.
  91778. * @param parsedAnimationGroup defines the source
  91779. * @param scene defines the scene that will receive the animationGroup
  91780. * @returns a new AnimationGroup
  91781. */
  91782. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91783. /**
  91784. * Returns the string "AnimationGroup"
  91785. * @returns "AnimationGroup"
  91786. */
  91787. getClassName(): string;
  91788. /**
  91789. * Creates a detailled string about the object
  91790. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91791. * @returns a string representing the object
  91792. */
  91793. toString(fullDetails?: boolean): string;
  91794. }
  91795. }
  91796. declare module BABYLON {
  91797. /**
  91798. * Define an interface for all classes that will hold resources
  91799. */
  91800. export interface IDisposable {
  91801. /**
  91802. * Releases all held resources
  91803. */
  91804. dispose(): void;
  91805. }
  91806. /** Interface defining initialization parameters for Scene class */
  91807. export interface SceneOptions {
  91808. /**
  91809. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91810. * It will improve performance when the number of geometries becomes important.
  91811. */
  91812. useGeometryUniqueIdsMap?: boolean;
  91813. /**
  91814. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91815. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91816. */
  91817. useMaterialMeshMap?: boolean;
  91818. /**
  91819. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91820. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91821. */
  91822. useClonedMeshhMap?: boolean;
  91823. }
  91824. /**
  91825. * Represents a scene to be rendered by the engine.
  91826. * @see http://doc.babylonjs.com/features/scene
  91827. */
  91828. export class Scene extends AbstractScene implements IAnimatable {
  91829. private static _uniqueIdCounter;
  91830. /** The fog is deactivated */
  91831. static readonly FOGMODE_NONE: number;
  91832. /** The fog density is following an exponential function */
  91833. static readonly FOGMODE_EXP: number;
  91834. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91835. static readonly FOGMODE_EXP2: number;
  91836. /** The fog density is following a linear function. */
  91837. static readonly FOGMODE_LINEAR: number;
  91838. /**
  91839. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91840. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91841. */
  91842. static MinDeltaTime: number;
  91843. /**
  91844. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91845. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91846. */
  91847. static MaxDeltaTime: number;
  91848. /**
  91849. * Factory used to create the default material.
  91850. * @param name The name of the material to create
  91851. * @param scene The scene to create the material for
  91852. * @returns The default material
  91853. */
  91854. static DefaultMaterialFactory(scene: Scene): Material;
  91855. /**
  91856. * Factory used to create the a collision coordinator.
  91857. * @returns The collision coordinator
  91858. */
  91859. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91860. /** @hidden */
  91861. _inputManager: InputManager;
  91862. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91863. cameraToUseForPointers: Nullable<Camera>;
  91864. /** @hidden */
  91865. readonly _isScene: boolean;
  91866. /**
  91867. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91868. */
  91869. autoClear: boolean;
  91870. /**
  91871. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91872. */
  91873. autoClearDepthAndStencil: boolean;
  91874. /**
  91875. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91876. */
  91877. clearColor: Color4;
  91878. /**
  91879. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91880. */
  91881. ambientColor: Color3;
  91882. /**
  91883. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91884. * It should only be one of the following (if not the default embedded one):
  91885. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91886. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91887. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91888. * The material properties need to be setup according to the type of texture in use.
  91889. */
  91890. environmentBRDFTexture: BaseTexture;
  91891. /** @hidden */
  91892. protected _environmentTexture: Nullable<BaseTexture>;
  91893. /**
  91894. * Texture used in all pbr material as the reflection texture.
  91895. * As in the majority of the scene they are the same (exception for multi room and so on),
  91896. * this is easier to reference from here than from all the materials.
  91897. */
  91898. /**
  91899. * Texture used in all pbr material as the reflection texture.
  91900. * As in the majority of the scene they are the same (exception for multi room and so on),
  91901. * this is easier to set here than in all the materials.
  91902. */
  91903. environmentTexture: Nullable<BaseTexture>;
  91904. /** @hidden */
  91905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91906. /**
  91907. * Default image processing configuration used either in the rendering
  91908. * Forward main pass or through the imageProcessingPostProcess if present.
  91909. * As in the majority of the scene they are the same (exception for multi camera),
  91910. * this is easier to reference from here than from all the materials and post process.
  91911. *
  91912. * No setter as we it is a shared configuration, you can set the values instead.
  91913. */
  91914. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91915. private _forceWireframe;
  91916. /**
  91917. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91918. */
  91919. forceWireframe: boolean;
  91920. private _forcePointsCloud;
  91921. /**
  91922. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91923. */
  91924. forcePointsCloud: boolean;
  91925. /**
  91926. * Gets or sets the active clipplane 1
  91927. */
  91928. clipPlane: Nullable<Plane>;
  91929. /**
  91930. * Gets or sets the active clipplane 2
  91931. */
  91932. clipPlane2: Nullable<Plane>;
  91933. /**
  91934. * Gets or sets the active clipplane 3
  91935. */
  91936. clipPlane3: Nullable<Plane>;
  91937. /**
  91938. * Gets or sets the active clipplane 4
  91939. */
  91940. clipPlane4: Nullable<Plane>;
  91941. /**
  91942. * Gets or sets a boolean indicating if animations are enabled
  91943. */
  91944. animationsEnabled: boolean;
  91945. private _animationPropertiesOverride;
  91946. /**
  91947. * Gets or sets the animation properties override
  91948. */
  91949. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91950. /**
  91951. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91952. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91953. */
  91954. useConstantAnimationDeltaTime: boolean;
  91955. /**
  91956. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91957. * Please note that it requires to run a ray cast through the scene on every frame
  91958. */
  91959. constantlyUpdateMeshUnderPointer: boolean;
  91960. /**
  91961. * Defines the HTML cursor to use when hovering over interactive elements
  91962. */
  91963. hoverCursor: string;
  91964. /**
  91965. * Defines the HTML default cursor to use (empty by default)
  91966. */
  91967. defaultCursor: string;
  91968. /**
  91969. * This is used to call preventDefault() on pointer down
  91970. * in order to block unwanted artifacts like system double clicks
  91971. */
  91972. preventDefaultOnPointerDown: boolean;
  91973. /**
  91974. * This is used to call preventDefault() on pointer up
  91975. * in order to block unwanted artifacts like system double clicks
  91976. */
  91977. preventDefaultOnPointerUp: boolean;
  91978. /**
  91979. * Gets or sets user defined metadata
  91980. */
  91981. metadata: any;
  91982. /**
  91983. * For internal use only. Please do not use.
  91984. */
  91985. reservedDataStore: any;
  91986. /**
  91987. * Gets the name of the plugin used to load this scene (null by default)
  91988. */
  91989. loadingPluginName: string;
  91990. /**
  91991. * Use this array to add regular expressions used to disable offline support for specific urls
  91992. */
  91993. disableOfflineSupportExceptionRules: RegExp[];
  91994. /**
  91995. * An event triggered when the scene is disposed.
  91996. */
  91997. onDisposeObservable: Observable<Scene>;
  91998. private _onDisposeObserver;
  91999. /** Sets a function to be executed when this scene is disposed. */
  92000. onDispose: () => void;
  92001. /**
  92002. * An event triggered before rendering the scene (right after animations and physics)
  92003. */
  92004. onBeforeRenderObservable: Observable<Scene>;
  92005. private _onBeforeRenderObserver;
  92006. /** Sets a function to be executed before rendering this scene */
  92007. beforeRender: Nullable<() => void>;
  92008. /**
  92009. * An event triggered after rendering the scene
  92010. */
  92011. onAfterRenderObservable: Observable<Scene>;
  92012. private _onAfterRenderObserver;
  92013. /** Sets a function to be executed after rendering this scene */
  92014. afterRender: Nullable<() => void>;
  92015. /**
  92016. * An event triggered before animating the scene
  92017. */
  92018. onBeforeAnimationsObservable: Observable<Scene>;
  92019. /**
  92020. * An event triggered after animations processing
  92021. */
  92022. onAfterAnimationsObservable: Observable<Scene>;
  92023. /**
  92024. * An event triggered before draw calls are ready to be sent
  92025. */
  92026. onBeforeDrawPhaseObservable: Observable<Scene>;
  92027. /**
  92028. * An event triggered after draw calls have been sent
  92029. */
  92030. onAfterDrawPhaseObservable: Observable<Scene>;
  92031. /**
  92032. * An event triggered when the scene is ready
  92033. */
  92034. onReadyObservable: Observable<Scene>;
  92035. /**
  92036. * An event triggered before rendering a camera
  92037. */
  92038. onBeforeCameraRenderObservable: Observable<Camera>;
  92039. private _onBeforeCameraRenderObserver;
  92040. /** Sets a function to be executed before rendering a camera*/
  92041. beforeCameraRender: () => void;
  92042. /**
  92043. * An event triggered after rendering a camera
  92044. */
  92045. onAfterCameraRenderObservable: Observable<Camera>;
  92046. private _onAfterCameraRenderObserver;
  92047. /** Sets a function to be executed after rendering a camera*/
  92048. afterCameraRender: () => void;
  92049. /**
  92050. * An event triggered when active meshes evaluation is about to start
  92051. */
  92052. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92053. /**
  92054. * An event triggered when active meshes evaluation is done
  92055. */
  92056. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92057. /**
  92058. * An event triggered when particles rendering is about to start
  92059. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92060. */
  92061. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92062. /**
  92063. * An event triggered when particles rendering is done
  92064. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92065. */
  92066. onAfterParticlesRenderingObservable: Observable<Scene>;
  92067. /**
  92068. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92069. */
  92070. onDataLoadedObservable: Observable<Scene>;
  92071. /**
  92072. * An event triggered when a camera is created
  92073. */
  92074. onNewCameraAddedObservable: Observable<Camera>;
  92075. /**
  92076. * An event triggered when a camera is removed
  92077. */
  92078. onCameraRemovedObservable: Observable<Camera>;
  92079. /**
  92080. * An event triggered when a light is created
  92081. */
  92082. onNewLightAddedObservable: Observable<Light>;
  92083. /**
  92084. * An event triggered when a light is removed
  92085. */
  92086. onLightRemovedObservable: Observable<Light>;
  92087. /**
  92088. * An event triggered when a geometry is created
  92089. */
  92090. onNewGeometryAddedObservable: Observable<Geometry>;
  92091. /**
  92092. * An event triggered when a geometry is removed
  92093. */
  92094. onGeometryRemovedObservable: Observable<Geometry>;
  92095. /**
  92096. * An event triggered when a transform node is created
  92097. */
  92098. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92099. /**
  92100. * An event triggered when a transform node is removed
  92101. */
  92102. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92103. /**
  92104. * An event triggered when a mesh is created
  92105. */
  92106. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92107. /**
  92108. * An event triggered when a mesh is removed
  92109. */
  92110. onMeshRemovedObservable: Observable<AbstractMesh>;
  92111. /**
  92112. * An event triggered when a skeleton is created
  92113. */
  92114. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92115. /**
  92116. * An event triggered when a skeleton is removed
  92117. */
  92118. onSkeletonRemovedObservable: Observable<Skeleton>;
  92119. /**
  92120. * An event triggered when a material is created
  92121. */
  92122. onNewMaterialAddedObservable: Observable<Material>;
  92123. /**
  92124. * An event triggered when a material is removed
  92125. */
  92126. onMaterialRemovedObservable: Observable<Material>;
  92127. /**
  92128. * An event triggered when a texture is created
  92129. */
  92130. onNewTextureAddedObservable: Observable<BaseTexture>;
  92131. /**
  92132. * An event triggered when a texture is removed
  92133. */
  92134. onTextureRemovedObservable: Observable<BaseTexture>;
  92135. /**
  92136. * An event triggered when render targets are about to be rendered
  92137. * Can happen multiple times per frame.
  92138. */
  92139. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92140. /**
  92141. * An event triggered when render targets were rendered.
  92142. * Can happen multiple times per frame.
  92143. */
  92144. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92145. /**
  92146. * An event triggered before calculating deterministic simulation step
  92147. */
  92148. onBeforeStepObservable: Observable<Scene>;
  92149. /**
  92150. * An event triggered after calculating deterministic simulation step
  92151. */
  92152. onAfterStepObservable: Observable<Scene>;
  92153. /**
  92154. * An event triggered when the activeCamera property is updated
  92155. */
  92156. onActiveCameraChanged: Observable<Scene>;
  92157. /**
  92158. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92159. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92160. * 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)
  92161. */
  92162. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92163. /**
  92164. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92165. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92166. * 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)
  92167. */
  92168. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92169. /**
  92170. * This Observable will when a mesh has been imported into the scene.
  92171. */
  92172. onMeshImportedObservable: Observable<AbstractMesh>;
  92173. /**
  92174. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92175. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92176. */
  92177. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92178. /** @hidden */
  92179. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92180. /**
  92181. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92182. */
  92183. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92184. /**
  92185. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92186. */
  92187. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92188. /**
  92189. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92190. */
  92191. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92192. /** Callback called when a pointer move is detected */
  92193. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92194. /** Callback called when a pointer down is detected */
  92195. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92196. /** Callback called when a pointer up is detected */
  92197. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92198. /** Callback called when a pointer pick is detected */
  92199. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92200. /**
  92201. * 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).
  92202. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92203. */
  92204. onPrePointerObservable: Observable<PointerInfoPre>;
  92205. /**
  92206. * Observable event triggered each time an input event is received from the rendering canvas
  92207. */
  92208. onPointerObservable: Observable<PointerInfo>;
  92209. /**
  92210. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92211. */
  92212. readonly unTranslatedPointer: Vector2;
  92213. /**
  92214. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92215. */
  92216. static DragMovementThreshold: number;
  92217. /**
  92218. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92219. */
  92220. static LongPressDelay: number;
  92221. /**
  92222. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92223. */
  92224. static DoubleClickDelay: number;
  92225. /** If you need to check double click without raising a single click at first click, enable this flag */
  92226. static ExclusiveDoubleClickMode: boolean;
  92227. /** @hidden */
  92228. _mirroredCameraPosition: Nullable<Vector3>;
  92229. /**
  92230. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92231. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92232. */
  92233. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92234. /**
  92235. * Observable event triggered each time an keyboard event is received from the hosting window
  92236. */
  92237. onKeyboardObservable: Observable<KeyboardInfo>;
  92238. private _useRightHandedSystem;
  92239. /**
  92240. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92241. */
  92242. useRightHandedSystem: boolean;
  92243. private _timeAccumulator;
  92244. private _currentStepId;
  92245. private _currentInternalStep;
  92246. /**
  92247. * Sets the step Id used by deterministic lock step
  92248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92249. * @param newStepId defines the step Id
  92250. */
  92251. setStepId(newStepId: number): void;
  92252. /**
  92253. * Gets the step Id used by deterministic lock step
  92254. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92255. * @returns the step Id
  92256. */
  92257. getStepId(): number;
  92258. /**
  92259. * Gets the internal step used by deterministic lock step
  92260. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92261. * @returns the internal step
  92262. */
  92263. getInternalStep(): number;
  92264. private _fogEnabled;
  92265. /**
  92266. * Gets or sets a boolean indicating if fog is enabled on this scene
  92267. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92268. * (Default is true)
  92269. */
  92270. fogEnabled: boolean;
  92271. private _fogMode;
  92272. /**
  92273. * Gets or sets the fog mode to use
  92274. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92275. * | mode | value |
  92276. * | --- | --- |
  92277. * | FOGMODE_NONE | 0 |
  92278. * | FOGMODE_EXP | 1 |
  92279. * | FOGMODE_EXP2 | 2 |
  92280. * | FOGMODE_LINEAR | 3 |
  92281. */
  92282. fogMode: number;
  92283. /**
  92284. * Gets or sets the fog color to use
  92285. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92286. * (Default is Color3(0.2, 0.2, 0.3))
  92287. */
  92288. fogColor: Color3;
  92289. /**
  92290. * Gets or sets the fog density to use
  92291. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92292. * (Default is 0.1)
  92293. */
  92294. fogDensity: number;
  92295. /**
  92296. * Gets or sets the fog start distance to use
  92297. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92298. * (Default is 0)
  92299. */
  92300. fogStart: number;
  92301. /**
  92302. * Gets or sets the fog end distance to use
  92303. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92304. * (Default is 1000)
  92305. */
  92306. fogEnd: number;
  92307. private _shadowsEnabled;
  92308. /**
  92309. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92310. */
  92311. shadowsEnabled: boolean;
  92312. private _lightsEnabled;
  92313. /**
  92314. * Gets or sets a boolean indicating if lights are enabled on this scene
  92315. */
  92316. lightsEnabled: boolean;
  92317. /** All of the active cameras added to this scene. */
  92318. activeCameras: Camera[];
  92319. /** @hidden */
  92320. _activeCamera: Nullable<Camera>;
  92321. /** Gets or sets the current active camera */
  92322. activeCamera: Nullable<Camera>;
  92323. private _defaultMaterial;
  92324. /** The default material used on meshes when no material is affected */
  92325. /** The default material used on meshes when no material is affected */
  92326. defaultMaterial: Material;
  92327. private _texturesEnabled;
  92328. /**
  92329. * Gets or sets a boolean indicating if textures are enabled on this scene
  92330. */
  92331. texturesEnabled: boolean;
  92332. /**
  92333. * Gets or sets a boolean indicating if particles are enabled on this scene
  92334. */
  92335. particlesEnabled: boolean;
  92336. /**
  92337. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92338. */
  92339. spritesEnabled: boolean;
  92340. private _skeletonsEnabled;
  92341. /**
  92342. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92343. */
  92344. skeletonsEnabled: boolean;
  92345. /**
  92346. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92347. */
  92348. lensFlaresEnabled: boolean;
  92349. /**
  92350. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92351. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92352. */
  92353. collisionsEnabled: boolean;
  92354. private _collisionCoordinator;
  92355. /** @hidden */
  92356. readonly collisionCoordinator: ICollisionCoordinator;
  92357. /**
  92358. * Defines the gravity applied to this scene (used only for collisions)
  92359. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92360. */
  92361. gravity: Vector3;
  92362. /**
  92363. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92364. */
  92365. postProcessesEnabled: boolean;
  92366. /**
  92367. * The list of postprocesses added to the scene
  92368. */
  92369. postProcesses: PostProcess[];
  92370. /**
  92371. * Gets the current postprocess manager
  92372. */
  92373. postProcessManager: PostProcessManager;
  92374. /**
  92375. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92376. */
  92377. renderTargetsEnabled: boolean;
  92378. /**
  92379. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92380. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92381. */
  92382. dumpNextRenderTargets: boolean;
  92383. /**
  92384. * The list of user defined render targets added to the scene
  92385. */
  92386. customRenderTargets: RenderTargetTexture[];
  92387. /**
  92388. * Defines if texture loading must be delayed
  92389. * If true, textures will only be loaded when they need to be rendered
  92390. */
  92391. useDelayedTextureLoading: boolean;
  92392. /**
  92393. * Gets the list of meshes imported to the scene through SceneLoader
  92394. */
  92395. importedMeshesFiles: String[];
  92396. /**
  92397. * Gets or sets a boolean indicating if probes are enabled on this scene
  92398. */
  92399. probesEnabled: boolean;
  92400. /**
  92401. * Gets or sets the current offline provider to use to store scene data
  92402. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92403. */
  92404. offlineProvider: IOfflineProvider;
  92405. /**
  92406. * Gets or sets the action manager associated with the scene
  92407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92408. */
  92409. actionManager: AbstractActionManager;
  92410. private _meshesForIntersections;
  92411. /**
  92412. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92413. */
  92414. proceduralTexturesEnabled: boolean;
  92415. private _engine;
  92416. private _totalVertices;
  92417. /** @hidden */
  92418. _activeIndices: PerfCounter;
  92419. /** @hidden */
  92420. _activeParticles: PerfCounter;
  92421. /** @hidden */
  92422. _activeBones: PerfCounter;
  92423. private _animationRatio;
  92424. /** @hidden */
  92425. _animationTimeLast: number;
  92426. /** @hidden */
  92427. _animationTime: number;
  92428. /**
  92429. * Gets or sets a general scale for animation speed
  92430. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92431. */
  92432. animationTimeScale: number;
  92433. /** @hidden */
  92434. _cachedMaterial: Nullable<Material>;
  92435. /** @hidden */
  92436. _cachedEffect: Nullable<Effect>;
  92437. /** @hidden */
  92438. _cachedVisibility: Nullable<number>;
  92439. private _renderId;
  92440. private _frameId;
  92441. private _executeWhenReadyTimeoutId;
  92442. private _intermediateRendering;
  92443. private _viewUpdateFlag;
  92444. private _projectionUpdateFlag;
  92445. /** @hidden */
  92446. _toBeDisposed: Nullable<IDisposable>[];
  92447. private _activeRequests;
  92448. /** @hidden */
  92449. _pendingData: any[];
  92450. private _isDisposed;
  92451. /**
  92452. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92453. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92454. */
  92455. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92456. private _activeMeshes;
  92457. private _processedMaterials;
  92458. private _renderTargets;
  92459. /** @hidden */
  92460. _activeParticleSystems: SmartArray<IParticleSystem>;
  92461. private _activeSkeletons;
  92462. private _softwareSkinnedMeshes;
  92463. private _renderingManager;
  92464. /** @hidden */
  92465. _activeAnimatables: Animatable[];
  92466. private _transformMatrix;
  92467. private _sceneUbo;
  92468. /** @hidden */
  92469. _viewMatrix: Matrix;
  92470. private _projectionMatrix;
  92471. /** @hidden */
  92472. _forcedViewPosition: Nullable<Vector3>;
  92473. /** @hidden */
  92474. _frustumPlanes: Plane[];
  92475. /**
  92476. * Gets the list of frustum planes (built from the active camera)
  92477. */
  92478. readonly frustumPlanes: Plane[];
  92479. /**
  92480. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92481. * This is useful if there are more lights that the maximum simulteanous authorized
  92482. */
  92483. requireLightSorting: boolean;
  92484. /** @hidden */
  92485. readonly useMaterialMeshMap: boolean;
  92486. /** @hidden */
  92487. readonly useClonedMeshhMap: boolean;
  92488. private _externalData;
  92489. private _uid;
  92490. /**
  92491. * @hidden
  92492. * Backing store of defined scene components.
  92493. */
  92494. _components: ISceneComponent[];
  92495. /**
  92496. * @hidden
  92497. * Backing store of defined scene components.
  92498. */
  92499. _serializableComponents: ISceneSerializableComponent[];
  92500. /**
  92501. * List of components to register on the next registration step.
  92502. */
  92503. private _transientComponents;
  92504. /**
  92505. * Registers the transient components if needed.
  92506. */
  92507. private _registerTransientComponents;
  92508. /**
  92509. * @hidden
  92510. * Add a component to the scene.
  92511. * Note that the ccomponent could be registered on th next frame if this is called after
  92512. * the register component stage.
  92513. * @param component Defines the component to add to the scene
  92514. */
  92515. _addComponent(component: ISceneComponent): void;
  92516. /**
  92517. * @hidden
  92518. * Gets a component from the scene.
  92519. * @param name defines the name of the component to retrieve
  92520. * @returns the component or null if not present
  92521. */
  92522. _getComponent(name: string): Nullable<ISceneComponent>;
  92523. /**
  92524. * @hidden
  92525. * Defines the actions happening before camera updates.
  92526. */
  92527. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92528. /**
  92529. * @hidden
  92530. * Defines the actions happening before clear the canvas.
  92531. */
  92532. _beforeClearStage: Stage<SimpleStageAction>;
  92533. /**
  92534. * @hidden
  92535. * Defines the actions when collecting render targets for the frame.
  92536. */
  92537. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92538. /**
  92539. * @hidden
  92540. * Defines the actions happening for one camera in the frame.
  92541. */
  92542. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92543. /**
  92544. * @hidden
  92545. * Defines the actions happening during the per mesh ready checks.
  92546. */
  92547. _isReadyForMeshStage: Stage<MeshStageAction>;
  92548. /**
  92549. * @hidden
  92550. * Defines the actions happening before evaluate active mesh checks.
  92551. */
  92552. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92553. /**
  92554. * @hidden
  92555. * Defines the actions happening during the evaluate sub mesh checks.
  92556. */
  92557. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92558. /**
  92559. * @hidden
  92560. * Defines the actions happening during the active mesh stage.
  92561. */
  92562. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92563. /**
  92564. * @hidden
  92565. * Defines the actions happening during the per camera render target step.
  92566. */
  92567. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92568. /**
  92569. * @hidden
  92570. * Defines the actions happening just before the active camera is drawing.
  92571. */
  92572. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92573. /**
  92574. * @hidden
  92575. * Defines the actions happening just before a render target is drawing.
  92576. */
  92577. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92578. /**
  92579. * @hidden
  92580. * Defines the actions happening just before a rendering group is drawing.
  92581. */
  92582. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92583. /**
  92584. * @hidden
  92585. * Defines the actions happening just before a mesh is drawing.
  92586. */
  92587. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92588. /**
  92589. * @hidden
  92590. * Defines the actions happening just after a mesh has been drawn.
  92591. */
  92592. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92593. /**
  92594. * @hidden
  92595. * Defines the actions happening just after a rendering group has been drawn.
  92596. */
  92597. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92598. /**
  92599. * @hidden
  92600. * Defines the actions happening just after the active camera has been drawn.
  92601. */
  92602. _afterCameraDrawStage: Stage<CameraStageAction>;
  92603. /**
  92604. * @hidden
  92605. * Defines the actions happening just after a render target has been drawn.
  92606. */
  92607. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92608. /**
  92609. * @hidden
  92610. * Defines the actions happening just after rendering all cameras and computing intersections.
  92611. */
  92612. _afterRenderStage: Stage<SimpleStageAction>;
  92613. /**
  92614. * @hidden
  92615. * Defines the actions happening when a pointer move event happens.
  92616. */
  92617. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92618. /**
  92619. * @hidden
  92620. * Defines the actions happening when a pointer down event happens.
  92621. */
  92622. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92623. /**
  92624. * @hidden
  92625. * Defines the actions happening when a pointer up event happens.
  92626. */
  92627. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92628. /**
  92629. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92630. */
  92631. private geometriesByUniqueId;
  92632. /**
  92633. * Creates a new Scene
  92634. * @param engine defines the engine to use to render this scene
  92635. * @param options defines the scene options
  92636. */
  92637. constructor(engine: Engine, options?: SceneOptions);
  92638. /**
  92639. * Gets a string idenfifying the name of the class
  92640. * @returns "Scene" string
  92641. */
  92642. getClassName(): string;
  92643. private _defaultMeshCandidates;
  92644. /**
  92645. * @hidden
  92646. */
  92647. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92648. private _defaultSubMeshCandidates;
  92649. /**
  92650. * @hidden
  92651. */
  92652. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92653. /**
  92654. * Sets the default candidate providers for the scene.
  92655. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92656. * and getCollidingSubMeshCandidates to their default function
  92657. */
  92658. setDefaultCandidateProviders(): void;
  92659. /**
  92660. * Gets the mesh that is currently under the pointer
  92661. */
  92662. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92663. /**
  92664. * Gets or sets the current on-screen X position of the pointer
  92665. */
  92666. pointerX: number;
  92667. /**
  92668. * Gets or sets the current on-screen Y position of the pointer
  92669. */
  92670. pointerY: number;
  92671. /**
  92672. * Gets the cached material (ie. the latest rendered one)
  92673. * @returns the cached material
  92674. */
  92675. getCachedMaterial(): Nullable<Material>;
  92676. /**
  92677. * Gets the cached effect (ie. the latest rendered one)
  92678. * @returns the cached effect
  92679. */
  92680. getCachedEffect(): Nullable<Effect>;
  92681. /**
  92682. * Gets the cached visibility state (ie. the latest rendered one)
  92683. * @returns the cached visibility state
  92684. */
  92685. getCachedVisibility(): Nullable<number>;
  92686. /**
  92687. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92688. * @param material defines the current material
  92689. * @param effect defines the current effect
  92690. * @param visibility defines the current visibility state
  92691. * @returns true if one parameter is not cached
  92692. */
  92693. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92694. /**
  92695. * Gets the engine associated with the scene
  92696. * @returns an Engine
  92697. */
  92698. getEngine(): Engine;
  92699. /**
  92700. * Gets the total number of vertices rendered per frame
  92701. * @returns the total number of vertices rendered per frame
  92702. */
  92703. getTotalVertices(): number;
  92704. /**
  92705. * Gets the performance counter for total vertices
  92706. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92707. */
  92708. readonly totalVerticesPerfCounter: PerfCounter;
  92709. /**
  92710. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92711. * @returns the total number of active indices rendered per frame
  92712. */
  92713. getActiveIndices(): number;
  92714. /**
  92715. * Gets the performance counter for active indices
  92716. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92717. */
  92718. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92719. /**
  92720. * Gets the total number of active particles rendered per frame
  92721. * @returns the total number of active particles rendered per frame
  92722. */
  92723. getActiveParticles(): number;
  92724. /**
  92725. * Gets the performance counter for active particles
  92726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92727. */
  92728. readonly activeParticlesPerfCounter: PerfCounter;
  92729. /**
  92730. * Gets the total number of active bones rendered per frame
  92731. * @returns the total number of active bones rendered per frame
  92732. */
  92733. getActiveBones(): number;
  92734. /**
  92735. * Gets the performance counter for active bones
  92736. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92737. */
  92738. readonly activeBonesPerfCounter: PerfCounter;
  92739. /**
  92740. * Gets the array of active meshes
  92741. * @returns an array of AbstractMesh
  92742. */
  92743. getActiveMeshes(): SmartArray<AbstractMesh>;
  92744. /**
  92745. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92746. * @returns a number
  92747. */
  92748. getAnimationRatio(): number;
  92749. /**
  92750. * Gets an unique Id for the current render phase
  92751. * @returns a number
  92752. */
  92753. getRenderId(): number;
  92754. /**
  92755. * Gets an unique Id for the current frame
  92756. * @returns a number
  92757. */
  92758. getFrameId(): number;
  92759. /** Call this function if you want to manually increment the render Id*/
  92760. incrementRenderId(): void;
  92761. private _createUbo;
  92762. /**
  92763. * Use this method to simulate a pointer move on a mesh
  92764. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92765. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92766. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92767. * @returns the current scene
  92768. */
  92769. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92770. /**
  92771. * Use this method to simulate a pointer down on a mesh
  92772. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92773. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92774. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92775. * @returns the current scene
  92776. */
  92777. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92778. /**
  92779. * Use this method to simulate a pointer up on a mesh
  92780. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92781. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92782. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92783. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92784. * @returns the current scene
  92785. */
  92786. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92787. /**
  92788. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92789. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92790. * @returns true if the pointer was captured
  92791. */
  92792. isPointerCaptured(pointerId?: number): boolean;
  92793. /**
  92794. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92795. * @param attachUp defines if you want to attach events to pointerup
  92796. * @param attachDown defines if you want to attach events to pointerdown
  92797. * @param attachMove defines if you want to attach events to pointermove
  92798. */
  92799. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92800. /** Detaches all event handlers*/
  92801. detachControl(): void;
  92802. /**
  92803. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92804. * Delay loaded resources are not taking in account
  92805. * @return true if all required resources are ready
  92806. */
  92807. isReady(): boolean;
  92808. /** Resets all cached information relative to material (including effect and visibility) */
  92809. resetCachedMaterial(): void;
  92810. /**
  92811. * Registers a function to be called before every frame render
  92812. * @param func defines the function to register
  92813. */
  92814. registerBeforeRender(func: () => void): void;
  92815. /**
  92816. * Unregisters a function called before every frame render
  92817. * @param func defines the function to unregister
  92818. */
  92819. unregisterBeforeRender(func: () => void): void;
  92820. /**
  92821. * Registers a function to be called after every frame render
  92822. * @param func defines the function to register
  92823. */
  92824. registerAfterRender(func: () => void): void;
  92825. /**
  92826. * Unregisters a function called after every frame render
  92827. * @param func defines the function to unregister
  92828. */
  92829. unregisterAfterRender(func: () => void): void;
  92830. private _executeOnceBeforeRender;
  92831. /**
  92832. * The provided function will run before render once and will be disposed afterwards.
  92833. * A timeout delay can be provided so that the function will be executed in N ms.
  92834. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92835. * @param func The function to be executed.
  92836. * @param timeout optional delay in ms
  92837. */
  92838. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92839. /** @hidden */
  92840. _addPendingData(data: any): void;
  92841. /** @hidden */
  92842. _removePendingData(data: any): void;
  92843. /**
  92844. * Returns the number of items waiting to be loaded
  92845. * @returns the number of items waiting to be loaded
  92846. */
  92847. getWaitingItemsCount(): number;
  92848. /**
  92849. * Returns a boolean indicating if the scene is still loading data
  92850. */
  92851. readonly isLoading: boolean;
  92852. /**
  92853. * Registers a function to be executed when the scene is ready
  92854. * @param {Function} func - the function to be executed
  92855. */
  92856. executeWhenReady(func: () => void): void;
  92857. /**
  92858. * Returns a promise that resolves when the scene is ready
  92859. * @returns A promise that resolves when the scene is ready
  92860. */
  92861. whenReadyAsync(): Promise<void>;
  92862. /** @hidden */
  92863. _checkIsReady(): void;
  92864. /**
  92865. * Gets all animatable attached to the scene
  92866. */
  92867. readonly animatables: Animatable[];
  92868. /**
  92869. * Resets the last animation time frame.
  92870. * Useful to override when animations start running when loading a scene for the first time.
  92871. */
  92872. resetLastAnimationTimeFrame(): void;
  92873. /**
  92874. * Gets the current view matrix
  92875. * @returns a Matrix
  92876. */
  92877. getViewMatrix(): Matrix;
  92878. /**
  92879. * Gets the current projection matrix
  92880. * @returns a Matrix
  92881. */
  92882. getProjectionMatrix(): Matrix;
  92883. /**
  92884. * Gets the current transform matrix
  92885. * @returns a Matrix made of View * Projection
  92886. */
  92887. getTransformMatrix(): Matrix;
  92888. /**
  92889. * Sets the current transform matrix
  92890. * @param viewL defines the View matrix to use
  92891. * @param projectionL defines the Projection matrix to use
  92892. * @param viewR defines the right View matrix to use (if provided)
  92893. * @param projectionR defines the right Projection matrix to use (if provided)
  92894. */
  92895. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92896. /**
  92897. * Gets the uniform buffer used to store scene data
  92898. * @returns a UniformBuffer
  92899. */
  92900. getSceneUniformBuffer(): UniformBuffer;
  92901. /**
  92902. * Gets an unique (relatively to the current scene) Id
  92903. * @returns an unique number for the scene
  92904. */
  92905. getUniqueId(): number;
  92906. /**
  92907. * Add a mesh to the list of scene's meshes
  92908. * @param newMesh defines the mesh to add
  92909. * @param recursive if all child meshes should also be added to the scene
  92910. */
  92911. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92912. /**
  92913. * Remove a mesh for the list of scene's meshes
  92914. * @param toRemove defines the mesh to remove
  92915. * @param recursive if all child meshes should also be removed from the scene
  92916. * @returns the index where the mesh was in the mesh list
  92917. */
  92918. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92919. /**
  92920. * Add a transform node to the list of scene's transform nodes
  92921. * @param newTransformNode defines the transform node to add
  92922. */
  92923. addTransformNode(newTransformNode: TransformNode): void;
  92924. /**
  92925. * Remove a transform node for the list of scene's transform nodes
  92926. * @param toRemove defines the transform node to remove
  92927. * @returns the index where the transform node was in the transform node list
  92928. */
  92929. removeTransformNode(toRemove: TransformNode): number;
  92930. /**
  92931. * Remove a skeleton for the list of scene's skeletons
  92932. * @param toRemove defines the skeleton to remove
  92933. * @returns the index where the skeleton was in the skeleton list
  92934. */
  92935. removeSkeleton(toRemove: Skeleton): number;
  92936. /**
  92937. * Remove a morph target for the list of scene's morph targets
  92938. * @param toRemove defines the morph target to remove
  92939. * @returns the index where the morph target was in the morph target list
  92940. */
  92941. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92942. /**
  92943. * Remove a light for the list of scene's lights
  92944. * @param toRemove defines the light to remove
  92945. * @returns the index where the light was in the light list
  92946. */
  92947. removeLight(toRemove: Light): number;
  92948. /**
  92949. * Remove a camera for the list of scene's cameras
  92950. * @param toRemove defines the camera to remove
  92951. * @returns the index where the camera was in the camera list
  92952. */
  92953. removeCamera(toRemove: Camera): number;
  92954. /**
  92955. * Remove a particle system for the list of scene's particle systems
  92956. * @param toRemove defines the particle system to remove
  92957. * @returns the index where the particle system was in the particle system list
  92958. */
  92959. removeParticleSystem(toRemove: IParticleSystem): number;
  92960. /**
  92961. * Remove a animation for the list of scene's animations
  92962. * @param toRemove defines the animation to remove
  92963. * @returns the index where the animation was in the animation list
  92964. */
  92965. removeAnimation(toRemove: Animation): number;
  92966. /**
  92967. * Will stop the animation of the given target
  92968. * @param target - the target
  92969. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  92970. * @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)
  92971. */
  92972. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  92973. /**
  92974. * Removes the given animation group from this scene.
  92975. * @param toRemove The animation group to remove
  92976. * @returns The index of the removed animation group
  92977. */
  92978. removeAnimationGroup(toRemove: AnimationGroup): number;
  92979. /**
  92980. * Removes the given multi-material from this scene.
  92981. * @param toRemove The multi-material to remove
  92982. * @returns The index of the removed multi-material
  92983. */
  92984. removeMultiMaterial(toRemove: MultiMaterial): number;
  92985. /**
  92986. * Removes the given material from this scene.
  92987. * @param toRemove The material to remove
  92988. * @returns The index of the removed material
  92989. */
  92990. removeMaterial(toRemove: Material): number;
  92991. /**
  92992. * Removes the given action manager from this scene.
  92993. * @param toRemove The action manager to remove
  92994. * @returns The index of the removed action manager
  92995. */
  92996. removeActionManager(toRemove: AbstractActionManager): number;
  92997. /**
  92998. * Removes the given texture from this scene.
  92999. * @param toRemove The texture to remove
  93000. * @returns The index of the removed texture
  93001. */
  93002. removeTexture(toRemove: BaseTexture): number;
  93003. /**
  93004. * Adds the given light to this scene
  93005. * @param newLight The light to add
  93006. */
  93007. addLight(newLight: Light): void;
  93008. /**
  93009. * Sorts the list list based on light priorities
  93010. */
  93011. sortLightsByPriority(): void;
  93012. /**
  93013. * Adds the given camera to this scene
  93014. * @param newCamera The camera to add
  93015. */
  93016. addCamera(newCamera: Camera): void;
  93017. /**
  93018. * Adds the given skeleton to this scene
  93019. * @param newSkeleton The skeleton to add
  93020. */
  93021. addSkeleton(newSkeleton: Skeleton): void;
  93022. /**
  93023. * Adds the given particle system to this scene
  93024. * @param newParticleSystem The particle system to add
  93025. */
  93026. addParticleSystem(newParticleSystem: IParticleSystem): void;
  93027. /**
  93028. * Adds the given animation to this scene
  93029. * @param newAnimation The animation to add
  93030. */
  93031. addAnimation(newAnimation: Animation): void;
  93032. /**
  93033. * Adds the given animation group to this scene.
  93034. * @param newAnimationGroup The animation group to add
  93035. */
  93036. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93037. /**
  93038. * Adds the given multi-material to this scene
  93039. * @param newMultiMaterial The multi-material to add
  93040. */
  93041. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93042. /**
  93043. * Adds the given material to this scene
  93044. * @param newMaterial The material to add
  93045. */
  93046. addMaterial(newMaterial: Material): void;
  93047. /**
  93048. * Adds the given morph target to this scene
  93049. * @param newMorphTargetManager The morph target to add
  93050. */
  93051. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93052. /**
  93053. * Adds the given geometry to this scene
  93054. * @param newGeometry The geometry to add
  93055. */
  93056. addGeometry(newGeometry: Geometry): void;
  93057. /**
  93058. * Adds the given action manager to this scene
  93059. * @param newActionManager The action manager to add
  93060. */
  93061. addActionManager(newActionManager: AbstractActionManager): void;
  93062. /**
  93063. * Adds the given texture to this scene.
  93064. * @param newTexture The texture to add
  93065. */
  93066. addTexture(newTexture: BaseTexture): void;
  93067. /**
  93068. * Switch active camera
  93069. * @param newCamera defines the new active camera
  93070. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93071. */
  93072. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93073. /**
  93074. * sets the active camera of the scene using its ID
  93075. * @param id defines the camera's ID
  93076. * @return the new active camera or null if none found.
  93077. */
  93078. setActiveCameraByID(id: string): Nullable<Camera>;
  93079. /**
  93080. * sets the active camera of the scene using its name
  93081. * @param name defines the camera's name
  93082. * @returns the new active camera or null if none found.
  93083. */
  93084. setActiveCameraByName(name: string): Nullable<Camera>;
  93085. /**
  93086. * get an animation group using its name
  93087. * @param name defines the material's name
  93088. * @return the animation group or null if none found.
  93089. */
  93090. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93091. /**
  93092. * Get a material using its unique id
  93093. * @param uniqueId defines the material's unique id
  93094. * @return the material or null if none found.
  93095. */
  93096. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93097. /**
  93098. * get a material using its id
  93099. * @param id defines the material's ID
  93100. * @return the material or null if none found.
  93101. */
  93102. getMaterialByID(id: string): Nullable<Material>;
  93103. /**
  93104. * Gets a material using its name
  93105. * @param name defines the material's name
  93106. * @return the material or null if none found.
  93107. */
  93108. getMaterialByName(name: string): Nullable<Material>;
  93109. /**
  93110. * Gets a camera using its id
  93111. * @param id defines the id to look for
  93112. * @returns the camera or null if not found
  93113. */
  93114. getCameraByID(id: string): Nullable<Camera>;
  93115. /**
  93116. * Gets a camera using its unique id
  93117. * @param uniqueId defines the unique id to look for
  93118. * @returns the camera or null if not found
  93119. */
  93120. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93121. /**
  93122. * Gets a camera using its name
  93123. * @param name defines the camera's name
  93124. * @return the camera or null if none found.
  93125. */
  93126. getCameraByName(name: string): Nullable<Camera>;
  93127. /**
  93128. * Gets a bone using its id
  93129. * @param id defines the bone's id
  93130. * @return the bone or null if not found
  93131. */
  93132. getBoneByID(id: string): Nullable<Bone>;
  93133. /**
  93134. * Gets a bone using its id
  93135. * @param name defines the bone's name
  93136. * @return the bone or null if not found
  93137. */
  93138. getBoneByName(name: string): Nullable<Bone>;
  93139. /**
  93140. * Gets a light node using its name
  93141. * @param name defines the the light's name
  93142. * @return the light or null if none found.
  93143. */
  93144. getLightByName(name: string): Nullable<Light>;
  93145. /**
  93146. * Gets a light node using its id
  93147. * @param id defines the light's id
  93148. * @return the light or null if none found.
  93149. */
  93150. getLightByID(id: string): Nullable<Light>;
  93151. /**
  93152. * Gets a light node using its scene-generated unique ID
  93153. * @param uniqueId defines the light's unique id
  93154. * @return the light or null if none found.
  93155. */
  93156. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93157. /**
  93158. * Gets a particle system by id
  93159. * @param id defines the particle system id
  93160. * @return the corresponding system or null if none found
  93161. */
  93162. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93163. /**
  93164. * Gets a geometry using its ID
  93165. * @param id defines the geometry's id
  93166. * @return the geometry or null if none found.
  93167. */
  93168. getGeometryByID(id: string): Nullable<Geometry>;
  93169. private _getGeometryByUniqueID;
  93170. /**
  93171. * Add a new geometry to this scene
  93172. * @param geometry defines the geometry to be added to the scene.
  93173. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93174. * @return a boolean defining if the geometry was added or not
  93175. */
  93176. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93177. /**
  93178. * Removes an existing geometry
  93179. * @param geometry defines the geometry to be removed from the scene
  93180. * @return a boolean defining if the geometry was removed or not
  93181. */
  93182. removeGeometry(geometry: Geometry): boolean;
  93183. /**
  93184. * Gets the list of geometries attached to the scene
  93185. * @returns an array of Geometry
  93186. */
  93187. getGeometries(): Geometry[];
  93188. /**
  93189. * Gets the first added mesh found of a given ID
  93190. * @param id defines the id to search for
  93191. * @return the mesh found or null if not found at all
  93192. */
  93193. getMeshByID(id: string): Nullable<AbstractMesh>;
  93194. /**
  93195. * Gets a list of meshes using their id
  93196. * @param id defines the id to search for
  93197. * @returns a list of meshes
  93198. */
  93199. getMeshesByID(id: string): Array<AbstractMesh>;
  93200. /**
  93201. * Gets the first added transform node found of a given ID
  93202. * @param id defines the id to search for
  93203. * @return the found transform node or null if not found at all.
  93204. */
  93205. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93206. /**
  93207. * Gets a transform node with its auto-generated unique id
  93208. * @param uniqueId efines the unique id to search for
  93209. * @return the found transform node or null if not found at all.
  93210. */
  93211. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93212. /**
  93213. * Gets a list of transform nodes using their id
  93214. * @param id defines the id to search for
  93215. * @returns a list of transform nodes
  93216. */
  93217. getTransformNodesByID(id: string): Array<TransformNode>;
  93218. /**
  93219. * Gets a mesh with its auto-generated unique id
  93220. * @param uniqueId defines the unique id to search for
  93221. * @return the found mesh or null if not found at all.
  93222. */
  93223. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93224. /**
  93225. * Gets a the last added mesh using a given id
  93226. * @param id defines the id to search for
  93227. * @return the found mesh or null if not found at all.
  93228. */
  93229. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93230. /**
  93231. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93232. * @param id defines the id to search for
  93233. * @return the found node or null if not found at all
  93234. */
  93235. getLastEntryByID(id: string): Nullable<Node>;
  93236. /**
  93237. * Gets a node (Mesh, Camera, Light) using a given id
  93238. * @param id defines the id to search for
  93239. * @return the found node or null if not found at all
  93240. */
  93241. getNodeByID(id: string): Nullable<Node>;
  93242. /**
  93243. * Gets a node (Mesh, Camera, Light) using a given name
  93244. * @param name defines the name to search for
  93245. * @return the found node or null if not found at all.
  93246. */
  93247. getNodeByName(name: string): Nullable<Node>;
  93248. /**
  93249. * Gets a mesh using a given name
  93250. * @param name defines the name to search for
  93251. * @return the found mesh or null if not found at all.
  93252. */
  93253. getMeshByName(name: string): Nullable<AbstractMesh>;
  93254. /**
  93255. * Gets a transform node using a given name
  93256. * @param name defines the name to search for
  93257. * @return the found transform node or null if not found at all.
  93258. */
  93259. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93260. /**
  93261. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93262. * @param id defines the id to search for
  93263. * @return the found skeleton or null if not found at all.
  93264. */
  93265. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93266. /**
  93267. * Gets a skeleton using a given auto generated unique id
  93268. * @param uniqueId defines the unique id to search for
  93269. * @return the found skeleton or null if not found at all.
  93270. */
  93271. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93272. /**
  93273. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93274. * @param id defines the id to search for
  93275. * @return the found skeleton or null if not found at all.
  93276. */
  93277. getSkeletonById(id: string): Nullable<Skeleton>;
  93278. /**
  93279. * Gets a skeleton using a given name
  93280. * @param name defines the name to search for
  93281. * @return the found skeleton or null if not found at all.
  93282. */
  93283. getSkeletonByName(name: string): Nullable<Skeleton>;
  93284. /**
  93285. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93286. * @param id defines the id to search for
  93287. * @return the found morph target manager or null if not found at all.
  93288. */
  93289. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93290. /**
  93291. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93292. * @param id defines the id to search for
  93293. * @return the found morph target or null if not found at all.
  93294. */
  93295. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93296. /**
  93297. * Gets a boolean indicating if the given mesh is active
  93298. * @param mesh defines the mesh to look for
  93299. * @returns true if the mesh is in the active list
  93300. */
  93301. isActiveMesh(mesh: AbstractMesh): boolean;
  93302. /**
  93303. * Return a unique id as a string which can serve as an identifier for the scene
  93304. */
  93305. readonly uid: string;
  93306. /**
  93307. * Add an externaly attached data from its key.
  93308. * This method call will fail and return false, if such key already exists.
  93309. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93310. * @param key the unique key that identifies the data
  93311. * @param data the data object to associate to the key for this Engine instance
  93312. * @return true if no such key were already present and the data was added successfully, false otherwise
  93313. */
  93314. addExternalData<T>(key: string, data: T): boolean;
  93315. /**
  93316. * Get an externaly attached data from its key
  93317. * @param key the unique key that identifies the data
  93318. * @return the associated data, if present (can be null), or undefined if not present
  93319. */
  93320. getExternalData<T>(key: string): Nullable<T>;
  93321. /**
  93322. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93323. * @param key the unique key that identifies the data
  93324. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93325. * @return the associated data, can be null if the factory returned null.
  93326. */
  93327. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93328. /**
  93329. * Remove an externaly attached data from the Engine instance
  93330. * @param key the unique key that identifies the data
  93331. * @return true if the data was successfully removed, false if it doesn't exist
  93332. */
  93333. removeExternalData(key: string): boolean;
  93334. private _evaluateSubMesh;
  93335. /**
  93336. * Clear the processed materials smart array preventing retention point in material dispose.
  93337. */
  93338. freeProcessedMaterials(): void;
  93339. private _preventFreeActiveMeshesAndRenderingGroups;
  93340. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93341. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93342. * when disposing several meshes in a row or a hierarchy of meshes.
  93343. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93344. */
  93345. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93346. /**
  93347. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93348. */
  93349. freeActiveMeshes(): void;
  93350. /**
  93351. * Clear the info related to rendering groups preventing retention points during dispose.
  93352. */
  93353. freeRenderingGroups(): void;
  93354. /** @hidden */
  93355. _isInIntermediateRendering(): boolean;
  93356. /**
  93357. * Lambda returning the list of potentially active meshes.
  93358. */
  93359. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93360. /**
  93361. * Lambda returning the list of potentially active sub meshes.
  93362. */
  93363. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93364. /**
  93365. * Lambda returning the list of potentially intersecting sub meshes.
  93366. */
  93367. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93368. /**
  93369. * Lambda returning the list of potentially colliding sub meshes.
  93370. */
  93371. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93372. private _activeMeshesFrozen;
  93373. /**
  93374. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93375. * @returns the current scene
  93376. */
  93377. freezeActiveMeshes(): Scene;
  93378. /**
  93379. * Use this function to restart evaluating active meshes on every frame
  93380. * @returns the current scene
  93381. */
  93382. unfreezeActiveMeshes(): Scene;
  93383. private _evaluateActiveMeshes;
  93384. private _activeMesh;
  93385. /**
  93386. * Update the transform matrix to update from the current active camera
  93387. * @param force defines a boolean used to force the update even if cache is up to date
  93388. */
  93389. updateTransformMatrix(force?: boolean): void;
  93390. private _bindFrameBuffer;
  93391. /** @hidden */
  93392. _allowPostProcessClearColor: boolean;
  93393. /** @hidden */
  93394. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93395. private _processSubCameras;
  93396. private _checkIntersections;
  93397. /** @hidden */
  93398. _advancePhysicsEngineStep(step: number): void;
  93399. /**
  93400. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93401. */
  93402. getDeterministicFrameTime: () => number;
  93403. /** @hidden */
  93404. _animate(): void;
  93405. /** Execute all animations (for a frame) */
  93406. animate(): void;
  93407. /**
  93408. * Render the scene
  93409. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93410. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93411. */
  93412. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93413. /**
  93414. * Freeze all materials
  93415. * A frozen material will not be updatable but should be faster to render
  93416. */
  93417. freezeMaterials(): void;
  93418. /**
  93419. * Unfreeze all materials
  93420. * A frozen material will not be updatable but should be faster to render
  93421. */
  93422. unfreezeMaterials(): void;
  93423. /**
  93424. * Releases all held ressources
  93425. */
  93426. dispose(): void;
  93427. /**
  93428. * Gets if the scene is already disposed
  93429. */
  93430. readonly isDisposed: boolean;
  93431. /**
  93432. * Call this function to reduce memory footprint of the scene.
  93433. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93434. */
  93435. clearCachedVertexData(): void;
  93436. /**
  93437. * This function will remove the local cached buffer data from texture.
  93438. * It will save memory but will prevent the texture from being rebuilt
  93439. */
  93440. cleanCachedTextureBuffer(): void;
  93441. /**
  93442. * Get the world extend vectors with an optional filter
  93443. *
  93444. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93445. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93446. */
  93447. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93448. min: Vector3;
  93449. max: Vector3;
  93450. };
  93451. /**
  93452. * Creates a ray that can be used to pick in the scene
  93453. * @param x defines the x coordinate of the origin (on-screen)
  93454. * @param y defines the y coordinate of the origin (on-screen)
  93455. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93456. * @param camera defines the camera to use for the picking
  93457. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93458. * @returns a Ray
  93459. */
  93460. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93461. /**
  93462. * Creates a ray that can be used to pick in the scene
  93463. * @param x defines the x coordinate of the origin (on-screen)
  93464. * @param y defines the y coordinate of the origin (on-screen)
  93465. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93466. * @param result defines the ray where to store the picking ray
  93467. * @param camera defines the camera to use for the picking
  93468. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93469. * @returns the current scene
  93470. */
  93471. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93472. /**
  93473. * Creates a ray that can be used to pick in the scene
  93474. * @param x defines the x coordinate of the origin (on-screen)
  93475. * @param y defines the y coordinate of the origin (on-screen)
  93476. * @param camera defines the camera to use for the picking
  93477. * @returns a Ray
  93478. */
  93479. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93480. /**
  93481. * Creates a ray that can be used to pick in the scene
  93482. * @param x defines the x coordinate of the origin (on-screen)
  93483. * @param y defines the y coordinate of the origin (on-screen)
  93484. * @param result defines the ray where to store the picking ray
  93485. * @param camera defines the camera to use for the picking
  93486. * @returns the current scene
  93487. */
  93488. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93489. /** Launch a ray to try to pick a mesh in the scene
  93490. * @param x position on screen
  93491. * @param y position on screen
  93492. * @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
  93493. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93494. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93495. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93496. * @returns a PickingInfo
  93497. */
  93498. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93499. /** Use the given ray to pick a mesh in the scene
  93500. * @param ray The ray to use to pick meshes
  93501. * @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
  93502. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93503. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93504. * @returns a PickingInfo
  93505. */
  93506. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93507. /**
  93508. * Launch a ray to try to pick a mesh in the scene
  93509. * @param x X position on screen
  93510. * @param y Y position on screen
  93511. * @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
  93512. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93513. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93514. * @returns an array of PickingInfo
  93515. */
  93516. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93517. /**
  93518. * Launch a ray to try to pick a mesh in the scene
  93519. * @param ray Ray to use
  93520. * @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
  93521. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93522. * @returns an array of PickingInfo
  93523. */
  93524. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93525. /**
  93526. * Force the value of meshUnderPointer
  93527. * @param mesh defines the mesh to use
  93528. */
  93529. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93530. /**
  93531. * Gets the mesh under the pointer
  93532. * @returns a Mesh or null if no mesh is under the pointer
  93533. */
  93534. getPointerOverMesh(): Nullable<AbstractMesh>;
  93535. /** @hidden */
  93536. _rebuildGeometries(): void;
  93537. /** @hidden */
  93538. _rebuildTextures(): void;
  93539. private _getByTags;
  93540. /**
  93541. * Get a list of meshes by tags
  93542. * @param tagsQuery defines the tags query to use
  93543. * @param forEach defines a predicate used to filter results
  93544. * @returns an array of Mesh
  93545. */
  93546. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93547. /**
  93548. * Get a list of cameras by tags
  93549. * @param tagsQuery defines the tags query to use
  93550. * @param forEach defines a predicate used to filter results
  93551. * @returns an array of Camera
  93552. */
  93553. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93554. /**
  93555. * Get a list of lights by tags
  93556. * @param tagsQuery defines the tags query to use
  93557. * @param forEach defines a predicate used to filter results
  93558. * @returns an array of Light
  93559. */
  93560. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93561. /**
  93562. * Get a list of materials by tags
  93563. * @param tagsQuery defines the tags query to use
  93564. * @param forEach defines a predicate used to filter results
  93565. * @returns an array of Material
  93566. */
  93567. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93568. /**
  93569. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93570. * This allowed control for front to back rendering or reversly depending of the special needs.
  93571. *
  93572. * @param renderingGroupId The rendering group id corresponding to its index
  93573. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93574. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93575. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93576. */
  93577. 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;
  93578. /**
  93579. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93580. *
  93581. * @param renderingGroupId The rendering group id corresponding to its index
  93582. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93583. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93584. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93585. */
  93586. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93587. /**
  93588. * Gets the current auto clear configuration for one rendering group of the rendering
  93589. * manager.
  93590. * @param index the rendering group index to get the information for
  93591. * @returns The auto clear setup for the requested rendering group
  93592. */
  93593. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93594. private _blockMaterialDirtyMechanism;
  93595. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93596. blockMaterialDirtyMechanism: boolean;
  93597. /**
  93598. * Will flag all materials as dirty to trigger new shader compilation
  93599. * @param flag defines the flag used to specify which material part must be marked as dirty
  93600. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93601. */
  93602. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93603. /** @hidden */
  93604. _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;
  93605. /** @hidden */
  93606. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93607. }
  93608. }
  93609. declare module BABYLON {
  93610. /**
  93611. * Set of assets to keep when moving a scene into an asset container.
  93612. */
  93613. export class KeepAssets extends AbstractScene {
  93614. }
  93615. /**
  93616. * Container with a set of assets that can be added or removed from a scene.
  93617. */
  93618. export class AssetContainer extends AbstractScene {
  93619. /**
  93620. * The scene the AssetContainer belongs to.
  93621. */
  93622. scene: Scene;
  93623. /**
  93624. * Instantiates an AssetContainer.
  93625. * @param scene The scene the AssetContainer belongs to.
  93626. */
  93627. constructor(scene: Scene);
  93628. /**
  93629. * Adds all the assets from the container to the scene.
  93630. */
  93631. addAllToScene(): void;
  93632. /**
  93633. * Removes all the assets in the container from the scene
  93634. */
  93635. removeAllFromScene(): void;
  93636. /**
  93637. * Disposes all the assets in the container
  93638. */
  93639. dispose(): void;
  93640. private _moveAssets;
  93641. /**
  93642. * Removes all the assets contained in the scene and adds them to the container.
  93643. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93644. */
  93645. moveAllFromScene(keepAssets?: KeepAssets): void;
  93646. /**
  93647. * 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.
  93648. * @returns the root mesh
  93649. */
  93650. createRootMesh(): Mesh;
  93651. }
  93652. }
  93653. declare module BABYLON {
  93654. /**
  93655. * Defines how the parser contract is defined.
  93656. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93657. */
  93658. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93659. /**
  93660. * Defines how the individual parser contract is defined.
  93661. * These parser can parse an individual asset
  93662. */
  93663. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93664. /**
  93665. * Base class of the scene acting as a container for the different elements composing a scene.
  93666. * This class is dynamically extended by the different components of the scene increasing
  93667. * flexibility and reducing coupling
  93668. */
  93669. export abstract class AbstractScene {
  93670. /**
  93671. * Stores the list of available parsers in the application.
  93672. */
  93673. private static _BabylonFileParsers;
  93674. /**
  93675. * Stores the list of available individual parsers in the application.
  93676. */
  93677. private static _IndividualBabylonFileParsers;
  93678. /**
  93679. * Adds a parser in the list of available ones
  93680. * @param name Defines the name of the parser
  93681. * @param parser Defines the parser to add
  93682. */
  93683. static AddParser(name: string, parser: BabylonFileParser): void;
  93684. /**
  93685. * Gets a general parser from the list of avaialble ones
  93686. * @param name Defines the name of the parser
  93687. * @returns the requested parser or null
  93688. */
  93689. static GetParser(name: string): Nullable<BabylonFileParser>;
  93690. /**
  93691. * Adds n individual parser in the list of available ones
  93692. * @param name Defines the name of the parser
  93693. * @param parser Defines the parser to add
  93694. */
  93695. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93696. /**
  93697. * Gets an individual parser from the list of avaialble ones
  93698. * @param name Defines the name of the parser
  93699. * @returns the requested parser or null
  93700. */
  93701. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93702. /**
  93703. * Parser json data and populate both a scene and its associated container object
  93704. * @param jsonData Defines the data to parse
  93705. * @param scene Defines the scene to parse the data for
  93706. * @param container Defines the container attached to the parsing sequence
  93707. * @param rootUrl Defines the root url of the data
  93708. */
  93709. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93710. /**
  93711. * Gets the list of root nodes (ie. nodes with no parent)
  93712. */
  93713. rootNodes: Node[];
  93714. /** All of the cameras added to this scene
  93715. * @see http://doc.babylonjs.com/babylon101/cameras
  93716. */
  93717. cameras: Camera[];
  93718. /**
  93719. * All of the lights added to this scene
  93720. * @see http://doc.babylonjs.com/babylon101/lights
  93721. */
  93722. lights: Light[];
  93723. /**
  93724. * All of the (abstract) meshes added to this scene
  93725. */
  93726. meshes: AbstractMesh[];
  93727. /**
  93728. * The list of skeletons added to the scene
  93729. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93730. */
  93731. skeletons: Skeleton[];
  93732. /**
  93733. * All of the particle systems added to this scene
  93734. * @see http://doc.babylonjs.com/babylon101/particles
  93735. */
  93736. particleSystems: IParticleSystem[];
  93737. /**
  93738. * Gets a list of Animations associated with the scene
  93739. */
  93740. animations: Animation[];
  93741. /**
  93742. * All of the animation groups added to this scene
  93743. * @see http://doc.babylonjs.com/how_to/group
  93744. */
  93745. animationGroups: AnimationGroup[];
  93746. /**
  93747. * All of the multi-materials added to this scene
  93748. * @see http://doc.babylonjs.com/how_to/multi_materials
  93749. */
  93750. multiMaterials: MultiMaterial[];
  93751. /**
  93752. * All of the materials added to this scene
  93753. * In the context of a Scene, it is not supposed to be modified manually.
  93754. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93755. * Note also that the order of the Material wihin the array is not significant and might change.
  93756. * @see http://doc.babylonjs.com/babylon101/materials
  93757. */
  93758. materials: Material[];
  93759. /**
  93760. * The list of morph target managers added to the scene
  93761. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93762. */
  93763. morphTargetManagers: MorphTargetManager[];
  93764. /**
  93765. * The list of geometries used in the scene.
  93766. */
  93767. geometries: Geometry[];
  93768. /**
  93769. * All of the tranform nodes added to this scene
  93770. * In the context of a Scene, it is not supposed to be modified manually.
  93771. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93772. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93773. * @see http://doc.babylonjs.com/how_to/transformnode
  93774. */
  93775. transformNodes: TransformNode[];
  93776. /**
  93777. * ActionManagers available on the scene.
  93778. */
  93779. actionManagers: AbstractActionManager[];
  93780. /**
  93781. * Textures to keep.
  93782. */
  93783. textures: BaseTexture[];
  93784. /**
  93785. * Environment texture for the scene
  93786. */
  93787. environmentTexture: Nullable<BaseTexture>;
  93788. }
  93789. }
  93790. declare module BABYLON {
  93791. /**
  93792. * Defines a sound that can be played in the application.
  93793. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93795. */
  93796. export class Sound {
  93797. /**
  93798. * The name of the sound in the scene.
  93799. */
  93800. name: string;
  93801. /**
  93802. * Does the sound autoplay once loaded.
  93803. */
  93804. autoplay: boolean;
  93805. /**
  93806. * Does the sound loop after it finishes playing once.
  93807. */
  93808. loop: boolean;
  93809. /**
  93810. * Does the sound use a custom attenuation curve to simulate the falloff
  93811. * happening when the source gets further away from the camera.
  93812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93813. */
  93814. useCustomAttenuation: boolean;
  93815. /**
  93816. * The sound track id this sound belongs to.
  93817. */
  93818. soundTrackId: number;
  93819. /**
  93820. * Is this sound currently played.
  93821. */
  93822. isPlaying: boolean;
  93823. /**
  93824. * Is this sound currently paused.
  93825. */
  93826. isPaused: boolean;
  93827. /**
  93828. * Does this sound enables spatial sound.
  93829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93830. */
  93831. spatialSound: boolean;
  93832. /**
  93833. * Define the reference distance the sound should be heard perfectly.
  93834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93835. */
  93836. refDistance: number;
  93837. /**
  93838. * Define the roll off factor of spatial sounds.
  93839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93840. */
  93841. rolloffFactor: number;
  93842. /**
  93843. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93845. */
  93846. maxDistance: number;
  93847. /**
  93848. * Define the distance attenuation model the sound will follow.
  93849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93850. */
  93851. distanceModel: string;
  93852. /**
  93853. * @hidden
  93854. * Back Compat
  93855. **/
  93856. onended: () => any;
  93857. /**
  93858. * Observable event when the current playing sound finishes.
  93859. */
  93860. onEndedObservable: Observable<Sound>;
  93861. private _panningModel;
  93862. private _playbackRate;
  93863. private _streaming;
  93864. private _startTime;
  93865. private _startOffset;
  93866. private _position;
  93867. /** @hidden */
  93868. _positionInEmitterSpace: boolean;
  93869. private _localDirection;
  93870. private _volume;
  93871. private _isReadyToPlay;
  93872. private _isDirectional;
  93873. private _readyToPlayCallback;
  93874. private _audioBuffer;
  93875. private _soundSource;
  93876. private _streamingSource;
  93877. private _soundPanner;
  93878. private _soundGain;
  93879. private _inputAudioNode;
  93880. private _outputAudioNode;
  93881. private _coneInnerAngle;
  93882. private _coneOuterAngle;
  93883. private _coneOuterGain;
  93884. private _scene;
  93885. private _connectedTransformNode;
  93886. private _customAttenuationFunction;
  93887. private _registerFunc;
  93888. private _isOutputConnected;
  93889. private _htmlAudioElement;
  93890. private _urlType;
  93891. /** @hidden */
  93892. static _SceneComponentInitialization: (scene: Scene) => void;
  93893. /**
  93894. * Create a sound and attach it to a scene
  93895. * @param name Name of your sound
  93896. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93897. * @param scene defines the scene the sound belongs to
  93898. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93899. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93900. */
  93901. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93902. /**
  93903. * Release the sound and its associated resources
  93904. */
  93905. dispose(): void;
  93906. /**
  93907. * Gets if the sounds is ready to be played or not.
  93908. * @returns true if ready, otherwise false
  93909. */
  93910. isReady(): boolean;
  93911. private _soundLoaded;
  93912. /**
  93913. * Sets the data of the sound from an audiobuffer
  93914. * @param audioBuffer The audioBuffer containing the data
  93915. */
  93916. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93917. /**
  93918. * Updates the current sounds options such as maxdistance, loop...
  93919. * @param options A JSON object containing values named as the object properties
  93920. */
  93921. updateOptions(options: any): void;
  93922. private _createSpatialParameters;
  93923. private _updateSpatialParameters;
  93924. /**
  93925. * Switch the panning model to HRTF:
  93926. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93928. */
  93929. switchPanningModelToHRTF(): void;
  93930. /**
  93931. * Switch the panning model to Equal Power:
  93932. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93934. */
  93935. switchPanningModelToEqualPower(): void;
  93936. private _switchPanningModel;
  93937. /**
  93938. * Connect this sound to a sound track audio node like gain...
  93939. * @param soundTrackAudioNode the sound track audio node to connect to
  93940. */
  93941. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93942. /**
  93943. * Transform this sound into a directional source
  93944. * @param coneInnerAngle Size of the inner cone in degree
  93945. * @param coneOuterAngle Size of the outer cone in degree
  93946. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93947. */
  93948. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93949. /**
  93950. * Gets or sets the inner angle for the directional cone.
  93951. */
  93952. /**
  93953. * Gets or sets the inner angle for the directional cone.
  93954. */
  93955. directionalConeInnerAngle: number;
  93956. /**
  93957. * Gets or sets the outer angle for the directional cone.
  93958. */
  93959. /**
  93960. * Gets or sets the outer angle for the directional cone.
  93961. */
  93962. directionalConeOuterAngle: number;
  93963. /**
  93964. * Sets the position of the emitter if spatial sound is enabled
  93965. * @param newPosition Defines the new posisiton
  93966. */
  93967. setPosition(newPosition: Vector3): void;
  93968. /**
  93969. * Sets the local direction of the emitter if spatial sound is enabled
  93970. * @param newLocalDirection Defines the new local direction
  93971. */
  93972. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93973. private _updateDirection;
  93974. /** @hidden */
  93975. updateDistanceFromListener(): void;
  93976. /**
  93977. * Sets a new custom attenuation function for the sound.
  93978. * @param callback Defines the function used for the attenuation
  93979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93980. */
  93981. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93982. /**
  93983. * Play the sound
  93984. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93985. * @param offset (optional) Start the sound setting it at a specific time
  93986. */
  93987. play(time?: number, offset?: number): void;
  93988. private _onended;
  93989. /**
  93990. * Stop the sound
  93991. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93992. */
  93993. stop(time?: number): void;
  93994. /**
  93995. * Put the sound in pause
  93996. */
  93997. pause(): void;
  93998. /**
  93999. * Sets a dedicated volume for this sounds
  94000. * @param newVolume Define the new volume of the sound
  94001. * @param time Define in how long the sound should be at this value
  94002. */
  94003. setVolume(newVolume: number, time?: number): void;
  94004. /**
  94005. * Set the sound play back rate
  94006. * @param newPlaybackRate Define the playback rate the sound should be played at
  94007. */
  94008. setPlaybackRate(newPlaybackRate: number): void;
  94009. /**
  94010. * Gets the volume of the sound.
  94011. * @returns the volume of the sound
  94012. */
  94013. getVolume(): number;
  94014. /**
  94015. * Attach the sound to a dedicated mesh
  94016. * @param transformNode The transform node to connect the sound with
  94017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94018. */
  94019. attachToMesh(transformNode: TransformNode): void;
  94020. /**
  94021. * Detach the sound from the previously attached mesh
  94022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94023. */
  94024. detachFromMesh(): void;
  94025. private _onRegisterAfterWorldMatrixUpdate;
  94026. /**
  94027. * Clone the current sound in the scene.
  94028. * @returns the new sound clone
  94029. */
  94030. clone(): Nullable<Sound>;
  94031. /**
  94032. * Gets the current underlying audio buffer containing the data
  94033. * @returns the audio buffer
  94034. */
  94035. getAudioBuffer(): Nullable<AudioBuffer>;
  94036. /**
  94037. * Serializes the Sound in a JSON representation
  94038. * @returns the JSON representation of the sound
  94039. */
  94040. serialize(): any;
  94041. /**
  94042. * Parse a JSON representation of a sound to innstantiate in a given scene
  94043. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94044. * @param scene Define the scene the new parsed sound should be created in
  94045. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94046. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94047. * @returns the newly parsed sound
  94048. */
  94049. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94050. }
  94051. }
  94052. declare module BABYLON {
  94053. /**
  94054. * This defines an action helpful to play a defined sound on a triggered action.
  94055. */
  94056. export class PlaySoundAction extends Action {
  94057. private _sound;
  94058. /**
  94059. * Instantiate the action
  94060. * @param triggerOptions defines the trigger options
  94061. * @param sound defines the sound to play
  94062. * @param condition defines the trigger related conditions
  94063. */
  94064. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94065. /** @hidden */
  94066. _prepare(): void;
  94067. /**
  94068. * Execute the action and play the sound.
  94069. */
  94070. execute(): void;
  94071. /**
  94072. * Serializes the actions and its related information.
  94073. * @param parent defines the object to serialize in
  94074. * @returns the serialized object
  94075. */
  94076. serialize(parent: any): any;
  94077. }
  94078. /**
  94079. * This defines an action helpful to stop a defined sound on a triggered action.
  94080. */
  94081. export class StopSoundAction extends Action {
  94082. private _sound;
  94083. /**
  94084. * Instantiate the action
  94085. * @param triggerOptions defines the trigger options
  94086. * @param sound defines the sound to stop
  94087. * @param condition defines the trigger related conditions
  94088. */
  94089. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94090. /** @hidden */
  94091. _prepare(): void;
  94092. /**
  94093. * Execute the action and stop the sound.
  94094. */
  94095. execute(): void;
  94096. /**
  94097. * Serializes the actions and its related information.
  94098. * @param parent defines the object to serialize in
  94099. * @returns the serialized object
  94100. */
  94101. serialize(parent: any): any;
  94102. }
  94103. }
  94104. declare module BABYLON {
  94105. /**
  94106. * This defines an action responsible to change the value of a property
  94107. * by interpolating between its current value and the newly set one once triggered.
  94108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94109. */
  94110. export class InterpolateValueAction extends Action {
  94111. /**
  94112. * Defines the path of the property where the value should be interpolated
  94113. */
  94114. propertyPath: string;
  94115. /**
  94116. * Defines the target value at the end of the interpolation.
  94117. */
  94118. value: any;
  94119. /**
  94120. * Defines the time it will take for the property to interpolate to the value.
  94121. */
  94122. duration: number;
  94123. /**
  94124. * Defines if the other scene animations should be stopped when the action has been triggered
  94125. */
  94126. stopOtherAnimations?: boolean;
  94127. /**
  94128. * Defines a callback raised once the interpolation animation has been done.
  94129. */
  94130. onInterpolationDone?: () => void;
  94131. /**
  94132. * Observable triggered once the interpolation animation has been done.
  94133. */
  94134. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94135. private _target;
  94136. private _effectiveTarget;
  94137. private _property;
  94138. /**
  94139. * Instantiate the action
  94140. * @param triggerOptions defines the trigger options
  94141. * @param target defines the object containing the value to interpolate
  94142. * @param propertyPath defines the path to the property in the target object
  94143. * @param value defines the target value at the end of the interpolation
  94144. * @param duration deines the time it will take for the property to interpolate to the value.
  94145. * @param condition defines the trigger related conditions
  94146. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94147. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94148. */
  94149. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94150. /** @hidden */
  94151. _prepare(): void;
  94152. /**
  94153. * Execute the action starts the value interpolation.
  94154. */
  94155. execute(): void;
  94156. /**
  94157. * Serializes the actions and its related information.
  94158. * @param parent defines the object to serialize in
  94159. * @returns the serialized object
  94160. */
  94161. serialize(parent: any): any;
  94162. }
  94163. }
  94164. declare module BABYLON {
  94165. /**
  94166. * Options allowed during the creation of a sound track.
  94167. */
  94168. export interface ISoundTrackOptions {
  94169. /**
  94170. * The volume the sound track should take during creation
  94171. */
  94172. volume?: number;
  94173. /**
  94174. * Define if the sound track is the main sound track of the scene
  94175. */
  94176. mainTrack?: boolean;
  94177. }
  94178. /**
  94179. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94180. * It will be also used in a future release to apply effects on a specific track.
  94181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94182. */
  94183. export class SoundTrack {
  94184. /**
  94185. * The unique identifier of the sound track in the scene.
  94186. */
  94187. id: number;
  94188. /**
  94189. * The list of sounds included in the sound track.
  94190. */
  94191. soundCollection: Array<Sound>;
  94192. private _outputAudioNode;
  94193. private _scene;
  94194. private _isMainTrack;
  94195. private _connectedAnalyser;
  94196. private _options;
  94197. private _isInitialized;
  94198. /**
  94199. * Creates a new sound track.
  94200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94201. * @param scene Define the scene the sound track belongs to
  94202. * @param options
  94203. */
  94204. constructor(scene: Scene, options?: ISoundTrackOptions);
  94205. private _initializeSoundTrackAudioGraph;
  94206. /**
  94207. * Release the sound track and its associated resources
  94208. */
  94209. dispose(): void;
  94210. /**
  94211. * Adds a sound to this sound track
  94212. * @param sound define the cound to add
  94213. * @ignoreNaming
  94214. */
  94215. AddSound(sound: Sound): void;
  94216. /**
  94217. * Removes a sound to this sound track
  94218. * @param sound define the cound to remove
  94219. * @ignoreNaming
  94220. */
  94221. RemoveSound(sound: Sound): void;
  94222. /**
  94223. * Set a global volume for the full sound track.
  94224. * @param newVolume Define the new volume of the sound track
  94225. */
  94226. setVolume(newVolume: number): void;
  94227. /**
  94228. * Switch the panning model to HRTF:
  94229. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94231. */
  94232. switchPanningModelToHRTF(): void;
  94233. /**
  94234. * Switch the panning model to Equal Power:
  94235. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94237. */
  94238. switchPanningModelToEqualPower(): void;
  94239. /**
  94240. * Connect the sound track to an audio analyser allowing some amazing
  94241. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94243. * @param analyser The analyser to connect to the engine
  94244. */
  94245. connectToAnalyser(analyser: Analyser): void;
  94246. }
  94247. }
  94248. declare module BABYLON {
  94249. interface AbstractScene {
  94250. /**
  94251. * The list of sounds used in the scene.
  94252. */
  94253. sounds: Nullable<Array<Sound>>;
  94254. }
  94255. interface Scene {
  94256. /**
  94257. * @hidden
  94258. * Backing field
  94259. */
  94260. _mainSoundTrack: SoundTrack;
  94261. /**
  94262. * The main sound track played by the scene.
  94263. * It cotains your primary collection of sounds.
  94264. */
  94265. mainSoundTrack: SoundTrack;
  94266. /**
  94267. * The list of sound tracks added to the scene
  94268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94269. */
  94270. soundTracks: Nullable<Array<SoundTrack>>;
  94271. /**
  94272. * Gets a sound using a given name
  94273. * @param name defines the name to search for
  94274. * @return the found sound or null if not found at all.
  94275. */
  94276. getSoundByName(name: string): Nullable<Sound>;
  94277. /**
  94278. * Gets or sets if audio support is enabled
  94279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94280. */
  94281. audioEnabled: boolean;
  94282. /**
  94283. * Gets or sets if audio will be output to headphones
  94284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94285. */
  94286. headphone: boolean;
  94287. }
  94288. /**
  94289. * Defines the sound scene component responsible to manage any sounds
  94290. * in a given scene.
  94291. */
  94292. export class AudioSceneComponent implements ISceneSerializableComponent {
  94293. /**
  94294. * The component name helpfull to identify the component in the list of scene components.
  94295. */
  94296. readonly name: string;
  94297. /**
  94298. * The scene the component belongs to.
  94299. */
  94300. scene: Scene;
  94301. private _audioEnabled;
  94302. /**
  94303. * Gets whether audio is enabled or not.
  94304. * Please use related enable/disable method to switch state.
  94305. */
  94306. readonly audioEnabled: boolean;
  94307. private _headphone;
  94308. /**
  94309. * Gets whether audio is outputing to headphone or not.
  94310. * Please use the according Switch methods to change output.
  94311. */
  94312. readonly headphone: boolean;
  94313. /**
  94314. * Creates a new instance of the component for the given scene
  94315. * @param scene Defines the scene to register the component in
  94316. */
  94317. constructor(scene: Scene);
  94318. /**
  94319. * Registers the component in a given scene
  94320. */
  94321. register(): void;
  94322. /**
  94323. * Rebuilds the elements related to this component in case of
  94324. * context lost for instance.
  94325. */
  94326. rebuild(): void;
  94327. /**
  94328. * Serializes the component data to the specified json object
  94329. * @param serializationObject The object to serialize to
  94330. */
  94331. serialize(serializationObject: any): void;
  94332. /**
  94333. * Adds all the element from the container to the scene
  94334. * @param container the container holding the elements
  94335. */
  94336. addFromContainer(container: AbstractScene): void;
  94337. /**
  94338. * Removes all the elements in the container from the scene
  94339. * @param container contains the elements to remove
  94340. * @param dispose if the removed element should be disposed (default: false)
  94341. */
  94342. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94343. /**
  94344. * Disposes the component and the associated ressources.
  94345. */
  94346. dispose(): void;
  94347. /**
  94348. * Disables audio in the associated scene.
  94349. */
  94350. disableAudio(): void;
  94351. /**
  94352. * Enables audio in the associated scene.
  94353. */
  94354. enableAudio(): void;
  94355. /**
  94356. * Switch audio to headphone output.
  94357. */
  94358. switchAudioModeForHeadphones(): void;
  94359. /**
  94360. * Switch audio to normal speakers.
  94361. */
  94362. switchAudioModeForNormalSpeakers(): void;
  94363. private _afterRender;
  94364. }
  94365. }
  94366. declare module BABYLON {
  94367. /**
  94368. * Wraps one or more Sound objects and selects one with random weight for playback.
  94369. */
  94370. export class WeightedSound {
  94371. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94372. loop: boolean;
  94373. private _coneInnerAngle;
  94374. private _coneOuterAngle;
  94375. private _volume;
  94376. /** A Sound is currently playing. */
  94377. isPlaying: boolean;
  94378. /** A Sound is currently paused. */
  94379. isPaused: boolean;
  94380. private _sounds;
  94381. private _weights;
  94382. private _currentIndex?;
  94383. /**
  94384. * Creates a new WeightedSound from the list of sounds given.
  94385. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94386. * @param sounds Array of Sounds that will be selected from.
  94387. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94388. */
  94389. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94390. /**
  94391. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94392. */
  94393. /**
  94394. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94395. */
  94396. directionalConeInnerAngle: number;
  94397. /**
  94398. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94399. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94400. */
  94401. /**
  94402. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94403. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94404. */
  94405. directionalConeOuterAngle: number;
  94406. /**
  94407. * Playback volume.
  94408. */
  94409. /**
  94410. * Playback volume.
  94411. */
  94412. volume: number;
  94413. private _onended;
  94414. /**
  94415. * Suspend playback
  94416. */
  94417. pause(): void;
  94418. /**
  94419. * Stop playback
  94420. */
  94421. stop(): void;
  94422. /**
  94423. * Start playback.
  94424. * @param startOffset Position the clip head at a specific time in seconds.
  94425. */
  94426. play(startOffset?: number): void;
  94427. }
  94428. }
  94429. declare module BABYLON {
  94430. /**
  94431. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94432. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94433. */
  94434. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94435. /**
  94436. * Gets the name of the behavior.
  94437. */
  94438. readonly name: string;
  94439. /**
  94440. * The easing function used by animations
  94441. */
  94442. static EasingFunction: BackEase;
  94443. /**
  94444. * The easing mode used by animations
  94445. */
  94446. static EasingMode: number;
  94447. /**
  94448. * The duration of the animation, in milliseconds
  94449. */
  94450. transitionDuration: number;
  94451. /**
  94452. * Length of the distance animated by the transition when lower radius is reached
  94453. */
  94454. lowerRadiusTransitionRange: number;
  94455. /**
  94456. * Length of the distance animated by the transition when upper radius is reached
  94457. */
  94458. upperRadiusTransitionRange: number;
  94459. private _autoTransitionRange;
  94460. /**
  94461. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94462. */
  94463. /**
  94464. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94465. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94466. */
  94467. autoTransitionRange: boolean;
  94468. private _attachedCamera;
  94469. private _onAfterCheckInputsObserver;
  94470. private _onMeshTargetChangedObserver;
  94471. /**
  94472. * Initializes the behavior.
  94473. */
  94474. init(): void;
  94475. /**
  94476. * Attaches the behavior to its arc rotate camera.
  94477. * @param camera Defines the camera to attach the behavior to
  94478. */
  94479. attach(camera: ArcRotateCamera): void;
  94480. /**
  94481. * Detaches the behavior from its current arc rotate camera.
  94482. */
  94483. detach(): void;
  94484. private _radiusIsAnimating;
  94485. private _radiusBounceTransition;
  94486. private _animatables;
  94487. private _cachedWheelPrecision;
  94488. /**
  94489. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94490. * @param radiusLimit The limit to check against.
  94491. * @return Bool to indicate if at limit.
  94492. */
  94493. private _isRadiusAtLimit;
  94494. /**
  94495. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94496. * @param radiusDelta The delta by which to animate to. Can be negative.
  94497. */
  94498. private _applyBoundRadiusAnimation;
  94499. /**
  94500. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94501. */
  94502. protected _clearAnimationLocks(): void;
  94503. /**
  94504. * Stops and removes all animations that have been applied to the camera
  94505. */
  94506. stopAllAnimations(): void;
  94507. }
  94508. }
  94509. declare module BABYLON {
  94510. /**
  94511. * 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.
  94512. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94513. */
  94514. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94515. /**
  94516. * Gets the name of the behavior.
  94517. */
  94518. readonly name: string;
  94519. private _mode;
  94520. private _radiusScale;
  94521. private _positionScale;
  94522. private _defaultElevation;
  94523. private _elevationReturnTime;
  94524. private _elevationReturnWaitTime;
  94525. private _zoomStopsAnimation;
  94526. private _framingTime;
  94527. /**
  94528. * The easing function used by animations
  94529. */
  94530. static EasingFunction: ExponentialEase;
  94531. /**
  94532. * The easing mode used by animations
  94533. */
  94534. static EasingMode: number;
  94535. /**
  94536. * Sets the current mode used by the behavior
  94537. */
  94538. /**
  94539. * Gets current mode used by the behavior.
  94540. */
  94541. mode: number;
  94542. /**
  94543. * Sets the scale applied to the radius (1 by default)
  94544. */
  94545. /**
  94546. * Gets the scale applied to the radius
  94547. */
  94548. radiusScale: number;
  94549. /**
  94550. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94551. */
  94552. /**
  94553. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94554. */
  94555. positionScale: number;
  94556. /**
  94557. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94558. * behaviour is triggered, in radians.
  94559. */
  94560. /**
  94561. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94562. * behaviour is triggered, in radians.
  94563. */
  94564. defaultElevation: number;
  94565. /**
  94566. * Sets the time (in milliseconds) taken to return to the default beta position.
  94567. * Negative value indicates camera should not return to default.
  94568. */
  94569. /**
  94570. * Gets the time (in milliseconds) taken to return to the default beta position.
  94571. * Negative value indicates camera should not return to default.
  94572. */
  94573. elevationReturnTime: number;
  94574. /**
  94575. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94576. */
  94577. /**
  94578. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94579. */
  94580. elevationReturnWaitTime: number;
  94581. /**
  94582. * Sets the flag that indicates if user zooming should stop animation.
  94583. */
  94584. /**
  94585. * Gets the flag that indicates if user zooming should stop animation.
  94586. */
  94587. zoomStopsAnimation: boolean;
  94588. /**
  94589. * Sets the transition time when framing the mesh, in milliseconds
  94590. */
  94591. /**
  94592. * Gets the transition time when framing the mesh, in milliseconds
  94593. */
  94594. framingTime: number;
  94595. /**
  94596. * Define if the behavior should automatically change the configured
  94597. * camera limits and sensibilities.
  94598. */
  94599. autoCorrectCameraLimitsAndSensibility: boolean;
  94600. private _onPrePointerObservableObserver;
  94601. private _onAfterCheckInputsObserver;
  94602. private _onMeshTargetChangedObserver;
  94603. private _attachedCamera;
  94604. private _isPointerDown;
  94605. private _lastInteractionTime;
  94606. /**
  94607. * Initializes the behavior.
  94608. */
  94609. init(): void;
  94610. /**
  94611. * Attaches the behavior to its arc rotate camera.
  94612. * @param camera Defines the camera to attach the behavior to
  94613. */
  94614. attach(camera: ArcRotateCamera): void;
  94615. /**
  94616. * Detaches the behavior from its current arc rotate camera.
  94617. */
  94618. detach(): void;
  94619. private _animatables;
  94620. private _betaIsAnimating;
  94621. private _betaTransition;
  94622. private _radiusTransition;
  94623. private _vectorTransition;
  94624. /**
  94625. * Targets the given mesh and updates zoom level accordingly.
  94626. * @param mesh The mesh to target.
  94627. * @param radius Optional. If a cached radius position already exists, overrides default.
  94628. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94629. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94630. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94631. */
  94632. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94633. /**
  94634. * Targets the given mesh with its children and updates zoom level accordingly.
  94635. * @param mesh The mesh to target.
  94636. * @param radius Optional. If a cached radius position already exists, overrides default.
  94637. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94638. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94639. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94640. */
  94641. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94642. /**
  94643. * Targets the given meshes with their children and updates zoom level accordingly.
  94644. * @param meshes The mesh to target.
  94645. * @param radius Optional. If a cached radius position already exists, overrides default.
  94646. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94647. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94648. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94649. */
  94650. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94651. /**
  94652. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94653. * @param minimumWorld Determines the smaller position of the bounding box extend
  94654. * @param maximumWorld Determines the bigger position of the bounding box extend
  94655. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94656. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94657. */
  94658. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94659. /**
  94660. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94661. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94662. * frustum width.
  94663. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94664. * to fully enclose the mesh in the viewing frustum.
  94665. */
  94666. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94667. /**
  94668. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94669. * is automatically returned to its default position (expected to be above ground plane).
  94670. */
  94671. private _maintainCameraAboveGround;
  94672. /**
  94673. * Returns the frustum slope based on the canvas ratio and camera FOV
  94674. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94675. */
  94676. private _getFrustumSlope;
  94677. /**
  94678. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94679. */
  94680. private _clearAnimationLocks;
  94681. /**
  94682. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94683. */
  94684. private _applyUserInteraction;
  94685. /**
  94686. * Stops and removes all animations that have been applied to the camera
  94687. */
  94688. stopAllAnimations(): void;
  94689. /**
  94690. * Gets a value indicating if the user is moving the camera
  94691. */
  94692. readonly isUserIsMoving: boolean;
  94693. /**
  94694. * The camera can move all the way towards the mesh.
  94695. */
  94696. static IgnoreBoundsSizeMode: number;
  94697. /**
  94698. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94699. */
  94700. static FitFrustumSidesMode: number;
  94701. }
  94702. }
  94703. declare module BABYLON {
  94704. /**
  94705. * Base class for Camera Pointer Inputs.
  94706. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94707. * for example usage.
  94708. */
  94709. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94710. /**
  94711. * Defines the camera the input is attached to.
  94712. */
  94713. abstract camera: Camera;
  94714. /**
  94715. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94716. */
  94717. protected _altKey: boolean;
  94718. protected _ctrlKey: boolean;
  94719. protected _metaKey: boolean;
  94720. protected _shiftKey: boolean;
  94721. /**
  94722. * Which mouse buttons were pressed at time of last mouse event.
  94723. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94724. */
  94725. protected _buttonsPressed: number;
  94726. /**
  94727. * Defines the buttons associated with the input to handle camera move.
  94728. */
  94729. buttons: number[];
  94730. /**
  94731. * Attach the input controls to a specific dom element to get the input from.
  94732. * @param element Defines the element the controls should be listened from
  94733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94734. */
  94735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94736. /**
  94737. * Detach the current controls from the specified dom element.
  94738. * @param element Defines the element to stop listening the inputs from
  94739. */
  94740. detachControl(element: Nullable<HTMLElement>): void;
  94741. /**
  94742. * Gets the class name of the current input.
  94743. * @returns the class name
  94744. */
  94745. getClassName(): string;
  94746. /**
  94747. * Get the friendly name associated with the input class.
  94748. * @returns the input friendly name
  94749. */
  94750. getSimpleName(): string;
  94751. /**
  94752. * Called on pointer POINTERDOUBLETAP event.
  94753. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94754. */
  94755. protected onDoubleTap(type: string): void;
  94756. /**
  94757. * Called on pointer POINTERMOVE event if only a single touch is active.
  94758. * Override this method to provide functionality.
  94759. */
  94760. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94761. /**
  94762. * Called on pointer POINTERMOVE event if multiple touches are active.
  94763. * Override this method to provide functionality.
  94764. */
  94765. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94766. /**
  94767. * Called on JS contextmenu event.
  94768. * Override this method to provide functionality.
  94769. */
  94770. protected onContextMenu(evt: PointerEvent): void;
  94771. /**
  94772. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94773. * press.
  94774. * Override this method to provide functionality.
  94775. */
  94776. protected onButtonDown(evt: PointerEvent): void;
  94777. /**
  94778. * Called each time a new POINTERUP event occurs. Ie, for each button
  94779. * release.
  94780. * Override this method to provide functionality.
  94781. */
  94782. protected onButtonUp(evt: PointerEvent): void;
  94783. /**
  94784. * Called when window becomes inactive.
  94785. * Override this method to provide functionality.
  94786. */
  94787. protected onLostFocus(): void;
  94788. private _pointerInput;
  94789. private _observer;
  94790. private _onLostFocus;
  94791. private pointA;
  94792. private pointB;
  94793. }
  94794. }
  94795. declare module BABYLON {
  94796. /**
  94797. * Manage the pointers inputs to control an arc rotate camera.
  94798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94799. */
  94800. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94801. /**
  94802. * Defines the camera the input is attached to.
  94803. */
  94804. camera: ArcRotateCamera;
  94805. /**
  94806. * Gets the class name of the current input.
  94807. * @returns the class name
  94808. */
  94809. getClassName(): string;
  94810. /**
  94811. * Defines the buttons associated with the input to handle camera move.
  94812. */
  94813. buttons: number[];
  94814. /**
  94815. * Defines the pointer angular sensibility along the X axis or how fast is
  94816. * the camera rotating.
  94817. */
  94818. angularSensibilityX: number;
  94819. /**
  94820. * Defines the pointer angular sensibility along the Y axis or how fast is
  94821. * the camera rotating.
  94822. */
  94823. angularSensibilityY: number;
  94824. /**
  94825. * Defines the pointer pinch precision or how fast is the camera zooming.
  94826. */
  94827. pinchPrecision: number;
  94828. /**
  94829. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94830. * from 0.
  94831. * It defines the percentage of current camera.radius to use as delta when
  94832. * pinch zoom is used.
  94833. */
  94834. pinchDeltaPercentage: number;
  94835. /**
  94836. * Defines the pointer panning sensibility or how fast is the camera moving.
  94837. */
  94838. panningSensibility: number;
  94839. /**
  94840. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94841. */
  94842. multiTouchPanning: boolean;
  94843. /**
  94844. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94845. * zoom (pinch) through multitouch.
  94846. */
  94847. multiTouchPanAndZoom: boolean;
  94848. /**
  94849. * Revers pinch action direction.
  94850. */
  94851. pinchInwards: boolean;
  94852. private _isPanClick;
  94853. private _twoFingerActivityCount;
  94854. private _isPinching;
  94855. /**
  94856. * Called on pointer POINTERMOVE event if only a single touch is active.
  94857. */
  94858. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94859. /**
  94860. * Called on pointer POINTERDOUBLETAP event.
  94861. */
  94862. protected onDoubleTap(type: string): void;
  94863. /**
  94864. * Called on pointer POINTERMOVE event if multiple touches are active.
  94865. */
  94866. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94867. /**
  94868. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94869. * press.
  94870. */
  94871. protected onButtonDown(evt: PointerEvent): void;
  94872. /**
  94873. * Called each time a new POINTERUP event occurs. Ie, for each button
  94874. * release.
  94875. */
  94876. protected onButtonUp(evt: PointerEvent): void;
  94877. /**
  94878. * Called when window becomes inactive.
  94879. */
  94880. protected onLostFocus(): void;
  94881. }
  94882. }
  94883. declare module BABYLON {
  94884. /**
  94885. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94887. */
  94888. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94889. /**
  94890. * Defines the camera the input is attached to.
  94891. */
  94892. camera: ArcRotateCamera;
  94893. /**
  94894. * Defines the list of key codes associated with the up action (increase alpha)
  94895. */
  94896. keysUp: number[];
  94897. /**
  94898. * Defines the list of key codes associated with the down action (decrease alpha)
  94899. */
  94900. keysDown: number[];
  94901. /**
  94902. * Defines the list of key codes associated with the left action (increase beta)
  94903. */
  94904. keysLeft: number[];
  94905. /**
  94906. * Defines the list of key codes associated with the right action (decrease beta)
  94907. */
  94908. keysRight: number[];
  94909. /**
  94910. * Defines the list of key codes associated with the reset action.
  94911. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94912. */
  94913. keysReset: number[];
  94914. /**
  94915. * Defines the panning sensibility of the inputs.
  94916. * (How fast is the camera paning)
  94917. */
  94918. panningSensibility: number;
  94919. /**
  94920. * Defines the zooming sensibility of the inputs.
  94921. * (How fast is the camera zooming)
  94922. */
  94923. zoomingSensibility: number;
  94924. /**
  94925. * Defines wether maintaining the alt key down switch the movement mode from
  94926. * orientation to zoom.
  94927. */
  94928. useAltToZoom: boolean;
  94929. /**
  94930. * Rotation speed of the camera
  94931. */
  94932. angularSpeed: number;
  94933. private _keys;
  94934. private _ctrlPressed;
  94935. private _altPressed;
  94936. private _onCanvasBlurObserver;
  94937. private _onKeyboardObserver;
  94938. private _engine;
  94939. private _scene;
  94940. /**
  94941. * Attach the input controls to a specific dom element to get the input from.
  94942. * @param element Defines the element the controls should be listened from
  94943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94944. */
  94945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94946. /**
  94947. * Detach the current controls from the specified dom element.
  94948. * @param element Defines the element to stop listening the inputs from
  94949. */
  94950. detachControl(element: Nullable<HTMLElement>): void;
  94951. /**
  94952. * Update the current camera state depending on the inputs that have been used this frame.
  94953. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94954. */
  94955. checkInputs(): void;
  94956. /**
  94957. * Gets the class name of the current intput.
  94958. * @returns the class name
  94959. */
  94960. getClassName(): string;
  94961. /**
  94962. * Get the friendly name associated with the input class.
  94963. * @returns the input friendly name
  94964. */
  94965. getSimpleName(): string;
  94966. }
  94967. }
  94968. declare module BABYLON {
  94969. /**
  94970. * Manage the mouse wheel inputs to control an arc rotate camera.
  94971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94972. */
  94973. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94974. /**
  94975. * Defines the camera the input is attached to.
  94976. */
  94977. camera: ArcRotateCamera;
  94978. /**
  94979. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94980. */
  94981. wheelPrecision: number;
  94982. /**
  94983. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94984. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94985. */
  94986. wheelDeltaPercentage: number;
  94987. private _wheel;
  94988. private _observer;
  94989. private computeDeltaFromMouseWheelLegacyEvent;
  94990. /**
  94991. * Attach the input controls to a specific dom element to get the input from.
  94992. * @param element Defines the element the controls should be listened from
  94993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94994. */
  94995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94996. /**
  94997. * Detach the current controls from the specified dom element.
  94998. * @param element Defines the element to stop listening the inputs from
  94999. */
  95000. detachControl(element: Nullable<HTMLElement>): void;
  95001. /**
  95002. * Gets the class name of the current intput.
  95003. * @returns the class name
  95004. */
  95005. getClassName(): string;
  95006. /**
  95007. * Get the friendly name associated with the input class.
  95008. * @returns the input friendly name
  95009. */
  95010. getSimpleName(): string;
  95011. }
  95012. }
  95013. declare module BABYLON {
  95014. /**
  95015. * Default Inputs manager for the ArcRotateCamera.
  95016. * It groups all the default supported inputs for ease of use.
  95017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95018. */
  95019. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  95020. /**
  95021. * Instantiates a new ArcRotateCameraInputsManager.
  95022. * @param camera Defines the camera the inputs belong to
  95023. */
  95024. constructor(camera: ArcRotateCamera);
  95025. /**
  95026. * Add mouse wheel input support to the input manager.
  95027. * @returns the current input manager
  95028. */
  95029. addMouseWheel(): ArcRotateCameraInputsManager;
  95030. /**
  95031. * Add pointers input support to the input manager.
  95032. * @returns the current input manager
  95033. */
  95034. addPointers(): ArcRotateCameraInputsManager;
  95035. /**
  95036. * Add keyboard input support to the input manager.
  95037. * @returns the current input manager
  95038. */
  95039. addKeyboard(): ArcRotateCameraInputsManager;
  95040. }
  95041. }
  95042. declare module BABYLON {
  95043. /**
  95044. * This represents an orbital type of camera.
  95045. *
  95046. * 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.
  95047. * 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.
  95048. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95049. */
  95050. export class ArcRotateCamera extends TargetCamera {
  95051. /**
  95052. * Defines the rotation angle of the camera along the longitudinal axis.
  95053. */
  95054. alpha: number;
  95055. /**
  95056. * Defines the rotation angle of the camera along the latitudinal axis.
  95057. */
  95058. beta: number;
  95059. /**
  95060. * Defines the radius of the camera from it s target point.
  95061. */
  95062. radius: number;
  95063. protected _target: Vector3;
  95064. protected _targetHost: Nullable<AbstractMesh>;
  95065. /**
  95066. * Defines the target point of the camera.
  95067. * The camera looks towards it form the radius distance.
  95068. */
  95069. target: Vector3;
  95070. /**
  95071. * Define the current local position of the camera in the scene
  95072. */
  95073. position: Vector3;
  95074. protected _upVector: Vector3;
  95075. protected _upToYMatrix: Matrix;
  95076. protected _YToUpMatrix: Matrix;
  95077. /**
  95078. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95079. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95080. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95081. */
  95082. upVector: Vector3;
  95083. /**
  95084. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95085. */
  95086. setMatUp(): void;
  95087. /**
  95088. * Current inertia value on the longitudinal axis.
  95089. * The bigger this number the longer it will take for the camera to stop.
  95090. */
  95091. inertialAlphaOffset: number;
  95092. /**
  95093. * Current inertia value on the latitudinal axis.
  95094. * The bigger this number the longer it will take for the camera to stop.
  95095. */
  95096. inertialBetaOffset: number;
  95097. /**
  95098. * Current inertia value on the radius axis.
  95099. * The bigger this number the longer it will take for the camera to stop.
  95100. */
  95101. inertialRadiusOffset: number;
  95102. /**
  95103. * Minimum allowed angle on the longitudinal axis.
  95104. * This can help limiting how the Camera is able to move in the scene.
  95105. */
  95106. lowerAlphaLimit: Nullable<number>;
  95107. /**
  95108. * Maximum allowed angle on the longitudinal axis.
  95109. * This can help limiting how the Camera is able to move in the scene.
  95110. */
  95111. upperAlphaLimit: Nullable<number>;
  95112. /**
  95113. * Minimum allowed angle on the latitudinal axis.
  95114. * This can help limiting how the Camera is able to move in the scene.
  95115. */
  95116. lowerBetaLimit: number;
  95117. /**
  95118. * Maximum allowed angle on the latitudinal axis.
  95119. * This can help limiting how the Camera is able to move in the scene.
  95120. */
  95121. upperBetaLimit: number;
  95122. /**
  95123. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95124. * This can help limiting how the Camera is able to move in the scene.
  95125. */
  95126. lowerRadiusLimit: Nullable<number>;
  95127. /**
  95128. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95129. * This can help limiting how the Camera is able to move in the scene.
  95130. */
  95131. upperRadiusLimit: Nullable<number>;
  95132. /**
  95133. * Defines the current inertia value used during panning of the camera along the X axis.
  95134. */
  95135. inertialPanningX: number;
  95136. /**
  95137. * Defines the current inertia value used during panning of the camera along the Y axis.
  95138. */
  95139. inertialPanningY: number;
  95140. /**
  95141. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95142. * Basically if your fingers moves away from more than this distance you will be considered
  95143. * in pinch mode.
  95144. */
  95145. pinchToPanMaxDistance: number;
  95146. /**
  95147. * Defines the maximum distance the camera can pan.
  95148. * This could help keeping the cammera always in your scene.
  95149. */
  95150. panningDistanceLimit: Nullable<number>;
  95151. /**
  95152. * Defines the target of the camera before paning.
  95153. */
  95154. panningOriginTarget: Vector3;
  95155. /**
  95156. * Defines the value of the inertia used during panning.
  95157. * 0 would mean stop inertia and one would mean no decelleration at all.
  95158. */
  95159. panningInertia: number;
  95160. /**
  95161. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95162. */
  95163. angularSensibilityX: number;
  95164. /**
  95165. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95166. */
  95167. angularSensibilityY: number;
  95168. /**
  95169. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95170. */
  95171. pinchPrecision: number;
  95172. /**
  95173. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95174. * It will be used instead of pinchDeltaPrecision if different from 0.
  95175. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95176. */
  95177. pinchDeltaPercentage: number;
  95178. /**
  95179. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95180. */
  95181. panningSensibility: number;
  95182. /**
  95183. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95184. */
  95185. keysUp: number[];
  95186. /**
  95187. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95188. */
  95189. keysDown: number[];
  95190. /**
  95191. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95192. */
  95193. keysLeft: number[];
  95194. /**
  95195. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95196. */
  95197. keysRight: number[];
  95198. /**
  95199. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95200. */
  95201. wheelPrecision: number;
  95202. /**
  95203. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95204. * It will be used instead of pinchDeltaPrecision if different from 0.
  95205. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95206. */
  95207. wheelDeltaPercentage: number;
  95208. /**
  95209. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95210. */
  95211. zoomOnFactor: number;
  95212. /**
  95213. * Defines a screen offset for the camera position.
  95214. */
  95215. targetScreenOffset: Vector2;
  95216. /**
  95217. * Allows the camera to be completely reversed.
  95218. * If false the camera can not arrive upside down.
  95219. */
  95220. allowUpsideDown: boolean;
  95221. /**
  95222. * Define if double tap/click is used to restore the previously saved state of the camera.
  95223. */
  95224. useInputToRestoreState: boolean;
  95225. /** @hidden */
  95226. _viewMatrix: Matrix;
  95227. /** @hidden */
  95228. _useCtrlForPanning: boolean;
  95229. /** @hidden */
  95230. _panningMouseButton: number;
  95231. /**
  95232. * Defines the input associated to the camera.
  95233. */
  95234. inputs: ArcRotateCameraInputsManager;
  95235. /** @hidden */
  95236. _reset: () => void;
  95237. /**
  95238. * Defines the allowed panning axis.
  95239. */
  95240. panningAxis: Vector3;
  95241. protected _localDirection: Vector3;
  95242. protected _transformedDirection: Vector3;
  95243. private _bouncingBehavior;
  95244. /**
  95245. * Gets the bouncing behavior of the camera if it has been enabled.
  95246. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95247. */
  95248. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95249. /**
  95250. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95252. */
  95253. useBouncingBehavior: boolean;
  95254. private _framingBehavior;
  95255. /**
  95256. * Gets the framing behavior of the camera if it has been enabled.
  95257. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95258. */
  95259. readonly framingBehavior: Nullable<FramingBehavior>;
  95260. /**
  95261. * Defines if the framing behavior of the camera is enabled on the camera.
  95262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95263. */
  95264. useFramingBehavior: boolean;
  95265. private _autoRotationBehavior;
  95266. /**
  95267. * Gets the auto rotation behavior of the camera if it has been enabled.
  95268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95269. */
  95270. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95271. /**
  95272. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95274. */
  95275. useAutoRotationBehavior: boolean;
  95276. /**
  95277. * Observable triggered when the mesh target has been changed on the camera.
  95278. */
  95279. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95280. /**
  95281. * Event raised when the camera is colliding with a mesh.
  95282. */
  95283. onCollide: (collidedMesh: AbstractMesh) => void;
  95284. /**
  95285. * Defines whether the camera should check collision with the objects oh the scene.
  95286. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95287. */
  95288. checkCollisions: boolean;
  95289. /**
  95290. * Defines the collision radius of the camera.
  95291. * This simulates a sphere around the camera.
  95292. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95293. */
  95294. collisionRadius: Vector3;
  95295. protected _collider: Collider;
  95296. protected _previousPosition: Vector3;
  95297. protected _collisionVelocity: Vector3;
  95298. protected _newPosition: Vector3;
  95299. protected _previousAlpha: number;
  95300. protected _previousBeta: number;
  95301. protected _previousRadius: number;
  95302. protected _collisionTriggered: boolean;
  95303. protected _targetBoundingCenter: Nullable<Vector3>;
  95304. private _computationVector;
  95305. /**
  95306. * Instantiates a new ArcRotateCamera in a given scene
  95307. * @param name Defines the name of the camera
  95308. * @param alpha Defines the camera rotation along the logitudinal axis
  95309. * @param beta Defines the camera rotation along the latitudinal axis
  95310. * @param radius Defines the camera distance from its target
  95311. * @param target Defines the camera target
  95312. * @param scene Defines the scene the camera belongs to
  95313. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95314. */
  95315. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95316. /** @hidden */
  95317. _initCache(): void;
  95318. /** @hidden */
  95319. _updateCache(ignoreParentClass?: boolean): void;
  95320. protected _getTargetPosition(): Vector3;
  95321. private _storedAlpha;
  95322. private _storedBeta;
  95323. private _storedRadius;
  95324. private _storedTarget;
  95325. /**
  95326. * Stores the current state of the camera (alpha, beta, radius and target)
  95327. * @returns the camera itself
  95328. */
  95329. storeState(): Camera;
  95330. /**
  95331. * @hidden
  95332. * Restored camera state. You must call storeState() first
  95333. */
  95334. _restoreStateValues(): boolean;
  95335. /** @hidden */
  95336. _isSynchronizedViewMatrix(): boolean;
  95337. /**
  95338. * Attached controls to the current camera.
  95339. * @param element Defines the element the controls should be listened from
  95340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95341. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95342. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95343. */
  95344. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95345. /**
  95346. * Detach the current controls from the camera.
  95347. * The camera will stop reacting to inputs.
  95348. * @param element Defines the element to stop listening the inputs from
  95349. */
  95350. detachControl(element: HTMLElement): void;
  95351. /** @hidden */
  95352. _checkInputs(): void;
  95353. protected _checkLimits(): void;
  95354. /**
  95355. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95356. */
  95357. rebuildAnglesAndRadius(): void;
  95358. /**
  95359. * Use a position to define the current camera related information like aplha, beta and radius
  95360. * @param position Defines the position to set the camera at
  95361. */
  95362. setPosition(position: Vector3): void;
  95363. /**
  95364. * Defines the target the camera should look at.
  95365. * This will automatically adapt alpha beta and radius to fit within the new target.
  95366. * @param target Defines the new target as a Vector or a mesh
  95367. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95368. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95369. */
  95370. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95371. /** @hidden */
  95372. _getViewMatrix(): Matrix;
  95373. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95374. /**
  95375. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95376. * @param meshes Defines the mesh to zoom on
  95377. * @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)
  95378. */
  95379. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95380. /**
  95381. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95382. * The target will be changed but the radius
  95383. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95384. * @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)
  95385. */
  95386. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95387. min: Vector3;
  95388. max: Vector3;
  95389. distance: number;
  95390. }, doNotUpdateMaxZ?: boolean): void;
  95391. /**
  95392. * @override
  95393. * Override Camera.createRigCamera
  95394. */
  95395. createRigCamera(name: string, cameraIndex: number): Camera;
  95396. /**
  95397. * @hidden
  95398. * @override
  95399. * Override Camera._updateRigCameras
  95400. */
  95401. _updateRigCameras(): void;
  95402. /**
  95403. * Destroy the camera and release the current resources hold by it.
  95404. */
  95405. dispose(): void;
  95406. /**
  95407. * Gets the current object class name.
  95408. * @return the class name
  95409. */
  95410. getClassName(): string;
  95411. }
  95412. }
  95413. declare module BABYLON {
  95414. /**
  95415. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95416. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95417. */
  95418. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95419. /**
  95420. * Gets the name of the behavior.
  95421. */
  95422. readonly name: string;
  95423. private _zoomStopsAnimation;
  95424. private _idleRotationSpeed;
  95425. private _idleRotationWaitTime;
  95426. private _idleRotationSpinupTime;
  95427. /**
  95428. * Sets the flag that indicates if user zooming should stop animation.
  95429. */
  95430. /**
  95431. * Gets the flag that indicates if user zooming should stop animation.
  95432. */
  95433. zoomStopsAnimation: boolean;
  95434. /**
  95435. * Sets the default speed at which the camera rotates around the model.
  95436. */
  95437. /**
  95438. * Gets the default speed at which the camera rotates around the model.
  95439. */
  95440. idleRotationSpeed: number;
  95441. /**
  95442. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95443. */
  95444. /**
  95445. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95446. */
  95447. idleRotationWaitTime: number;
  95448. /**
  95449. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95450. */
  95451. /**
  95452. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95453. */
  95454. idleRotationSpinupTime: number;
  95455. /**
  95456. * Gets a value indicating if the camera is currently rotating because of this behavior
  95457. */
  95458. readonly rotationInProgress: boolean;
  95459. private _onPrePointerObservableObserver;
  95460. private _onAfterCheckInputsObserver;
  95461. private _attachedCamera;
  95462. private _isPointerDown;
  95463. private _lastFrameTime;
  95464. private _lastInteractionTime;
  95465. private _cameraRotationSpeed;
  95466. /**
  95467. * Initializes the behavior.
  95468. */
  95469. init(): void;
  95470. /**
  95471. * Attaches the behavior to its arc rotate camera.
  95472. * @param camera Defines the camera to attach the behavior to
  95473. */
  95474. attach(camera: ArcRotateCamera): void;
  95475. /**
  95476. * Detaches the behavior from its current arc rotate camera.
  95477. */
  95478. detach(): void;
  95479. /**
  95480. * Returns true if user is scrolling.
  95481. * @return true if user is scrolling.
  95482. */
  95483. private _userIsZooming;
  95484. private _lastFrameRadius;
  95485. private _shouldAnimationStopForInteraction;
  95486. /**
  95487. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95488. */
  95489. private _applyUserInteraction;
  95490. private _userIsMoving;
  95491. }
  95492. }
  95493. declare module BABYLON {
  95494. /**
  95495. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95496. */
  95497. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95498. private ui;
  95499. /**
  95500. * The name of the behavior
  95501. */
  95502. name: string;
  95503. /**
  95504. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95505. */
  95506. distanceAwayFromFace: number;
  95507. /**
  95508. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95509. */
  95510. distanceAwayFromBottomOfFace: number;
  95511. private _faceVectors;
  95512. private _target;
  95513. private _scene;
  95514. private _onRenderObserver;
  95515. private _tmpMatrix;
  95516. private _tmpVector;
  95517. /**
  95518. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95519. * @param ui The transform node that should be attched to the mesh
  95520. */
  95521. constructor(ui: TransformNode);
  95522. /**
  95523. * Initializes the behavior
  95524. */
  95525. init(): void;
  95526. private _closestFace;
  95527. private _zeroVector;
  95528. private _lookAtTmpMatrix;
  95529. private _lookAtToRef;
  95530. /**
  95531. * Attaches the AttachToBoxBehavior to the passed in mesh
  95532. * @param target The mesh that the specified node will be attached to
  95533. */
  95534. attach(target: Mesh): void;
  95535. /**
  95536. * Detaches the behavior from the mesh
  95537. */
  95538. detach(): void;
  95539. }
  95540. }
  95541. declare module BABYLON {
  95542. /**
  95543. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95544. */
  95545. export class FadeInOutBehavior implements Behavior<Mesh> {
  95546. /**
  95547. * Time in milliseconds to delay before fading in (Default: 0)
  95548. */
  95549. delay: number;
  95550. /**
  95551. * Time in milliseconds for the mesh to fade in (Default: 300)
  95552. */
  95553. fadeInTime: number;
  95554. private _millisecondsPerFrame;
  95555. private _hovered;
  95556. private _hoverValue;
  95557. private _ownerNode;
  95558. /**
  95559. * Instatiates the FadeInOutBehavior
  95560. */
  95561. constructor();
  95562. /**
  95563. * The name of the behavior
  95564. */
  95565. readonly name: string;
  95566. /**
  95567. * Initializes the behavior
  95568. */
  95569. init(): void;
  95570. /**
  95571. * Attaches the fade behavior on the passed in mesh
  95572. * @param ownerNode The mesh that will be faded in/out once attached
  95573. */
  95574. attach(ownerNode: Mesh): void;
  95575. /**
  95576. * Detaches the behavior from the mesh
  95577. */
  95578. detach(): void;
  95579. /**
  95580. * Triggers the mesh to begin fading in or out
  95581. * @param value if the object should fade in or out (true to fade in)
  95582. */
  95583. fadeIn(value: boolean): void;
  95584. private _update;
  95585. private _setAllVisibility;
  95586. }
  95587. }
  95588. declare module BABYLON {
  95589. /**
  95590. * Class containing a set of static utilities functions for managing Pivots
  95591. * @hidden
  95592. */
  95593. export class PivotTools {
  95594. private static _PivotCached;
  95595. private static _OldPivotPoint;
  95596. private static _PivotTranslation;
  95597. private static _PivotTmpVector;
  95598. /** @hidden */
  95599. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95600. /** @hidden */
  95601. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95602. }
  95603. }
  95604. declare module BABYLON {
  95605. /**
  95606. * Class containing static functions to help procedurally build meshes
  95607. */
  95608. export class PlaneBuilder {
  95609. /**
  95610. * Creates a plane mesh
  95611. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95612. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95613. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95617. * @param name defines the name of the mesh
  95618. * @param options defines the options used to create the mesh
  95619. * @param scene defines the hosting scene
  95620. * @returns the plane mesh
  95621. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95622. */
  95623. static CreatePlane(name: string, options: {
  95624. size?: number;
  95625. width?: number;
  95626. height?: number;
  95627. sideOrientation?: number;
  95628. frontUVs?: Vector4;
  95629. backUVs?: Vector4;
  95630. updatable?: boolean;
  95631. sourcePlane?: Plane;
  95632. }, scene?: Nullable<Scene>): Mesh;
  95633. }
  95634. }
  95635. declare module BABYLON {
  95636. /**
  95637. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95638. */
  95639. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95640. private static _AnyMouseID;
  95641. private _attachedNode;
  95642. private _dragPlane;
  95643. private _scene;
  95644. private _pointerObserver;
  95645. private _beforeRenderObserver;
  95646. private static _planeScene;
  95647. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95648. /**
  95649. * 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)
  95650. */
  95651. maxDragAngle: number;
  95652. /**
  95653. * @hidden
  95654. */
  95655. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95656. /**
  95657. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95658. */
  95659. currentDraggingPointerID: number;
  95660. /**
  95661. * The last position where the pointer hit the drag plane in world space
  95662. */
  95663. lastDragPosition: Vector3;
  95664. /**
  95665. * If the behavior is currently in a dragging state
  95666. */
  95667. dragging: boolean;
  95668. /**
  95669. * 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)
  95670. */
  95671. dragDeltaRatio: number;
  95672. /**
  95673. * If the drag plane orientation should be updated during the dragging (Default: true)
  95674. */
  95675. updateDragPlane: boolean;
  95676. private _debugMode;
  95677. private _moving;
  95678. /**
  95679. * Fires each time the attached mesh is dragged with the pointer
  95680. * * delta between last drag position and current drag position in world space
  95681. * * dragDistance along the drag axis
  95682. * * dragPlaneNormal normal of the current drag plane used during the drag
  95683. * * dragPlanePoint in world space where the drag intersects the drag plane
  95684. */
  95685. onDragObservable: Observable<{
  95686. delta: Vector3;
  95687. dragPlanePoint: Vector3;
  95688. dragPlaneNormal: Vector3;
  95689. dragDistance: number;
  95690. pointerId: number;
  95691. }>;
  95692. /**
  95693. * Fires each time a drag begins (eg. mouse down on mesh)
  95694. */
  95695. onDragStartObservable: Observable<{
  95696. dragPlanePoint: Vector3;
  95697. pointerId: number;
  95698. }>;
  95699. /**
  95700. * Fires each time a drag ends (eg. mouse release after drag)
  95701. */
  95702. onDragEndObservable: Observable<{
  95703. dragPlanePoint: Vector3;
  95704. pointerId: number;
  95705. }>;
  95706. /**
  95707. * If the attached mesh should be moved when dragged
  95708. */
  95709. moveAttached: boolean;
  95710. /**
  95711. * If the drag behavior will react to drag events (Default: true)
  95712. */
  95713. enabled: boolean;
  95714. /**
  95715. * If camera controls should be detached during the drag
  95716. */
  95717. detachCameraControls: boolean;
  95718. /**
  95719. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95720. */
  95721. useObjectOrienationForDragging: boolean;
  95722. private _options;
  95723. /**
  95724. * Creates a pointer drag behavior that can be attached to a mesh
  95725. * @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)
  95726. */
  95727. constructor(options?: {
  95728. dragAxis?: Vector3;
  95729. dragPlaneNormal?: Vector3;
  95730. });
  95731. /**
  95732. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95733. */
  95734. validateDrag: (targetPosition: Vector3) => boolean;
  95735. /**
  95736. * The name of the behavior
  95737. */
  95738. readonly name: string;
  95739. /**
  95740. * Initializes the behavior
  95741. */
  95742. init(): void;
  95743. private _tmpVector;
  95744. private _alternatePickedPoint;
  95745. private _worldDragAxis;
  95746. private _targetPosition;
  95747. private _attachedElement;
  95748. /**
  95749. * Attaches the drag behavior the passed in mesh
  95750. * @param ownerNode The mesh that will be dragged around once attached
  95751. */
  95752. attach(ownerNode: AbstractMesh): void;
  95753. /**
  95754. * Force relase the drag action by code.
  95755. */
  95756. releaseDrag(): void;
  95757. private _startDragRay;
  95758. private _lastPointerRay;
  95759. /**
  95760. * Simulates the start of a pointer drag event on the behavior
  95761. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95762. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95763. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95764. */
  95765. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95766. private _startDrag;
  95767. private _dragDelta;
  95768. private _moveDrag;
  95769. private _pickWithRayOnDragPlane;
  95770. private _pointA;
  95771. private _pointB;
  95772. private _pointC;
  95773. private _lineA;
  95774. private _lineB;
  95775. private _localAxis;
  95776. private _lookAt;
  95777. private _updateDragPlanePosition;
  95778. /**
  95779. * Detaches the behavior from the mesh
  95780. */
  95781. detach(): void;
  95782. }
  95783. }
  95784. declare module BABYLON {
  95785. /**
  95786. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95787. */
  95788. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95789. private _dragBehaviorA;
  95790. private _dragBehaviorB;
  95791. private _startDistance;
  95792. private _initialScale;
  95793. private _targetScale;
  95794. private _ownerNode;
  95795. private _sceneRenderObserver;
  95796. /**
  95797. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95798. */
  95799. constructor();
  95800. /**
  95801. * The name of the behavior
  95802. */
  95803. readonly name: string;
  95804. /**
  95805. * Initializes the behavior
  95806. */
  95807. init(): void;
  95808. private _getCurrentDistance;
  95809. /**
  95810. * Attaches the scale behavior the passed in mesh
  95811. * @param ownerNode The mesh that will be scaled around once attached
  95812. */
  95813. attach(ownerNode: Mesh): void;
  95814. /**
  95815. * Detaches the behavior from the mesh
  95816. */
  95817. detach(): void;
  95818. }
  95819. }
  95820. declare module BABYLON {
  95821. /**
  95822. * 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
  95823. */
  95824. export class SixDofDragBehavior implements Behavior<Mesh> {
  95825. private static _virtualScene;
  95826. private _ownerNode;
  95827. private _sceneRenderObserver;
  95828. private _scene;
  95829. private _targetPosition;
  95830. private _virtualOriginMesh;
  95831. private _virtualDragMesh;
  95832. private _pointerObserver;
  95833. private _moving;
  95834. private _startingOrientation;
  95835. /**
  95836. * 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)
  95837. */
  95838. private zDragFactor;
  95839. /**
  95840. * If the object should rotate to face the drag origin
  95841. */
  95842. rotateDraggedObject: boolean;
  95843. /**
  95844. * If the behavior is currently in a dragging state
  95845. */
  95846. dragging: boolean;
  95847. /**
  95848. * 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)
  95849. */
  95850. dragDeltaRatio: number;
  95851. /**
  95852. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95853. */
  95854. currentDraggingPointerID: number;
  95855. /**
  95856. * If camera controls should be detached during the drag
  95857. */
  95858. detachCameraControls: boolean;
  95859. /**
  95860. * Fires each time a drag starts
  95861. */
  95862. onDragStartObservable: Observable<{}>;
  95863. /**
  95864. * Fires each time a drag ends (eg. mouse release after drag)
  95865. */
  95866. onDragEndObservable: Observable<{}>;
  95867. /**
  95868. * 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
  95869. */
  95870. constructor();
  95871. /**
  95872. * The name of the behavior
  95873. */
  95874. readonly name: string;
  95875. /**
  95876. * Initializes the behavior
  95877. */
  95878. init(): void;
  95879. /**
  95880. * Attaches the scale behavior the passed in mesh
  95881. * @param ownerNode The mesh that will be scaled around once attached
  95882. */
  95883. attach(ownerNode: Mesh): void;
  95884. /**
  95885. * Detaches the behavior from the mesh
  95886. */
  95887. detach(): void;
  95888. }
  95889. }
  95890. declare module BABYLON {
  95891. /**
  95892. * Class used to apply inverse kinematics to bones
  95893. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95894. */
  95895. export class BoneIKController {
  95896. private static _tmpVecs;
  95897. private static _tmpQuat;
  95898. private static _tmpMats;
  95899. /**
  95900. * Gets or sets the target mesh
  95901. */
  95902. targetMesh: AbstractMesh;
  95903. /** Gets or sets the mesh used as pole */
  95904. poleTargetMesh: AbstractMesh;
  95905. /**
  95906. * Gets or sets the bone used as pole
  95907. */
  95908. poleTargetBone: Nullable<Bone>;
  95909. /**
  95910. * Gets or sets the target position
  95911. */
  95912. targetPosition: Vector3;
  95913. /**
  95914. * Gets or sets the pole target position
  95915. */
  95916. poleTargetPosition: Vector3;
  95917. /**
  95918. * Gets or sets the pole target local offset
  95919. */
  95920. poleTargetLocalOffset: Vector3;
  95921. /**
  95922. * Gets or sets the pole angle
  95923. */
  95924. poleAngle: number;
  95925. /**
  95926. * Gets or sets the mesh associated with the controller
  95927. */
  95928. mesh: AbstractMesh;
  95929. /**
  95930. * 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)
  95931. */
  95932. slerpAmount: number;
  95933. private _bone1Quat;
  95934. private _bone1Mat;
  95935. private _bone2Ang;
  95936. private _bone1;
  95937. private _bone2;
  95938. private _bone1Length;
  95939. private _bone2Length;
  95940. private _maxAngle;
  95941. private _maxReach;
  95942. private _rightHandedSystem;
  95943. private _bendAxis;
  95944. private _slerping;
  95945. private _adjustRoll;
  95946. /**
  95947. * Gets or sets maximum allowed angle
  95948. */
  95949. maxAngle: number;
  95950. /**
  95951. * Creates a new BoneIKController
  95952. * @param mesh defines the mesh to control
  95953. * @param bone defines the bone to control
  95954. * @param options defines options to set up the controller
  95955. */
  95956. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95957. targetMesh?: AbstractMesh;
  95958. poleTargetMesh?: AbstractMesh;
  95959. poleTargetBone?: Bone;
  95960. poleTargetLocalOffset?: Vector3;
  95961. poleAngle?: number;
  95962. bendAxis?: Vector3;
  95963. maxAngle?: number;
  95964. slerpAmount?: number;
  95965. });
  95966. private _setMaxAngle;
  95967. /**
  95968. * Force the controller to update the bones
  95969. */
  95970. update(): void;
  95971. }
  95972. }
  95973. declare module BABYLON {
  95974. /**
  95975. * Class used to make a bone look toward a point in space
  95976. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95977. */
  95978. export class BoneLookController {
  95979. private static _tmpVecs;
  95980. private static _tmpQuat;
  95981. private static _tmpMats;
  95982. /**
  95983. * The target Vector3 that the bone will look at
  95984. */
  95985. target: Vector3;
  95986. /**
  95987. * The mesh that the bone is attached to
  95988. */
  95989. mesh: AbstractMesh;
  95990. /**
  95991. * The bone that will be looking to the target
  95992. */
  95993. bone: Bone;
  95994. /**
  95995. * The up axis of the coordinate system that is used when the bone is rotated
  95996. */
  95997. upAxis: Vector3;
  95998. /**
  95999. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  96000. */
  96001. upAxisSpace: Space;
  96002. /**
  96003. * Used to make an adjustment to the yaw of the bone
  96004. */
  96005. adjustYaw: number;
  96006. /**
  96007. * Used to make an adjustment to the pitch of the bone
  96008. */
  96009. adjustPitch: number;
  96010. /**
  96011. * Used to make an adjustment to the roll of the bone
  96012. */
  96013. adjustRoll: number;
  96014. /**
  96015. * 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)
  96016. */
  96017. slerpAmount: number;
  96018. private _minYaw;
  96019. private _maxYaw;
  96020. private _minPitch;
  96021. private _maxPitch;
  96022. private _minYawSin;
  96023. private _minYawCos;
  96024. private _maxYawSin;
  96025. private _maxYawCos;
  96026. private _midYawConstraint;
  96027. private _minPitchTan;
  96028. private _maxPitchTan;
  96029. private _boneQuat;
  96030. private _slerping;
  96031. private _transformYawPitch;
  96032. private _transformYawPitchInv;
  96033. private _firstFrameSkipped;
  96034. private _yawRange;
  96035. private _fowardAxis;
  96036. /**
  96037. * Gets or sets the minimum yaw angle that the bone can look to
  96038. */
  96039. minYaw: number;
  96040. /**
  96041. * Gets or sets the maximum yaw angle that the bone can look to
  96042. */
  96043. maxYaw: number;
  96044. /**
  96045. * Gets or sets the minimum pitch angle that the bone can look to
  96046. */
  96047. minPitch: number;
  96048. /**
  96049. * Gets or sets the maximum pitch angle that the bone can look to
  96050. */
  96051. maxPitch: number;
  96052. /**
  96053. * Create a BoneLookController
  96054. * @param mesh the mesh that the bone belongs to
  96055. * @param bone the bone that will be looking to the target
  96056. * @param target the target Vector3 to look at
  96057. * @param options optional settings:
  96058. * * maxYaw: the maximum angle the bone will yaw to
  96059. * * minYaw: the minimum angle the bone will yaw to
  96060. * * maxPitch: the maximum angle the bone will pitch to
  96061. * * minPitch: the minimum angle the bone will yaw to
  96062. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96063. * * upAxis: the up axis of the coordinate system
  96064. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96065. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96066. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96067. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96068. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96069. * * adjustRoll: used to make an adjustment to the roll of the bone
  96070. **/
  96071. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96072. maxYaw?: number;
  96073. minYaw?: number;
  96074. maxPitch?: number;
  96075. minPitch?: number;
  96076. slerpAmount?: number;
  96077. upAxis?: Vector3;
  96078. upAxisSpace?: Space;
  96079. yawAxis?: Vector3;
  96080. pitchAxis?: Vector3;
  96081. adjustYaw?: number;
  96082. adjustPitch?: number;
  96083. adjustRoll?: number;
  96084. });
  96085. /**
  96086. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96087. */
  96088. update(): void;
  96089. private _getAngleDiff;
  96090. private _getAngleBetween;
  96091. private _isAngleBetween;
  96092. }
  96093. }
  96094. declare module BABYLON {
  96095. /**
  96096. * Manage the gamepad inputs to control an arc rotate camera.
  96097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96098. */
  96099. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96100. /**
  96101. * Defines the camera the input is attached to.
  96102. */
  96103. camera: ArcRotateCamera;
  96104. /**
  96105. * Defines the gamepad the input is gathering event from.
  96106. */
  96107. gamepad: Nullable<Gamepad>;
  96108. /**
  96109. * Defines the gamepad rotation sensiblity.
  96110. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96111. */
  96112. gamepadRotationSensibility: number;
  96113. /**
  96114. * Defines the gamepad move sensiblity.
  96115. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96116. */
  96117. gamepadMoveSensibility: number;
  96118. private _onGamepadConnectedObserver;
  96119. private _onGamepadDisconnectedObserver;
  96120. /**
  96121. * Attach the input controls to a specific dom element to get the input from.
  96122. * @param element Defines the element the controls should be listened from
  96123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96124. */
  96125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96126. /**
  96127. * Detach the current controls from the specified dom element.
  96128. * @param element Defines the element to stop listening the inputs from
  96129. */
  96130. detachControl(element: Nullable<HTMLElement>): void;
  96131. /**
  96132. * Update the current camera state depending on the inputs that have been used this frame.
  96133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96134. */
  96135. checkInputs(): void;
  96136. /**
  96137. * Gets the class name of the current intput.
  96138. * @returns the class name
  96139. */
  96140. getClassName(): string;
  96141. /**
  96142. * Get the friendly name associated with the input class.
  96143. * @returns the input friendly name
  96144. */
  96145. getSimpleName(): string;
  96146. }
  96147. }
  96148. declare module BABYLON {
  96149. interface ArcRotateCameraInputsManager {
  96150. /**
  96151. * Add orientation input support to the input manager.
  96152. * @returns the current input manager
  96153. */
  96154. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96155. }
  96156. /**
  96157. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96159. */
  96160. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96161. /**
  96162. * Defines the camera the input is attached to.
  96163. */
  96164. camera: ArcRotateCamera;
  96165. /**
  96166. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96167. */
  96168. alphaCorrection: number;
  96169. /**
  96170. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96171. */
  96172. gammaCorrection: number;
  96173. private _alpha;
  96174. private _gamma;
  96175. private _dirty;
  96176. private _deviceOrientationHandler;
  96177. /**
  96178. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96179. */
  96180. constructor();
  96181. /**
  96182. * Attach the input controls to a specific dom element to get the input from.
  96183. * @param element Defines the element the controls should be listened from
  96184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96185. */
  96186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96187. /** @hidden */
  96188. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96189. /**
  96190. * Update the current camera state depending on the inputs that have been used this frame.
  96191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96192. */
  96193. checkInputs(): void;
  96194. /**
  96195. * Detach the current controls from the specified dom element.
  96196. * @param element Defines the element to stop listening the inputs from
  96197. */
  96198. detachControl(element: Nullable<HTMLElement>): void;
  96199. /**
  96200. * Gets the class name of the current intput.
  96201. * @returns the class name
  96202. */
  96203. getClassName(): string;
  96204. /**
  96205. * Get the friendly name associated with the input class.
  96206. * @returns the input friendly name
  96207. */
  96208. getSimpleName(): string;
  96209. }
  96210. }
  96211. declare module BABYLON {
  96212. /**
  96213. * Listen to mouse events to control the camera.
  96214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96215. */
  96216. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96217. /**
  96218. * Defines the camera the input is attached to.
  96219. */
  96220. camera: FlyCamera;
  96221. /**
  96222. * Defines if touch is enabled. (Default is true.)
  96223. */
  96224. touchEnabled: boolean;
  96225. /**
  96226. * Defines the buttons associated with the input to handle camera rotation.
  96227. */
  96228. buttons: number[];
  96229. /**
  96230. * Assign buttons for Yaw control.
  96231. */
  96232. buttonsYaw: number[];
  96233. /**
  96234. * Assign buttons for Pitch control.
  96235. */
  96236. buttonsPitch: number[];
  96237. /**
  96238. * Assign buttons for Roll control.
  96239. */
  96240. buttonsRoll: number[];
  96241. /**
  96242. * Detect if any button is being pressed while mouse is moved.
  96243. * -1 = Mouse locked.
  96244. * 0 = Left button.
  96245. * 1 = Middle Button.
  96246. * 2 = Right Button.
  96247. */
  96248. activeButton: number;
  96249. /**
  96250. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96251. * Higher values reduce its sensitivity.
  96252. */
  96253. angularSensibility: number;
  96254. private _mousemoveCallback;
  96255. private _observer;
  96256. private _rollObserver;
  96257. private previousPosition;
  96258. private noPreventDefault;
  96259. private element;
  96260. /**
  96261. * Listen to mouse events to control the camera.
  96262. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96264. */
  96265. constructor(touchEnabled?: boolean);
  96266. /**
  96267. * Attach the mouse control to the HTML DOM element.
  96268. * @param element Defines the element that listens to the input events.
  96269. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96270. */
  96271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96272. /**
  96273. * Detach the current controls from the specified dom element.
  96274. * @param element Defines the element to stop listening the inputs from
  96275. */
  96276. detachControl(element: Nullable<HTMLElement>): void;
  96277. /**
  96278. * Gets the class name of the current input.
  96279. * @returns the class name.
  96280. */
  96281. getClassName(): string;
  96282. /**
  96283. * Get the friendly name associated with the input class.
  96284. * @returns the input's friendly name.
  96285. */
  96286. getSimpleName(): string;
  96287. private _pointerInput;
  96288. private _onMouseMove;
  96289. /**
  96290. * Rotate camera by mouse offset.
  96291. */
  96292. private rotateCamera;
  96293. }
  96294. }
  96295. declare module BABYLON {
  96296. /**
  96297. * Default Inputs manager for the FlyCamera.
  96298. * It groups all the default supported inputs for ease of use.
  96299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96300. */
  96301. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96302. /**
  96303. * Instantiates a new FlyCameraInputsManager.
  96304. * @param camera Defines the camera the inputs belong to.
  96305. */
  96306. constructor(camera: FlyCamera);
  96307. /**
  96308. * Add keyboard input support to the input manager.
  96309. * @returns the new FlyCameraKeyboardMoveInput().
  96310. */
  96311. addKeyboard(): FlyCameraInputsManager;
  96312. /**
  96313. * Add mouse input support to the input manager.
  96314. * @param touchEnabled Enable touch screen support.
  96315. * @returns the new FlyCameraMouseInput().
  96316. */
  96317. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96318. }
  96319. }
  96320. declare module BABYLON {
  96321. /**
  96322. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96323. * such as in a 3D Space Shooter or a Flight Simulator.
  96324. */
  96325. export class FlyCamera extends TargetCamera {
  96326. /**
  96327. * Define the collision ellipsoid of the camera.
  96328. * This is helpful for simulating a camera body, like a player's body.
  96329. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96330. */
  96331. ellipsoid: Vector3;
  96332. /**
  96333. * Define an offset for the position of the ellipsoid around the camera.
  96334. * This can be helpful if the camera is attached away from the player's body center,
  96335. * such as at its head.
  96336. */
  96337. ellipsoidOffset: Vector3;
  96338. /**
  96339. * Enable or disable collisions of the camera with the rest of the scene objects.
  96340. */
  96341. checkCollisions: boolean;
  96342. /**
  96343. * Enable or disable gravity on the camera.
  96344. */
  96345. applyGravity: boolean;
  96346. /**
  96347. * Define the current direction the camera is moving to.
  96348. */
  96349. cameraDirection: Vector3;
  96350. /**
  96351. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96352. * This overrides and empties cameraRotation.
  96353. */
  96354. rotationQuaternion: Quaternion;
  96355. /**
  96356. * Track Roll to maintain the wanted Rolling when looking around.
  96357. */
  96358. _trackRoll: number;
  96359. /**
  96360. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96361. */
  96362. rollCorrect: number;
  96363. /**
  96364. * Mimic a banked turn, Rolling the camera when Yawing.
  96365. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96366. */
  96367. bankedTurn: boolean;
  96368. /**
  96369. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96370. */
  96371. bankedTurnLimit: number;
  96372. /**
  96373. * Value of 0 disables the banked Roll.
  96374. * Value of 1 is equal to the Yaw angle in radians.
  96375. */
  96376. bankedTurnMultiplier: number;
  96377. /**
  96378. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96379. */
  96380. inputs: FlyCameraInputsManager;
  96381. /**
  96382. * Gets the input sensibility for mouse input.
  96383. * Higher values reduce sensitivity.
  96384. */
  96385. /**
  96386. * Sets the input sensibility for a mouse input.
  96387. * Higher values reduce sensitivity.
  96388. */
  96389. angularSensibility: number;
  96390. /**
  96391. * Get the keys for camera movement forward.
  96392. */
  96393. /**
  96394. * Set the keys for camera movement forward.
  96395. */
  96396. keysForward: number[];
  96397. /**
  96398. * Get the keys for camera movement backward.
  96399. */
  96400. keysBackward: number[];
  96401. /**
  96402. * Get the keys for camera movement up.
  96403. */
  96404. /**
  96405. * Set the keys for camera movement up.
  96406. */
  96407. keysUp: number[];
  96408. /**
  96409. * Get the keys for camera movement down.
  96410. */
  96411. /**
  96412. * Set the keys for camera movement down.
  96413. */
  96414. keysDown: number[];
  96415. /**
  96416. * Get the keys for camera movement left.
  96417. */
  96418. /**
  96419. * Set the keys for camera movement left.
  96420. */
  96421. keysLeft: number[];
  96422. /**
  96423. * Set the keys for camera movement right.
  96424. */
  96425. /**
  96426. * Set the keys for camera movement right.
  96427. */
  96428. keysRight: number[];
  96429. /**
  96430. * Event raised when the camera collides with a mesh in the scene.
  96431. */
  96432. onCollide: (collidedMesh: AbstractMesh) => void;
  96433. private _collider;
  96434. private _needMoveForGravity;
  96435. private _oldPosition;
  96436. private _diffPosition;
  96437. private _newPosition;
  96438. /** @hidden */
  96439. _localDirection: Vector3;
  96440. /** @hidden */
  96441. _transformedDirection: Vector3;
  96442. /**
  96443. * Instantiates a FlyCamera.
  96444. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96445. * such as in a 3D Space Shooter or a Flight Simulator.
  96446. * @param name Define the name of the camera in the scene.
  96447. * @param position Define the starting position of the camera in the scene.
  96448. * @param scene Define the scene the camera belongs to.
  96449. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96450. */
  96451. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96452. /**
  96453. * Attach a control to the HTML DOM element.
  96454. * @param element Defines the element that listens to the input events.
  96455. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96456. */
  96457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96458. /**
  96459. * Detach a control from the HTML DOM element.
  96460. * The camera will stop reacting to that input.
  96461. * @param element Defines the element that listens to the input events.
  96462. */
  96463. detachControl(element: HTMLElement): void;
  96464. private _collisionMask;
  96465. /**
  96466. * Get the mask that the camera ignores in collision events.
  96467. */
  96468. /**
  96469. * Set the mask that the camera ignores in collision events.
  96470. */
  96471. collisionMask: number;
  96472. /** @hidden */
  96473. _collideWithWorld(displacement: Vector3): void;
  96474. /** @hidden */
  96475. private _onCollisionPositionChange;
  96476. /** @hidden */
  96477. _checkInputs(): void;
  96478. /** @hidden */
  96479. _decideIfNeedsToMove(): boolean;
  96480. /** @hidden */
  96481. _updatePosition(): void;
  96482. /**
  96483. * Restore the Roll to its target value at the rate specified.
  96484. * @param rate - Higher means slower restoring.
  96485. * @hidden
  96486. */
  96487. restoreRoll(rate: number): void;
  96488. /**
  96489. * Destroy the camera and release the current resources held by it.
  96490. */
  96491. dispose(): void;
  96492. /**
  96493. * Get the current object class name.
  96494. * @returns the class name.
  96495. */
  96496. getClassName(): string;
  96497. }
  96498. }
  96499. declare module BABYLON {
  96500. /**
  96501. * Listen to keyboard events to control the camera.
  96502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96503. */
  96504. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96505. /**
  96506. * Defines the camera the input is attached to.
  96507. */
  96508. camera: FlyCamera;
  96509. /**
  96510. * The list of keyboard keys used to control the forward move of the camera.
  96511. */
  96512. keysForward: number[];
  96513. /**
  96514. * The list of keyboard keys used to control the backward move of the camera.
  96515. */
  96516. keysBackward: number[];
  96517. /**
  96518. * The list of keyboard keys used to control the forward move of the camera.
  96519. */
  96520. keysUp: number[];
  96521. /**
  96522. * The list of keyboard keys used to control the backward move of the camera.
  96523. */
  96524. keysDown: number[];
  96525. /**
  96526. * The list of keyboard keys used to control the right strafe move of the camera.
  96527. */
  96528. keysRight: number[];
  96529. /**
  96530. * The list of keyboard keys used to control the left strafe move of the camera.
  96531. */
  96532. keysLeft: number[];
  96533. private _keys;
  96534. private _onCanvasBlurObserver;
  96535. private _onKeyboardObserver;
  96536. private _engine;
  96537. private _scene;
  96538. /**
  96539. * Attach the input controls to a specific dom element to get the input from.
  96540. * @param element Defines the element the controls should be listened from
  96541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96542. */
  96543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96544. /**
  96545. * Detach the current controls from the specified dom element.
  96546. * @param element Defines the element to stop listening the inputs from
  96547. */
  96548. detachControl(element: Nullable<HTMLElement>): void;
  96549. /**
  96550. * Gets the class name of the current intput.
  96551. * @returns the class name
  96552. */
  96553. getClassName(): string;
  96554. /** @hidden */
  96555. _onLostFocus(e: FocusEvent): void;
  96556. /**
  96557. * Get the friendly name associated with the input class.
  96558. * @returns the input friendly name
  96559. */
  96560. getSimpleName(): string;
  96561. /**
  96562. * Update the current camera state depending on the inputs that have been used this frame.
  96563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96564. */
  96565. checkInputs(): void;
  96566. }
  96567. }
  96568. declare module BABYLON {
  96569. /**
  96570. * Manage the mouse wheel inputs to control a follow camera.
  96571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96572. */
  96573. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96574. /**
  96575. * Defines the camera the input is attached to.
  96576. */
  96577. camera: FollowCamera;
  96578. /**
  96579. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96580. */
  96581. axisControlRadius: boolean;
  96582. /**
  96583. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96584. */
  96585. axisControlHeight: boolean;
  96586. /**
  96587. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96588. */
  96589. axisControlRotation: boolean;
  96590. /**
  96591. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96592. * relation to mouseWheel events.
  96593. */
  96594. wheelPrecision: number;
  96595. /**
  96596. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96597. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96598. */
  96599. wheelDeltaPercentage: number;
  96600. private _wheel;
  96601. private _observer;
  96602. /**
  96603. * Attach the input controls to a specific dom element to get the input from.
  96604. * @param element Defines the element the controls should be listened from
  96605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96606. */
  96607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96608. /**
  96609. * Detach the current controls from the specified dom element.
  96610. * @param element Defines the element to stop listening the inputs from
  96611. */
  96612. detachControl(element: Nullable<HTMLElement>): void;
  96613. /**
  96614. * Gets the class name of the current intput.
  96615. * @returns the class name
  96616. */
  96617. getClassName(): string;
  96618. /**
  96619. * Get the friendly name associated with the input class.
  96620. * @returns the input friendly name
  96621. */
  96622. getSimpleName(): string;
  96623. }
  96624. }
  96625. declare module BABYLON {
  96626. /**
  96627. * Manage the pointers inputs to control an follow camera.
  96628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96629. */
  96630. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96631. /**
  96632. * Defines the camera the input is attached to.
  96633. */
  96634. camera: FollowCamera;
  96635. /**
  96636. * Gets the class name of the current input.
  96637. * @returns the class name
  96638. */
  96639. getClassName(): string;
  96640. /**
  96641. * Defines the pointer angular sensibility along the X axis or how fast is
  96642. * the camera rotating.
  96643. * A negative number will reverse the axis direction.
  96644. */
  96645. angularSensibilityX: number;
  96646. /**
  96647. * Defines the pointer angular sensibility along the Y axis or how fast is
  96648. * the camera rotating.
  96649. * A negative number will reverse the axis direction.
  96650. */
  96651. angularSensibilityY: number;
  96652. /**
  96653. * Defines the pointer pinch precision or how fast is the camera zooming.
  96654. * A negative number will reverse the axis direction.
  96655. */
  96656. pinchPrecision: number;
  96657. /**
  96658. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96659. * from 0.
  96660. * It defines the percentage of current camera.radius to use as delta when
  96661. * pinch zoom is used.
  96662. */
  96663. pinchDeltaPercentage: number;
  96664. /**
  96665. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96666. */
  96667. axisXControlRadius: boolean;
  96668. /**
  96669. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96670. */
  96671. axisXControlHeight: boolean;
  96672. /**
  96673. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96674. */
  96675. axisXControlRotation: boolean;
  96676. /**
  96677. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96678. */
  96679. axisYControlRadius: boolean;
  96680. /**
  96681. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96682. */
  96683. axisYControlHeight: boolean;
  96684. /**
  96685. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96686. */
  96687. axisYControlRotation: boolean;
  96688. /**
  96689. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96690. */
  96691. axisPinchControlRadius: boolean;
  96692. /**
  96693. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96694. */
  96695. axisPinchControlHeight: boolean;
  96696. /**
  96697. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96698. */
  96699. axisPinchControlRotation: boolean;
  96700. /**
  96701. * Log error messages if basic misconfiguration has occurred.
  96702. */
  96703. warningEnable: boolean;
  96704. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96705. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96706. private _warningCounter;
  96707. private _warning;
  96708. }
  96709. }
  96710. declare module BABYLON {
  96711. /**
  96712. * Default Inputs manager for the FollowCamera.
  96713. * It groups all the default supported inputs for ease of use.
  96714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96715. */
  96716. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96717. /**
  96718. * Instantiates a new FollowCameraInputsManager.
  96719. * @param camera Defines the camera the inputs belong to
  96720. */
  96721. constructor(camera: FollowCamera);
  96722. /**
  96723. * Add keyboard input support to the input manager.
  96724. * @returns the current input manager
  96725. */
  96726. addKeyboard(): FollowCameraInputsManager;
  96727. /**
  96728. * Add mouse wheel input support to the input manager.
  96729. * @returns the current input manager
  96730. */
  96731. addMouseWheel(): FollowCameraInputsManager;
  96732. /**
  96733. * Add pointers input support to the input manager.
  96734. * @returns the current input manager
  96735. */
  96736. addPointers(): FollowCameraInputsManager;
  96737. /**
  96738. * Add orientation input support to the input manager.
  96739. * @returns the current input manager
  96740. */
  96741. addVRDeviceOrientation(): FollowCameraInputsManager;
  96742. }
  96743. }
  96744. declare module BABYLON {
  96745. /**
  96746. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96747. * an arc rotate version arcFollowCamera are available.
  96748. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96749. */
  96750. export class FollowCamera extends TargetCamera {
  96751. /**
  96752. * Distance the follow camera should follow an object at
  96753. */
  96754. radius: number;
  96755. /**
  96756. * Minimum allowed distance of the camera to the axis of rotation
  96757. * (The camera can not get closer).
  96758. * This can help limiting how the Camera is able to move in the scene.
  96759. */
  96760. lowerRadiusLimit: Nullable<number>;
  96761. /**
  96762. * Maximum allowed distance of the camera to the axis of rotation
  96763. * (The camera can not get further).
  96764. * This can help limiting how the Camera is able to move in the scene.
  96765. */
  96766. upperRadiusLimit: Nullable<number>;
  96767. /**
  96768. * Define a rotation offset between the camera and the object it follows
  96769. */
  96770. rotationOffset: number;
  96771. /**
  96772. * Minimum allowed angle to camera position relative to target object.
  96773. * This can help limiting how the Camera is able to move in the scene.
  96774. */
  96775. lowerRotationOffsetLimit: Nullable<number>;
  96776. /**
  96777. * Maximum allowed angle to camera position relative to target object.
  96778. * This can help limiting how the Camera is able to move in the scene.
  96779. */
  96780. upperRotationOffsetLimit: Nullable<number>;
  96781. /**
  96782. * Define a height offset between the camera and the object it follows.
  96783. * It can help following an object from the top (like a car chaing a plane)
  96784. */
  96785. heightOffset: number;
  96786. /**
  96787. * Minimum allowed height of camera position relative to target object.
  96788. * This can help limiting how the Camera is able to move in the scene.
  96789. */
  96790. lowerHeightOffsetLimit: Nullable<number>;
  96791. /**
  96792. * Maximum allowed height of camera position relative to target object.
  96793. * This can help limiting how the Camera is able to move in the scene.
  96794. */
  96795. upperHeightOffsetLimit: Nullable<number>;
  96796. /**
  96797. * Define how fast the camera can accelerate to follow it s target.
  96798. */
  96799. cameraAcceleration: number;
  96800. /**
  96801. * Define the speed limit of the camera following an object.
  96802. */
  96803. maxCameraSpeed: number;
  96804. /**
  96805. * Define the target of the camera.
  96806. */
  96807. lockedTarget: Nullable<AbstractMesh>;
  96808. /**
  96809. * Defines the input associated with the camera.
  96810. */
  96811. inputs: FollowCameraInputsManager;
  96812. /**
  96813. * Instantiates the follow camera.
  96814. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96815. * @param name Define the name of the camera in the scene
  96816. * @param position Define the position of the camera
  96817. * @param scene Define the scene the camera belong to
  96818. * @param lockedTarget Define the target of the camera
  96819. */
  96820. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96821. private _follow;
  96822. /**
  96823. * Attached controls to the current camera.
  96824. * @param element Defines the element the controls should be listened from
  96825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96826. */
  96827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96828. /**
  96829. * Detach the current controls from the camera.
  96830. * The camera will stop reacting to inputs.
  96831. * @param element Defines the element to stop listening the inputs from
  96832. */
  96833. detachControl(element: HTMLElement): void;
  96834. /** @hidden */
  96835. _checkInputs(): void;
  96836. private _checkLimits;
  96837. /**
  96838. * Gets the camera class name.
  96839. * @returns the class name
  96840. */
  96841. getClassName(): string;
  96842. }
  96843. /**
  96844. * Arc Rotate version of the follow camera.
  96845. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96846. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96847. */
  96848. export class ArcFollowCamera extends TargetCamera {
  96849. /** The longitudinal angle of the camera */
  96850. alpha: number;
  96851. /** The latitudinal angle of the camera */
  96852. beta: number;
  96853. /** The radius of the camera from its target */
  96854. radius: number;
  96855. /** Define the camera target (the messh it should follow) */
  96856. target: Nullable<AbstractMesh>;
  96857. private _cartesianCoordinates;
  96858. /**
  96859. * Instantiates a new ArcFollowCamera
  96860. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96861. * @param name Define the name of the camera
  96862. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96863. * @param beta Define the rotation angle of the camera around the elevation axis
  96864. * @param radius Define the radius of the camera from its target point
  96865. * @param target Define the target of the camera
  96866. * @param scene Define the scene the camera belongs to
  96867. */
  96868. constructor(name: string,
  96869. /** The longitudinal angle of the camera */
  96870. alpha: number,
  96871. /** The latitudinal angle of the camera */
  96872. beta: number,
  96873. /** The radius of the camera from its target */
  96874. radius: number,
  96875. /** Define the camera target (the messh it should follow) */
  96876. target: Nullable<AbstractMesh>, scene: Scene);
  96877. private _follow;
  96878. /** @hidden */
  96879. _checkInputs(): void;
  96880. /**
  96881. * Returns the class name of the object.
  96882. * It is mostly used internally for serialization purposes.
  96883. */
  96884. getClassName(): string;
  96885. }
  96886. }
  96887. declare module BABYLON {
  96888. /**
  96889. * Manage the keyboard inputs to control the movement of a follow camera.
  96890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96891. */
  96892. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96893. /**
  96894. * Defines the camera the input is attached to.
  96895. */
  96896. camera: FollowCamera;
  96897. /**
  96898. * Defines the list of key codes associated with the up action (increase heightOffset)
  96899. */
  96900. keysHeightOffsetIncr: number[];
  96901. /**
  96902. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96903. */
  96904. keysHeightOffsetDecr: number[];
  96905. /**
  96906. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96907. */
  96908. keysHeightOffsetModifierAlt: boolean;
  96909. /**
  96910. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96911. */
  96912. keysHeightOffsetModifierCtrl: boolean;
  96913. /**
  96914. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96915. */
  96916. keysHeightOffsetModifierShift: boolean;
  96917. /**
  96918. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96919. */
  96920. keysRotationOffsetIncr: number[];
  96921. /**
  96922. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96923. */
  96924. keysRotationOffsetDecr: number[];
  96925. /**
  96926. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96927. */
  96928. keysRotationOffsetModifierAlt: boolean;
  96929. /**
  96930. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96931. */
  96932. keysRotationOffsetModifierCtrl: boolean;
  96933. /**
  96934. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96935. */
  96936. keysRotationOffsetModifierShift: boolean;
  96937. /**
  96938. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96939. */
  96940. keysRadiusIncr: number[];
  96941. /**
  96942. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96943. */
  96944. keysRadiusDecr: number[];
  96945. /**
  96946. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96947. */
  96948. keysRadiusModifierAlt: boolean;
  96949. /**
  96950. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96951. */
  96952. keysRadiusModifierCtrl: boolean;
  96953. /**
  96954. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96955. */
  96956. keysRadiusModifierShift: boolean;
  96957. /**
  96958. * Defines the rate of change of heightOffset.
  96959. */
  96960. heightSensibility: number;
  96961. /**
  96962. * Defines the rate of change of rotationOffset.
  96963. */
  96964. rotationSensibility: number;
  96965. /**
  96966. * Defines the rate of change of radius.
  96967. */
  96968. radiusSensibility: number;
  96969. private _keys;
  96970. private _ctrlPressed;
  96971. private _altPressed;
  96972. private _shiftPressed;
  96973. private _onCanvasBlurObserver;
  96974. private _onKeyboardObserver;
  96975. private _engine;
  96976. private _scene;
  96977. /**
  96978. * Attach the input controls to a specific dom element to get the input from.
  96979. * @param element Defines the element the controls should be listened from
  96980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96981. */
  96982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96983. /**
  96984. * Detach the current controls from the specified dom element.
  96985. * @param element Defines the element to stop listening the inputs from
  96986. */
  96987. detachControl(element: Nullable<HTMLElement>): void;
  96988. /**
  96989. * Update the current camera state depending on the inputs that have been used this frame.
  96990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96991. */
  96992. checkInputs(): void;
  96993. /**
  96994. * Gets the class name of the current input.
  96995. * @returns the class name
  96996. */
  96997. getClassName(): string;
  96998. /**
  96999. * Get the friendly name associated with the input class.
  97000. * @returns the input friendly name
  97001. */
  97002. getSimpleName(): string;
  97003. /**
  97004. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97005. * allow modification of the heightOffset value.
  97006. */
  97007. private _modifierHeightOffset;
  97008. /**
  97009. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97010. * allow modification of the rotationOffset value.
  97011. */
  97012. private _modifierRotationOffset;
  97013. /**
  97014. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97015. * allow modification of the radius value.
  97016. */
  97017. private _modifierRadius;
  97018. }
  97019. }
  97020. declare module BABYLON {
  97021. interface FreeCameraInputsManager {
  97022. /**
  97023. * @hidden
  97024. */
  97025. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  97026. /**
  97027. * Add orientation input support to the input manager.
  97028. * @returns the current input manager
  97029. */
  97030. addDeviceOrientation(): FreeCameraInputsManager;
  97031. }
  97032. /**
  97033. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  97034. * Screen rotation is taken into account.
  97035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97036. */
  97037. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97038. private _camera;
  97039. private _screenOrientationAngle;
  97040. private _constantTranform;
  97041. private _screenQuaternion;
  97042. private _alpha;
  97043. private _beta;
  97044. private _gamma;
  97045. /**
  97046. * @hidden
  97047. */
  97048. _onDeviceOrientationChangedObservable: Observable<void>;
  97049. /**
  97050. * Instantiates a new input
  97051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97052. */
  97053. constructor();
  97054. /**
  97055. * Define the camera controlled by the input.
  97056. */
  97057. camera: FreeCamera;
  97058. /**
  97059. * Attach the input controls to a specific dom element to get the input from.
  97060. * @param element Defines the element the controls should be listened from
  97061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97062. */
  97063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97064. private _orientationChanged;
  97065. private _deviceOrientation;
  97066. /**
  97067. * Detach the current controls from the specified dom element.
  97068. * @param element Defines the element to stop listening the inputs from
  97069. */
  97070. detachControl(element: Nullable<HTMLElement>): void;
  97071. /**
  97072. * Update the current camera state depending on the inputs that have been used this frame.
  97073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97074. */
  97075. checkInputs(): void;
  97076. /**
  97077. * Gets the class name of the current intput.
  97078. * @returns the class name
  97079. */
  97080. getClassName(): string;
  97081. /**
  97082. * Get the friendly name associated with the input class.
  97083. * @returns the input friendly name
  97084. */
  97085. getSimpleName(): string;
  97086. }
  97087. }
  97088. declare module BABYLON {
  97089. /**
  97090. * Manage the gamepad inputs to control a free camera.
  97091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97092. */
  97093. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97094. /**
  97095. * Define the camera the input is attached to.
  97096. */
  97097. camera: FreeCamera;
  97098. /**
  97099. * Define the Gamepad controlling the input
  97100. */
  97101. gamepad: Nullable<Gamepad>;
  97102. /**
  97103. * Defines the gamepad rotation sensiblity.
  97104. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97105. */
  97106. gamepadAngularSensibility: number;
  97107. /**
  97108. * Defines the gamepad move sensiblity.
  97109. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97110. */
  97111. gamepadMoveSensibility: number;
  97112. private _onGamepadConnectedObserver;
  97113. private _onGamepadDisconnectedObserver;
  97114. private _cameraTransform;
  97115. private _deltaTransform;
  97116. private _vector3;
  97117. private _vector2;
  97118. /**
  97119. * Attach the input controls to a specific dom element to get the input from.
  97120. * @param element Defines the element the controls should be listened from
  97121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97122. */
  97123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97124. /**
  97125. * Detach the current controls from the specified dom element.
  97126. * @param element Defines the element to stop listening the inputs from
  97127. */
  97128. detachControl(element: Nullable<HTMLElement>): void;
  97129. /**
  97130. * Update the current camera state depending on the inputs that have been used this frame.
  97131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97132. */
  97133. checkInputs(): void;
  97134. /**
  97135. * Gets the class name of the current intput.
  97136. * @returns the class name
  97137. */
  97138. getClassName(): string;
  97139. /**
  97140. * Get the friendly name associated with the input class.
  97141. * @returns the input friendly name
  97142. */
  97143. getSimpleName(): string;
  97144. }
  97145. }
  97146. declare module BABYLON {
  97147. /**
  97148. * Defines the potential axis of a Joystick
  97149. */
  97150. export enum JoystickAxis {
  97151. /** X axis */
  97152. X = 0,
  97153. /** Y axis */
  97154. Y = 1,
  97155. /** Z axis */
  97156. Z = 2
  97157. }
  97158. /**
  97159. * Class used to define virtual joystick (used in touch mode)
  97160. */
  97161. export class VirtualJoystick {
  97162. /**
  97163. * Gets or sets a boolean indicating that left and right values must be inverted
  97164. */
  97165. reverseLeftRight: boolean;
  97166. /**
  97167. * Gets or sets a boolean indicating that up and down values must be inverted
  97168. */
  97169. reverseUpDown: boolean;
  97170. /**
  97171. * Gets the offset value for the position (ie. the change of the position value)
  97172. */
  97173. deltaPosition: Vector3;
  97174. /**
  97175. * Gets a boolean indicating if the virtual joystick was pressed
  97176. */
  97177. pressed: boolean;
  97178. /**
  97179. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97180. */
  97181. static Canvas: Nullable<HTMLCanvasElement>;
  97182. private static _globalJoystickIndex;
  97183. private static vjCanvasContext;
  97184. private static vjCanvasWidth;
  97185. private static vjCanvasHeight;
  97186. private static halfWidth;
  97187. private _action;
  97188. private _axisTargetedByLeftAndRight;
  97189. private _axisTargetedByUpAndDown;
  97190. private _joystickSensibility;
  97191. private _inversedSensibility;
  97192. private _joystickPointerID;
  97193. private _joystickColor;
  97194. private _joystickPointerPos;
  97195. private _joystickPreviousPointerPos;
  97196. private _joystickPointerStartPos;
  97197. private _deltaJoystickVector;
  97198. private _leftJoystick;
  97199. private _touches;
  97200. private _onPointerDownHandlerRef;
  97201. private _onPointerMoveHandlerRef;
  97202. private _onPointerUpHandlerRef;
  97203. private _onResize;
  97204. /**
  97205. * Creates a new virtual joystick
  97206. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97207. */
  97208. constructor(leftJoystick?: boolean);
  97209. /**
  97210. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97211. * @param newJoystickSensibility defines the new sensibility
  97212. */
  97213. setJoystickSensibility(newJoystickSensibility: number): void;
  97214. private _onPointerDown;
  97215. private _onPointerMove;
  97216. private _onPointerUp;
  97217. /**
  97218. * Change the color of the virtual joystick
  97219. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97220. */
  97221. setJoystickColor(newColor: string): void;
  97222. /**
  97223. * Defines a callback to call when the joystick is touched
  97224. * @param action defines the callback
  97225. */
  97226. setActionOnTouch(action: () => any): void;
  97227. /**
  97228. * Defines which axis you'd like to control for left & right
  97229. * @param axis defines the axis to use
  97230. */
  97231. setAxisForLeftRight(axis: JoystickAxis): void;
  97232. /**
  97233. * Defines which axis you'd like to control for up & down
  97234. * @param axis defines the axis to use
  97235. */
  97236. setAxisForUpDown(axis: JoystickAxis): void;
  97237. private _drawVirtualJoystick;
  97238. /**
  97239. * Release internal HTML canvas
  97240. */
  97241. releaseCanvas(): void;
  97242. }
  97243. }
  97244. declare module BABYLON {
  97245. interface FreeCameraInputsManager {
  97246. /**
  97247. * Add virtual joystick input support to the input manager.
  97248. * @returns the current input manager
  97249. */
  97250. addVirtualJoystick(): FreeCameraInputsManager;
  97251. }
  97252. /**
  97253. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97255. */
  97256. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97257. /**
  97258. * Defines the camera the input is attached to.
  97259. */
  97260. camera: FreeCamera;
  97261. private _leftjoystick;
  97262. private _rightjoystick;
  97263. /**
  97264. * Gets the left stick of the virtual joystick.
  97265. * @returns The virtual Joystick
  97266. */
  97267. getLeftJoystick(): VirtualJoystick;
  97268. /**
  97269. * Gets the right stick of the virtual joystick.
  97270. * @returns The virtual Joystick
  97271. */
  97272. getRightJoystick(): VirtualJoystick;
  97273. /**
  97274. * Update the current camera state depending on the inputs that have been used this frame.
  97275. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97276. */
  97277. checkInputs(): void;
  97278. /**
  97279. * Attach the input controls to a specific dom element to get the input from.
  97280. * @param element Defines the element the controls should be listened from
  97281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97282. */
  97283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97284. /**
  97285. * Detach the current controls from the specified dom element.
  97286. * @param element Defines the element to stop listening the inputs from
  97287. */
  97288. detachControl(element: Nullable<HTMLElement>): void;
  97289. /**
  97290. * Gets the class name of the current intput.
  97291. * @returns the class name
  97292. */
  97293. getClassName(): string;
  97294. /**
  97295. * Get the friendly name associated with the input class.
  97296. * @returns the input friendly name
  97297. */
  97298. getSimpleName(): string;
  97299. }
  97300. }
  97301. declare module BABYLON {
  97302. /**
  97303. * This represents a FPS type of camera controlled by touch.
  97304. * This is like a universal camera minus the Gamepad controls.
  97305. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97306. */
  97307. export class TouchCamera extends FreeCamera {
  97308. /**
  97309. * Defines the touch sensibility for rotation.
  97310. * The higher the faster.
  97311. */
  97312. touchAngularSensibility: number;
  97313. /**
  97314. * Defines the touch sensibility for move.
  97315. * The higher the faster.
  97316. */
  97317. touchMoveSensibility: number;
  97318. /**
  97319. * Instantiates a new touch camera.
  97320. * This represents a FPS type of camera controlled by touch.
  97321. * This is like a universal camera minus the Gamepad controls.
  97322. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97323. * @param name Define the name of the camera in the scene
  97324. * @param position Define the start position of the camera in the scene
  97325. * @param scene Define the scene the camera belongs to
  97326. */
  97327. constructor(name: string, position: Vector3, scene: Scene);
  97328. /**
  97329. * Gets the current object class name.
  97330. * @return the class name
  97331. */
  97332. getClassName(): string;
  97333. /** @hidden */
  97334. _setupInputs(): void;
  97335. }
  97336. }
  97337. declare module BABYLON {
  97338. /**
  97339. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97340. * being tilted forward or back and left or right.
  97341. */
  97342. export class DeviceOrientationCamera extends FreeCamera {
  97343. private _initialQuaternion;
  97344. private _quaternionCache;
  97345. private _tmpDragQuaternion;
  97346. /**
  97347. * Creates a new device orientation camera
  97348. * @param name The name of the camera
  97349. * @param position The start position camera
  97350. * @param scene The scene the camera belongs to
  97351. */
  97352. constructor(name: string, position: Vector3, scene: Scene);
  97353. /**
  97354. * @hidden
  97355. * Disabled pointer input on first orientation sensor update (Default: true)
  97356. */
  97357. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97358. private _dragFactor;
  97359. /**
  97360. * Enabled turning on the y axis when the orientation sensor is active
  97361. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97362. */
  97363. enableHorizontalDragging(dragFactor?: number): void;
  97364. /**
  97365. * Gets the current instance class name ("DeviceOrientationCamera").
  97366. * This helps avoiding instanceof at run time.
  97367. * @returns the class name
  97368. */
  97369. getClassName(): string;
  97370. /**
  97371. * @hidden
  97372. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97373. */
  97374. _checkInputs(): void;
  97375. /**
  97376. * Reset the camera to its default orientation on the specified axis only.
  97377. * @param axis The axis to reset
  97378. */
  97379. resetToCurrentRotation(axis?: Axis): void;
  97380. }
  97381. }
  97382. declare module BABYLON {
  97383. /**
  97384. * Defines supported buttons for XBox360 compatible gamepads
  97385. */
  97386. export enum Xbox360Button {
  97387. /** A */
  97388. A = 0,
  97389. /** B */
  97390. B = 1,
  97391. /** X */
  97392. X = 2,
  97393. /** Y */
  97394. Y = 3,
  97395. /** Start */
  97396. Start = 4,
  97397. /** Back */
  97398. Back = 5,
  97399. /** Left button */
  97400. LB = 6,
  97401. /** Right button */
  97402. RB = 7,
  97403. /** Left stick */
  97404. LeftStick = 8,
  97405. /** Right stick */
  97406. RightStick = 9
  97407. }
  97408. /** Defines values for XBox360 DPad */
  97409. export enum Xbox360Dpad {
  97410. /** Up */
  97411. Up = 0,
  97412. /** Down */
  97413. Down = 1,
  97414. /** Left */
  97415. Left = 2,
  97416. /** Right */
  97417. Right = 3
  97418. }
  97419. /**
  97420. * Defines a XBox360 gamepad
  97421. */
  97422. export class Xbox360Pad extends Gamepad {
  97423. private _leftTrigger;
  97424. private _rightTrigger;
  97425. private _onlefttriggerchanged;
  97426. private _onrighttriggerchanged;
  97427. private _onbuttondown;
  97428. private _onbuttonup;
  97429. private _ondpaddown;
  97430. private _ondpadup;
  97431. /** Observable raised when a button is pressed */
  97432. onButtonDownObservable: Observable<Xbox360Button>;
  97433. /** Observable raised when a button is released */
  97434. onButtonUpObservable: Observable<Xbox360Button>;
  97435. /** Observable raised when a pad is pressed */
  97436. onPadDownObservable: Observable<Xbox360Dpad>;
  97437. /** Observable raised when a pad is released */
  97438. onPadUpObservable: Observable<Xbox360Dpad>;
  97439. private _buttonA;
  97440. private _buttonB;
  97441. private _buttonX;
  97442. private _buttonY;
  97443. private _buttonBack;
  97444. private _buttonStart;
  97445. private _buttonLB;
  97446. private _buttonRB;
  97447. private _buttonLeftStick;
  97448. private _buttonRightStick;
  97449. private _dPadUp;
  97450. private _dPadDown;
  97451. private _dPadLeft;
  97452. private _dPadRight;
  97453. private _isXboxOnePad;
  97454. /**
  97455. * Creates a new XBox360 gamepad object
  97456. * @param id defines the id of this gamepad
  97457. * @param index defines its index
  97458. * @param gamepad defines the internal HTML gamepad object
  97459. * @param xboxOne defines if it is a XBox One gamepad
  97460. */
  97461. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97462. /**
  97463. * Defines the callback to call when left trigger is pressed
  97464. * @param callback defines the callback to use
  97465. */
  97466. onlefttriggerchanged(callback: (value: number) => void): void;
  97467. /**
  97468. * Defines the callback to call when right trigger is pressed
  97469. * @param callback defines the callback to use
  97470. */
  97471. onrighttriggerchanged(callback: (value: number) => void): void;
  97472. /**
  97473. * Gets the left trigger value
  97474. */
  97475. /**
  97476. * Sets the left trigger value
  97477. */
  97478. leftTrigger: number;
  97479. /**
  97480. * Gets the right trigger value
  97481. */
  97482. /**
  97483. * Sets the right trigger value
  97484. */
  97485. rightTrigger: number;
  97486. /**
  97487. * Defines the callback to call when a button is pressed
  97488. * @param callback defines the callback to use
  97489. */
  97490. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97491. /**
  97492. * Defines the callback to call when a button is released
  97493. * @param callback defines the callback to use
  97494. */
  97495. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97496. /**
  97497. * Defines the callback to call when a pad is pressed
  97498. * @param callback defines the callback to use
  97499. */
  97500. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97501. /**
  97502. * Defines the callback to call when a pad is released
  97503. * @param callback defines the callback to use
  97504. */
  97505. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97506. private _setButtonValue;
  97507. private _setDPadValue;
  97508. /**
  97509. * Gets the value of the `A` button
  97510. */
  97511. /**
  97512. * Sets the value of the `A` button
  97513. */
  97514. buttonA: number;
  97515. /**
  97516. * Gets the value of the `B` button
  97517. */
  97518. /**
  97519. * Sets the value of the `B` button
  97520. */
  97521. buttonB: number;
  97522. /**
  97523. * Gets the value of the `X` button
  97524. */
  97525. /**
  97526. * Sets the value of the `X` button
  97527. */
  97528. buttonX: number;
  97529. /**
  97530. * Gets the value of the `Y` button
  97531. */
  97532. /**
  97533. * Sets the value of the `Y` button
  97534. */
  97535. buttonY: number;
  97536. /**
  97537. * Gets the value of the `Start` button
  97538. */
  97539. /**
  97540. * Sets the value of the `Start` button
  97541. */
  97542. buttonStart: number;
  97543. /**
  97544. * Gets the value of the `Back` button
  97545. */
  97546. /**
  97547. * Sets the value of the `Back` button
  97548. */
  97549. buttonBack: number;
  97550. /**
  97551. * Gets the value of the `Left` button
  97552. */
  97553. /**
  97554. * Sets the value of the `Left` button
  97555. */
  97556. buttonLB: number;
  97557. /**
  97558. * Gets the value of the `Right` button
  97559. */
  97560. /**
  97561. * Sets the value of the `Right` button
  97562. */
  97563. buttonRB: number;
  97564. /**
  97565. * Gets the value of the Left joystick
  97566. */
  97567. /**
  97568. * Sets the value of the Left joystick
  97569. */
  97570. buttonLeftStick: number;
  97571. /**
  97572. * Gets the value of the Right joystick
  97573. */
  97574. /**
  97575. * Sets the value of the Right joystick
  97576. */
  97577. buttonRightStick: number;
  97578. /**
  97579. * Gets the value of D-pad up
  97580. */
  97581. /**
  97582. * Sets the value of D-pad up
  97583. */
  97584. dPadUp: number;
  97585. /**
  97586. * Gets the value of D-pad down
  97587. */
  97588. /**
  97589. * Sets the value of D-pad down
  97590. */
  97591. dPadDown: number;
  97592. /**
  97593. * Gets the value of D-pad left
  97594. */
  97595. /**
  97596. * Sets the value of D-pad left
  97597. */
  97598. dPadLeft: number;
  97599. /**
  97600. * Gets the value of D-pad right
  97601. */
  97602. /**
  97603. * Sets the value of D-pad right
  97604. */
  97605. dPadRight: number;
  97606. /**
  97607. * Force the gamepad to synchronize with device values
  97608. */
  97609. update(): void;
  97610. /**
  97611. * Disposes the gamepad
  97612. */
  97613. dispose(): void;
  97614. }
  97615. }
  97616. declare module BABYLON {
  97617. /**
  97618. * Manager for handling gamepads
  97619. */
  97620. export class GamepadManager {
  97621. private _scene?;
  97622. private _babylonGamepads;
  97623. private _oneGamepadConnected;
  97624. /** @hidden */
  97625. _isMonitoring: boolean;
  97626. private _gamepadEventSupported;
  97627. private _gamepadSupport;
  97628. /**
  97629. * observable to be triggered when the gamepad controller has been connected
  97630. */
  97631. onGamepadConnectedObservable: Observable<Gamepad>;
  97632. /**
  97633. * observable to be triggered when the gamepad controller has been disconnected
  97634. */
  97635. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97636. private _onGamepadConnectedEvent;
  97637. private _onGamepadDisconnectedEvent;
  97638. /**
  97639. * Initializes the gamepad manager
  97640. * @param _scene BabylonJS scene
  97641. */
  97642. constructor(_scene?: Scene | undefined);
  97643. /**
  97644. * The gamepads in the game pad manager
  97645. */
  97646. readonly gamepads: Gamepad[];
  97647. /**
  97648. * Get the gamepad controllers based on type
  97649. * @param type The type of gamepad controller
  97650. * @returns Nullable gamepad
  97651. */
  97652. getGamepadByType(type?: number): Nullable<Gamepad>;
  97653. /**
  97654. * Disposes the gamepad manager
  97655. */
  97656. dispose(): void;
  97657. private _addNewGamepad;
  97658. private _startMonitoringGamepads;
  97659. private _stopMonitoringGamepads;
  97660. /** @hidden */
  97661. _checkGamepadsStatus(): void;
  97662. private _updateGamepadObjects;
  97663. }
  97664. }
  97665. declare module BABYLON {
  97666. interface Scene {
  97667. /** @hidden */
  97668. _gamepadManager: Nullable<GamepadManager>;
  97669. /**
  97670. * Gets the gamepad manager associated with the scene
  97671. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97672. */
  97673. gamepadManager: GamepadManager;
  97674. }
  97675. /**
  97676. * Interface representing a free camera inputs manager
  97677. */
  97678. interface FreeCameraInputsManager {
  97679. /**
  97680. * Adds gamepad input support to the FreeCameraInputsManager.
  97681. * @returns the FreeCameraInputsManager
  97682. */
  97683. addGamepad(): FreeCameraInputsManager;
  97684. }
  97685. /**
  97686. * Interface representing an arc rotate camera inputs manager
  97687. */
  97688. interface ArcRotateCameraInputsManager {
  97689. /**
  97690. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97691. * @returns the camera inputs manager
  97692. */
  97693. addGamepad(): ArcRotateCameraInputsManager;
  97694. }
  97695. /**
  97696. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97697. */
  97698. export class GamepadSystemSceneComponent implements ISceneComponent {
  97699. /**
  97700. * The component name helpfull to identify the component in the list of scene components.
  97701. */
  97702. readonly name: string;
  97703. /**
  97704. * The scene the component belongs to.
  97705. */
  97706. scene: Scene;
  97707. /**
  97708. * Creates a new instance of the component for the given scene
  97709. * @param scene Defines the scene to register the component in
  97710. */
  97711. constructor(scene: Scene);
  97712. /**
  97713. * Registers the component in a given scene
  97714. */
  97715. register(): void;
  97716. /**
  97717. * Rebuilds the elements related to this component in case of
  97718. * context lost for instance.
  97719. */
  97720. rebuild(): void;
  97721. /**
  97722. * Disposes the component and the associated ressources
  97723. */
  97724. dispose(): void;
  97725. private _beforeCameraUpdate;
  97726. }
  97727. }
  97728. declare module BABYLON {
  97729. /**
  97730. * 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,
  97731. * which still works and will still be found in many Playgrounds.
  97732. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97733. */
  97734. export class UniversalCamera extends TouchCamera {
  97735. /**
  97736. * Defines the gamepad rotation sensiblity.
  97737. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97738. */
  97739. gamepadAngularSensibility: number;
  97740. /**
  97741. * Defines the gamepad move sensiblity.
  97742. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97743. */
  97744. gamepadMoveSensibility: number;
  97745. /**
  97746. * 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,
  97747. * which still works and will still be found in many Playgrounds.
  97748. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97749. * @param name Define the name of the camera in the scene
  97750. * @param position Define the start position of the camera in the scene
  97751. * @param scene Define the scene the camera belongs to
  97752. */
  97753. constructor(name: string, position: Vector3, scene: Scene);
  97754. /**
  97755. * Gets the current object class name.
  97756. * @return the class name
  97757. */
  97758. getClassName(): string;
  97759. }
  97760. }
  97761. declare module BABYLON {
  97762. /**
  97763. * This represents a FPS type of camera. This is only here for back compat purpose.
  97764. * Please use the UniversalCamera instead as both are identical.
  97765. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97766. */
  97767. export class GamepadCamera extends UniversalCamera {
  97768. /**
  97769. * Instantiates a new Gamepad Camera
  97770. * This represents a FPS type of camera. This is only here for back compat purpose.
  97771. * Please use the UniversalCamera instead as both are identical.
  97772. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97773. * @param name Define the name of the camera in the scene
  97774. * @param position Define the start position of the camera in the scene
  97775. * @param scene Define the scene the camera belongs to
  97776. */
  97777. constructor(name: string, position: Vector3, scene: Scene);
  97778. /**
  97779. * Gets the current object class name.
  97780. * @return the class name
  97781. */
  97782. getClassName(): string;
  97783. }
  97784. }
  97785. declare module BABYLON {
  97786. /** @hidden */
  97787. export var passPixelShader: {
  97788. name: string;
  97789. shader: string;
  97790. };
  97791. }
  97792. declare module BABYLON {
  97793. /** @hidden */
  97794. export var passCubePixelShader: {
  97795. name: string;
  97796. shader: string;
  97797. };
  97798. }
  97799. declare module BABYLON {
  97800. /**
  97801. * PassPostProcess which produces an output the same as it's input
  97802. */
  97803. export class PassPostProcess extends PostProcess {
  97804. /**
  97805. * Creates the PassPostProcess
  97806. * @param name The name of the effect.
  97807. * @param options The required width/height ratio to downsize to before computing the render pass.
  97808. * @param camera The camera to apply the render pass to.
  97809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97810. * @param engine The engine which the post process will be applied. (default: current engine)
  97811. * @param reusable If the post process can be reused on the same frame. (default: false)
  97812. * @param textureType The type of texture to be used when performing the post processing.
  97813. * @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)
  97814. */
  97815. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97816. }
  97817. /**
  97818. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97819. */
  97820. export class PassCubePostProcess extends PostProcess {
  97821. private _face;
  97822. /**
  97823. * Gets or sets the cube face to display.
  97824. * * 0 is +X
  97825. * * 1 is -X
  97826. * * 2 is +Y
  97827. * * 3 is -Y
  97828. * * 4 is +Z
  97829. * * 5 is -Z
  97830. */
  97831. face: number;
  97832. /**
  97833. * Creates the PassCubePostProcess
  97834. * @param name The name of the effect.
  97835. * @param options The required width/height ratio to downsize to before computing the render pass.
  97836. * @param camera The camera to apply the render pass to.
  97837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97838. * @param engine The engine which the post process will be applied. (default: current engine)
  97839. * @param reusable If the post process can be reused on the same frame. (default: false)
  97840. * @param textureType The type of texture to be used when performing the post processing.
  97841. * @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)
  97842. */
  97843. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97844. }
  97845. }
  97846. declare module BABYLON {
  97847. /** @hidden */
  97848. export var anaglyphPixelShader: {
  97849. name: string;
  97850. shader: string;
  97851. };
  97852. }
  97853. declare module BABYLON {
  97854. /**
  97855. * Postprocess used to generate anaglyphic rendering
  97856. */
  97857. export class AnaglyphPostProcess extends PostProcess {
  97858. private _passedProcess;
  97859. /**
  97860. * Creates a new AnaglyphPostProcess
  97861. * @param name defines postprocess name
  97862. * @param options defines creation options or target ratio scale
  97863. * @param rigCameras defines cameras using this postprocess
  97864. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97865. * @param engine defines hosting engine
  97866. * @param reusable defines if the postprocess will be reused multiple times per frame
  97867. */
  97868. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97869. }
  97870. }
  97871. declare module BABYLON {
  97872. /**
  97873. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97874. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97875. */
  97876. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97877. /**
  97878. * Creates a new AnaglyphArcRotateCamera
  97879. * @param name defines camera name
  97880. * @param alpha defines alpha angle (in radians)
  97881. * @param beta defines beta angle (in radians)
  97882. * @param radius defines radius
  97883. * @param target defines camera target
  97884. * @param interaxialDistance defines distance between each color axis
  97885. * @param scene defines the hosting scene
  97886. */
  97887. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97888. /**
  97889. * Gets camera class name
  97890. * @returns AnaglyphArcRotateCamera
  97891. */
  97892. getClassName(): string;
  97893. }
  97894. }
  97895. declare module BABYLON {
  97896. /**
  97897. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97898. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97899. */
  97900. export class AnaglyphFreeCamera extends FreeCamera {
  97901. /**
  97902. * Creates a new AnaglyphFreeCamera
  97903. * @param name defines camera name
  97904. * @param position defines initial position
  97905. * @param interaxialDistance defines distance between each color axis
  97906. * @param scene defines the hosting scene
  97907. */
  97908. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97909. /**
  97910. * Gets camera class name
  97911. * @returns AnaglyphFreeCamera
  97912. */
  97913. getClassName(): string;
  97914. }
  97915. }
  97916. declare module BABYLON {
  97917. /**
  97918. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97919. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97920. */
  97921. export class AnaglyphGamepadCamera extends GamepadCamera {
  97922. /**
  97923. * Creates a new AnaglyphGamepadCamera
  97924. * @param name defines camera name
  97925. * @param position defines initial position
  97926. * @param interaxialDistance defines distance between each color axis
  97927. * @param scene defines the hosting scene
  97928. */
  97929. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97930. /**
  97931. * Gets camera class name
  97932. * @returns AnaglyphGamepadCamera
  97933. */
  97934. getClassName(): string;
  97935. }
  97936. }
  97937. declare module BABYLON {
  97938. /**
  97939. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97940. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97941. */
  97942. export class AnaglyphUniversalCamera extends UniversalCamera {
  97943. /**
  97944. * Creates a new AnaglyphUniversalCamera
  97945. * @param name defines camera name
  97946. * @param position defines initial position
  97947. * @param interaxialDistance defines distance between each color axis
  97948. * @param scene defines the hosting scene
  97949. */
  97950. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97951. /**
  97952. * Gets camera class name
  97953. * @returns AnaglyphUniversalCamera
  97954. */
  97955. getClassName(): string;
  97956. }
  97957. }
  97958. declare module BABYLON {
  97959. /** @hidden */
  97960. export var stereoscopicInterlacePixelShader: {
  97961. name: string;
  97962. shader: string;
  97963. };
  97964. }
  97965. declare module BABYLON {
  97966. /**
  97967. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97968. */
  97969. export class StereoscopicInterlacePostProcess extends PostProcess {
  97970. private _stepSize;
  97971. private _passedProcess;
  97972. /**
  97973. * Initializes a StereoscopicInterlacePostProcess
  97974. * @param name The name of the effect.
  97975. * @param rigCameras The rig cameras to be appled to the post process
  97976. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97978. * @param engine The engine which the post process will be applied. (default: current engine)
  97979. * @param reusable If the post process can be reused on the same frame. (default: false)
  97980. */
  97981. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97982. }
  97983. }
  97984. declare module BABYLON {
  97985. /**
  97986. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97987. * @see http://doc.babylonjs.com/features/cameras
  97988. */
  97989. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97990. /**
  97991. * Creates a new StereoscopicArcRotateCamera
  97992. * @param name defines camera name
  97993. * @param alpha defines alpha angle (in radians)
  97994. * @param beta defines beta angle (in radians)
  97995. * @param radius defines radius
  97996. * @param target defines camera target
  97997. * @param interaxialDistance defines distance between each color axis
  97998. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97999. * @param scene defines the hosting scene
  98000. */
  98001. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98002. /**
  98003. * Gets camera class name
  98004. * @returns StereoscopicArcRotateCamera
  98005. */
  98006. getClassName(): string;
  98007. }
  98008. }
  98009. declare module BABYLON {
  98010. /**
  98011. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  98012. * @see http://doc.babylonjs.com/features/cameras
  98013. */
  98014. export class StereoscopicFreeCamera extends FreeCamera {
  98015. /**
  98016. * Creates a new StereoscopicFreeCamera
  98017. * @param name defines camera name
  98018. * @param position defines initial position
  98019. * @param interaxialDistance defines distance between each color axis
  98020. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98021. * @param scene defines the hosting scene
  98022. */
  98023. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98024. /**
  98025. * Gets camera class name
  98026. * @returns StereoscopicFreeCamera
  98027. */
  98028. getClassName(): string;
  98029. }
  98030. }
  98031. declare module BABYLON {
  98032. /**
  98033. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  98034. * @see http://doc.babylonjs.com/features/cameras
  98035. */
  98036. export class StereoscopicGamepadCamera extends GamepadCamera {
  98037. /**
  98038. * Creates a new StereoscopicGamepadCamera
  98039. * @param name defines camera name
  98040. * @param position defines initial position
  98041. * @param interaxialDistance defines distance between each color axis
  98042. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98043. * @param scene defines the hosting scene
  98044. */
  98045. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98046. /**
  98047. * Gets camera class name
  98048. * @returns StereoscopicGamepadCamera
  98049. */
  98050. getClassName(): string;
  98051. }
  98052. }
  98053. declare module BABYLON {
  98054. /**
  98055. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  98056. * @see http://doc.babylonjs.com/features/cameras
  98057. */
  98058. export class StereoscopicUniversalCamera extends UniversalCamera {
  98059. /**
  98060. * Creates a new StereoscopicUniversalCamera
  98061. * @param name defines camera name
  98062. * @param position defines initial position
  98063. * @param interaxialDistance defines distance between each color axis
  98064. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98065. * @param scene defines the hosting scene
  98066. */
  98067. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98068. /**
  98069. * Gets camera class name
  98070. * @returns StereoscopicUniversalCamera
  98071. */
  98072. getClassName(): string;
  98073. }
  98074. }
  98075. declare module BABYLON {
  98076. /**
  98077. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98078. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  98079. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  98080. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  98081. */
  98082. export class VirtualJoysticksCamera extends FreeCamera {
  98083. /**
  98084. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  98085. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  98086. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  98087. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  98088. * @param name Define the name of the camera in the scene
  98089. * @param position Define the start position of the camera in the scene
  98090. * @param scene Define the scene the camera belongs to
  98091. */
  98092. constructor(name: string, position: Vector3, scene: Scene);
  98093. /**
  98094. * Gets the current object class name.
  98095. * @return the class name
  98096. */
  98097. getClassName(): string;
  98098. }
  98099. }
  98100. declare module BABYLON {
  98101. /**
  98102. * This represents all the required metrics to create a VR camera.
  98103. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  98104. */
  98105. export class VRCameraMetrics {
  98106. /**
  98107. * Define the horizontal resolution off the screen.
  98108. */
  98109. hResolution: number;
  98110. /**
  98111. * Define the vertical resolution off the screen.
  98112. */
  98113. vResolution: number;
  98114. /**
  98115. * Define the horizontal screen size.
  98116. */
  98117. hScreenSize: number;
  98118. /**
  98119. * Define the vertical screen size.
  98120. */
  98121. vScreenSize: number;
  98122. /**
  98123. * Define the vertical screen center position.
  98124. */
  98125. vScreenCenter: number;
  98126. /**
  98127. * Define the distance of the eyes to the screen.
  98128. */
  98129. eyeToScreenDistance: number;
  98130. /**
  98131. * Define the distance between both lenses
  98132. */
  98133. lensSeparationDistance: number;
  98134. /**
  98135. * Define the distance between both viewer's eyes.
  98136. */
  98137. interpupillaryDistance: number;
  98138. /**
  98139. * Define the distortion factor of the VR postprocess.
  98140. * Please, touch with care.
  98141. */
  98142. distortionK: number[];
  98143. /**
  98144. * Define the chromatic aberration correction factors for the VR post process.
  98145. */
  98146. chromaAbCorrection: number[];
  98147. /**
  98148. * Define the scale factor of the post process.
  98149. * The smaller the better but the slower.
  98150. */
  98151. postProcessScaleFactor: number;
  98152. /**
  98153. * Define an offset for the lens center.
  98154. */
  98155. lensCenterOffset: number;
  98156. /**
  98157. * Define if the current vr camera should compensate the distortion of the lense or not.
  98158. */
  98159. compensateDistortion: boolean;
  98160. /**
  98161. * Defines if multiview should be enabled when rendering (Default: false)
  98162. */
  98163. multiviewEnabled: boolean;
  98164. /**
  98165. * Gets the rendering aspect ratio based on the provided resolutions.
  98166. */
  98167. readonly aspectRatio: number;
  98168. /**
  98169. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  98170. */
  98171. readonly aspectRatioFov: number;
  98172. /**
  98173. * @hidden
  98174. */
  98175. readonly leftHMatrix: Matrix;
  98176. /**
  98177. * @hidden
  98178. */
  98179. readonly rightHMatrix: Matrix;
  98180. /**
  98181. * @hidden
  98182. */
  98183. readonly leftPreViewMatrix: Matrix;
  98184. /**
  98185. * @hidden
  98186. */
  98187. readonly rightPreViewMatrix: Matrix;
  98188. /**
  98189. * Get the default VRMetrics based on the most generic setup.
  98190. * @returns the default vr metrics
  98191. */
  98192. static GetDefault(): VRCameraMetrics;
  98193. }
  98194. }
  98195. declare module BABYLON {
  98196. /** @hidden */
  98197. export var vrDistortionCorrectionPixelShader: {
  98198. name: string;
  98199. shader: string;
  98200. };
  98201. }
  98202. declare module BABYLON {
  98203. /**
  98204. * VRDistortionCorrectionPostProcess used for mobile VR
  98205. */
  98206. export class VRDistortionCorrectionPostProcess extends PostProcess {
  98207. private _isRightEye;
  98208. private _distortionFactors;
  98209. private _postProcessScaleFactor;
  98210. private _lensCenterOffset;
  98211. private _scaleIn;
  98212. private _scaleFactor;
  98213. private _lensCenter;
  98214. /**
  98215. * Initializes the VRDistortionCorrectionPostProcess
  98216. * @param name The name of the effect.
  98217. * @param camera The camera to apply the render pass to.
  98218. * @param isRightEye If this is for the right eye distortion
  98219. * @param vrMetrics All the required metrics for the VR camera
  98220. */
  98221. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  98222. }
  98223. }
  98224. declare module BABYLON {
  98225. /**
  98226. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  98227. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98228. */
  98229. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  98230. /**
  98231. * Creates a new VRDeviceOrientationArcRotateCamera
  98232. * @param name defines camera name
  98233. * @param alpha defines the camera rotation along the logitudinal axis
  98234. * @param beta defines the camera rotation along the latitudinal axis
  98235. * @param radius defines the camera distance from its target
  98236. * @param target defines the camera target
  98237. * @param scene defines the scene the camera belongs to
  98238. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98239. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98240. */
  98241. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98242. /**
  98243. * Gets camera class name
  98244. * @returns VRDeviceOrientationArcRotateCamera
  98245. */
  98246. getClassName(): string;
  98247. }
  98248. }
  98249. declare module BABYLON {
  98250. /**
  98251. * Camera used to simulate VR rendering (based on FreeCamera)
  98252. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98253. */
  98254. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  98255. /**
  98256. * Creates a new VRDeviceOrientationFreeCamera
  98257. * @param name defines camera name
  98258. * @param position defines the start position of the camera
  98259. * @param scene defines the scene the camera belongs to
  98260. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98261. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98262. */
  98263. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98264. /**
  98265. * Gets camera class name
  98266. * @returns VRDeviceOrientationFreeCamera
  98267. */
  98268. getClassName(): string;
  98269. }
  98270. }
  98271. declare module BABYLON {
  98272. /**
  98273. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  98274. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98275. */
  98276. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  98277. /**
  98278. * Creates a new VRDeviceOrientationGamepadCamera
  98279. * @param name defines camera name
  98280. * @param position defines the start position of the camera
  98281. * @param scene defines the scene the camera belongs to
  98282. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98283. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98284. */
  98285. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98286. /**
  98287. * Gets camera class name
  98288. * @returns VRDeviceOrientationGamepadCamera
  98289. */
  98290. getClassName(): string;
  98291. }
  98292. }
  98293. declare module BABYLON {
  98294. /**
  98295. * Base class of materials working in push mode in babylon JS
  98296. * @hidden
  98297. */
  98298. export class PushMaterial extends Material {
  98299. protected _activeEffect: Effect;
  98300. protected _normalMatrix: Matrix;
  98301. /**
  98302. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98303. * This means that the material can keep using a previous shader while a new one is being compiled.
  98304. * This is mostly used when shader parallel compilation is supported (true by default)
  98305. */
  98306. allowShaderHotSwapping: boolean;
  98307. constructor(name: string, scene: Scene);
  98308. getEffect(): Effect;
  98309. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98310. /**
  98311. * Binds the given world matrix to the active effect
  98312. *
  98313. * @param world the matrix to bind
  98314. */
  98315. bindOnlyWorldMatrix(world: Matrix): void;
  98316. /**
  98317. * Binds the given normal matrix to the active effect
  98318. *
  98319. * @param normalMatrix the matrix to bind
  98320. */
  98321. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98322. bind(world: Matrix, mesh?: Mesh): void;
  98323. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98324. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98325. }
  98326. }
  98327. declare module BABYLON {
  98328. /**
  98329. * This groups all the flags used to control the materials channel.
  98330. */
  98331. export class MaterialFlags {
  98332. private static _DiffuseTextureEnabled;
  98333. /**
  98334. * Are diffuse textures enabled in the application.
  98335. */
  98336. static DiffuseTextureEnabled: boolean;
  98337. private static _AmbientTextureEnabled;
  98338. /**
  98339. * Are ambient textures enabled in the application.
  98340. */
  98341. static AmbientTextureEnabled: boolean;
  98342. private static _OpacityTextureEnabled;
  98343. /**
  98344. * Are opacity textures enabled in the application.
  98345. */
  98346. static OpacityTextureEnabled: boolean;
  98347. private static _ReflectionTextureEnabled;
  98348. /**
  98349. * Are reflection textures enabled in the application.
  98350. */
  98351. static ReflectionTextureEnabled: boolean;
  98352. private static _EmissiveTextureEnabled;
  98353. /**
  98354. * Are emissive textures enabled in the application.
  98355. */
  98356. static EmissiveTextureEnabled: boolean;
  98357. private static _SpecularTextureEnabled;
  98358. /**
  98359. * Are specular textures enabled in the application.
  98360. */
  98361. static SpecularTextureEnabled: boolean;
  98362. private static _BumpTextureEnabled;
  98363. /**
  98364. * Are bump textures enabled in the application.
  98365. */
  98366. static BumpTextureEnabled: boolean;
  98367. private static _LightmapTextureEnabled;
  98368. /**
  98369. * Are lightmap textures enabled in the application.
  98370. */
  98371. static LightmapTextureEnabled: boolean;
  98372. private static _RefractionTextureEnabled;
  98373. /**
  98374. * Are refraction textures enabled in the application.
  98375. */
  98376. static RefractionTextureEnabled: boolean;
  98377. private static _ColorGradingTextureEnabled;
  98378. /**
  98379. * Are color grading textures enabled in the application.
  98380. */
  98381. static ColorGradingTextureEnabled: boolean;
  98382. private static _FresnelEnabled;
  98383. /**
  98384. * Are fresnels enabled in the application.
  98385. */
  98386. static FresnelEnabled: boolean;
  98387. private static _ClearCoatTextureEnabled;
  98388. /**
  98389. * Are clear coat textures enabled in the application.
  98390. */
  98391. static ClearCoatTextureEnabled: boolean;
  98392. private static _ClearCoatBumpTextureEnabled;
  98393. /**
  98394. * Are clear coat bump textures enabled in the application.
  98395. */
  98396. static ClearCoatBumpTextureEnabled: boolean;
  98397. private static _ClearCoatTintTextureEnabled;
  98398. /**
  98399. * Are clear coat tint textures enabled in the application.
  98400. */
  98401. static ClearCoatTintTextureEnabled: boolean;
  98402. private static _SheenTextureEnabled;
  98403. /**
  98404. * Are sheen textures enabled in the application.
  98405. */
  98406. static SheenTextureEnabled: boolean;
  98407. private static _AnisotropicTextureEnabled;
  98408. /**
  98409. * Are anisotropic textures enabled in the application.
  98410. */
  98411. static AnisotropicTextureEnabled: boolean;
  98412. private static _ThicknessTextureEnabled;
  98413. /**
  98414. * Are thickness textures enabled in the application.
  98415. */
  98416. static ThicknessTextureEnabled: boolean;
  98417. }
  98418. }
  98419. declare module BABYLON {
  98420. /** @hidden */
  98421. export var defaultFragmentDeclaration: {
  98422. name: string;
  98423. shader: string;
  98424. };
  98425. }
  98426. declare module BABYLON {
  98427. /** @hidden */
  98428. export var defaultUboDeclaration: {
  98429. name: string;
  98430. shader: string;
  98431. };
  98432. }
  98433. declare module BABYLON {
  98434. /** @hidden */
  98435. export var lightFragmentDeclaration: {
  98436. name: string;
  98437. shader: string;
  98438. };
  98439. }
  98440. declare module BABYLON {
  98441. /** @hidden */
  98442. export var lightUboDeclaration: {
  98443. name: string;
  98444. shader: string;
  98445. };
  98446. }
  98447. declare module BABYLON {
  98448. /** @hidden */
  98449. export var lightsFragmentFunctions: {
  98450. name: string;
  98451. shader: string;
  98452. };
  98453. }
  98454. declare module BABYLON {
  98455. /** @hidden */
  98456. export var shadowsFragmentFunctions: {
  98457. name: string;
  98458. shader: string;
  98459. };
  98460. }
  98461. declare module BABYLON {
  98462. /** @hidden */
  98463. export var fresnelFunction: {
  98464. name: string;
  98465. shader: string;
  98466. };
  98467. }
  98468. declare module BABYLON {
  98469. /** @hidden */
  98470. export var reflectionFunction: {
  98471. name: string;
  98472. shader: string;
  98473. };
  98474. }
  98475. declare module BABYLON {
  98476. /** @hidden */
  98477. export var bumpFragmentFunctions: {
  98478. name: string;
  98479. shader: string;
  98480. };
  98481. }
  98482. declare module BABYLON {
  98483. /** @hidden */
  98484. export var logDepthDeclaration: {
  98485. name: string;
  98486. shader: string;
  98487. };
  98488. }
  98489. declare module BABYLON {
  98490. /** @hidden */
  98491. export var bumpFragment: {
  98492. name: string;
  98493. shader: string;
  98494. };
  98495. }
  98496. declare module BABYLON {
  98497. /** @hidden */
  98498. export var depthPrePass: {
  98499. name: string;
  98500. shader: string;
  98501. };
  98502. }
  98503. declare module BABYLON {
  98504. /** @hidden */
  98505. export var lightFragment: {
  98506. name: string;
  98507. shader: string;
  98508. };
  98509. }
  98510. declare module BABYLON {
  98511. /** @hidden */
  98512. export var logDepthFragment: {
  98513. name: string;
  98514. shader: string;
  98515. };
  98516. }
  98517. declare module BABYLON {
  98518. /** @hidden */
  98519. export var defaultPixelShader: {
  98520. name: string;
  98521. shader: string;
  98522. };
  98523. }
  98524. declare module BABYLON {
  98525. /** @hidden */
  98526. export var defaultVertexDeclaration: {
  98527. name: string;
  98528. shader: string;
  98529. };
  98530. }
  98531. declare module BABYLON {
  98532. /** @hidden */
  98533. export var bumpVertexDeclaration: {
  98534. name: string;
  98535. shader: string;
  98536. };
  98537. }
  98538. declare module BABYLON {
  98539. /** @hidden */
  98540. export var bumpVertex: {
  98541. name: string;
  98542. shader: string;
  98543. };
  98544. }
  98545. declare module BABYLON {
  98546. /** @hidden */
  98547. export var fogVertex: {
  98548. name: string;
  98549. shader: string;
  98550. };
  98551. }
  98552. declare module BABYLON {
  98553. /** @hidden */
  98554. export var shadowsVertex: {
  98555. name: string;
  98556. shader: string;
  98557. };
  98558. }
  98559. declare module BABYLON {
  98560. /** @hidden */
  98561. export var pointCloudVertex: {
  98562. name: string;
  98563. shader: string;
  98564. };
  98565. }
  98566. declare module BABYLON {
  98567. /** @hidden */
  98568. export var logDepthVertex: {
  98569. name: string;
  98570. shader: string;
  98571. };
  98572. }
  98573. declare module BABYLON {
  98574. /** @hidden */
  98575. export var defaultVertexShader: {
  98576. name: string;
  98577. shader: string;
  98578. };
  98579. }
  98580. declare module BABYLON {
  98581. /** @hidden */
  98582. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98583. MAINUV1: boolean;
  98584. MAINUV2: boolean;
  98585. DIFFUSE: boolean;
  98586. DIFFUSEDIRECTUV: number;
  98587. AMBIENT: boolean;
  98588. AMBIENTDIRECTUV: number;
  98589. OPACITY: boolean;
  98590. OPACITYDIRECTUV: number;
  98591. OPACITYRGB: boolean;
  98592. REFLECTION: boolean;
  98593. EMISSIVE: boolean;
  98594. EMISSIVEDIRECTUV: number;
  98595. SPECULAR: boolean;
  98596. SPECULARDIRECTUV: number;
  98597. BUMP: boolean;
  98598. BUMPDIRECTUV: number;
  98599. PARALLAX: boolean;
  98600. PARALLAXOCCLUSION: boolean;
  98601. SPECULAROVERALPHA: boolean;
  98602. CLIPPLANE: boolean;
  98603. CLIPPLANE2: boolean;
  98604. CLIPPLANE3: boolean;
  98605. CLIPPLANE4: boolean;
  98606. ALPHATEST: boolean;
  98607. DEPTHPREPASS: boolean;
  98608. ALPHAFROMDIFFUSE: boolean;
  98609. POINTSIZE: boolean;
  98610. FOG: boolean;
  98611. SPECULARTERM: boolean;
  98612. DIFFUSEFRESNEL: boolean;
  98613. OPACITYFRESNEL: boolean;
  98614. REFLECTIONFRESNEL: boolean;
  98615. REFRACTIONFRESNEL: boolean;
  98616. EMISSIVEFRESNEL: boolean;
  98617. FRESNEL: boolean;
  98618. NORMAL: boolean;
  98619. UV1: boolean;
  98620. UV2: boolean;
  98621. VERTEXCOLOR: boolean;
  98622. VERTEXALPHA: boolean;
  98623. NUM_BONE_INFLUENCERS: number;
  98624. BonesPerMesh: number;
  98625. BONETEXTURE: boolean;
  98626. INSTANCES: boolean;
  98627. GLOSSINESS: boolean;
  98628. ROUGHNESS: boolean;
  98629. EMISSIVEASILLUMINATION: boolean;
  98630. LINKEMISSIVEWITHDIFFUSE: boolean;
  98631. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98632. LIGHTMAP: boolean;
  98633. LIGHTMAPDIRECTUV: number;
  98634. OBJECTSPACE_NORMALMAP: boolean;
  98635. USELIGHTMAPASSHADOWMAP: boolean;
  98636. REFLECTIONMAP_3D: boolean;
  98637. REFLECTIONMAP_SPHERICAL: boolean;
  98638. REFLECTIONMAP_PLANAR: boolean;
  98639. REFLECTIONMAP_CUBIC: boolean;
  98640. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98641. REFLECTIONMAP_PROJECTION: boolean;
  98642. REFLECTIONMAP_SKYBOX: boolean;
  98643. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98644. REFLECTIONMAP_EXPLICIT: boolean;
  98645. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98646. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98647. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98648. INVERTCUBICMAP: boolean;
  98649. LOGARITHMICDEPTH: boolean;
  98650. REFRACTION: boolean;
  98651. REFRACTIONMAP_3D: boolean;
  98652. REFLECTIONOVERALPHA: boolean;
  98653. TWOSIDEDLIGHTING: boolean;
  98654. SHADOWFLOAT: boolean;
  98655. MORPHTARGETS: boolean;
  98656. MORPHTARGETS_NORMAL: boolean;
  98657. MORPHTARGETS_TANGENT: boolean;
  98658. NUM_MORPH_INFLUENCERS: number;
  98659. NONUNIFORMSCALING: boolean;
  98660. PREMULTIPLYALPHA: boolean;
  98661. IMAGEPROCESSING: boolean;
  98662. VIGNETTE: boolean;
  98663. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98664. VIGNETTEBLENDMODEOPAQUE: boolean;
  98665. TONEMAPPING: boolean;
  98666. TONEMAPPING_ACES: boolean;
  98667. CONTRAST: boolean;
  98668. COLORCURVES: boolean;
  98669. COLORGRADING: boolean;
  98670. COLORGRADING3D: boolean;
  98671. SAMPLER3DGREENDEPTH: boolean;
  98672. SAMPLER3DBGRMAP: boolean;
  98673. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98674. MULTIVIEW: boolean;
  98675. /**
  98676. * If the reflection texture on this material is in linear color space
  98677. * @hidden
  98678. */
  98679. IS_REFLECTION_LINEAR: boolean;
  98680. /**
  98681. * If the refraction texture on this material is in linear color space
  98682. * @hidden
  98683. */
  98684. IS_REFRACTION_LINEAR: boolean;
  98685. EXPOSURE: boolean;
  98686. constructor();
  98687. setReflectionMode(modeToEnable: string): void;
  98688. }
  98689. /**
  98690. * This is the default material used in Babylon. It is the best trade off between quality
  98691. * and performances.
  98692. * @see http://doc.babylonjs.com/babylon101/materials
  98693. */
  98694. export class StandardMaterial extends PushMaterial {
  98695. private _diffuseTexture;
  98696. /**
  98697. * The basic texture of the material as viewed under a light.
  98698. */
  98699. diffuseTexture: Nullable<BaseTexture>;
  98700. private _ambientTexture;
  98701. /**
  98702. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98703. */
  98704. ambientTexture: Nullable<BaseTexture>;
  98705. private _opacityTexture;
  98706. /**
  98707. * Define the transparency of the material from a texture.
  98708. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98709. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98710. */
  98711. opacityTexture: Nullable<BaseTexture>;
  98712. private _reflectionTexture;
  98713. /**
  98714. * Define the texture used to display the reflection.
  98715. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98716. */
  98717. reflectionTexture: Nullable<BaseTexture>;
  98718. private _emissiveTexture;
  98719. /**
  98720. * Define texture of the material as if self lit.
  98721. * This will be mixed in the final result even in the absence of light.
  98722. */
  98723. emissiveTexture: Nullable<BaseTexture>;
  98724. private _specularTexture;
  98725. /**
  98726. * Define how the color and intensity of the highlight given by the light in the material.
  98727. */
  98728. specularTexture: Nullable<BaseTexture>;
  98729. private _bumpTexture;
  98730. /**
  98731. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98732. * 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.
  98733. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98734. */
  98735. bumpTexture: Nullable<BaseTexture>;
  98736. private _lightmapTexture;
  98737. /**
  98738. * Complex lighting can be computationally expensive to compute at runtime.
  98739. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98740. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98741. */
  98742. lightmapTexture: Nullable<BaseTexture>;
  98743. private _refractionTexture;
  98744. /**
  98745. * Define the texture used to display the refraction.
  98746. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98747. */
  98748. refractionTexture: Nullable<BaseTexture>;
  98749. /**
  98750. * The color of the material lit by the environmental background lighting.
  98751. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98752. */
  98753. ambientColor: Color3;
  98754. /**
  98755. * The basic color of the material as viewed under a light.
  98756. */
  98757. diffuseColor: Color3;
  98758. /**
  98759. * Define how the color and intensity of the highlight given by the light in the material.
  98760. */
  98761. specularColor: Color3;
  98762. /**
  98763. * Define the color of the material as if self lit.
  98764. * This will be mixed in the final result even in the absence of light.
  98765. */
  98766. emissiveColor: Color3;
  98767. /**
  98768. * Defines how sharp are the highlights in the material.
  98769. * The bigger the value the sharper giving a more glossy feeling to the result.
  98770. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98771. */
  98772. specularPower: number;
  98773. private _useAlphaFromDiffuseTexture;
  98774. /**
  98775. * Does the transparency come from the diffuse texture alpha channel.
  98776. */
  98777. useAlphaFromDiffuseTexture: boolean;
  98778. private _useEmissiveAsIllumination;
  98779. /**
  98780. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98781. */
  98782. useEmissiveAsIllumination: boolean;
  98783. private _linkEmissiveWithDiffuse;
  98784. /**
  98785. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98786. * the emissive level when the final color is close to one.
  98787. */
  98788. linkEmissiveWithDiffuse: boolean;
  98789. private _useSpecularOverAlpha;
  98790. /**
  98791. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98792. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98793. */
  98794. useSpecularOverAlpha: boolean;
  98795. private _useReflectionOverAlpha;
  98796. /**
  98797. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98798. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98799. */
  98800. useReflectionOverAlpha: boolean;
  98801. private _disableLighting;
  98802. /**
  98803. * Does lights from the scene impacts this material.
  98804. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98805. */
  98806. disableLighting: boolean;
  98807. private _useObjectSpaceNormalMap;
  98808. /**
  98809. * Allows using an object space normal map (instead of tangent space).
  98810. */
  98811. useObjectSpaceNormalMap: boolean;
  98812. private _useParallax;
  98813. /**
  98814. * Is parallax enabled or not.
  98815. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98816. */
  98817. useParallax: boolean;
  98818. private _useParallaxOcclusion;
  98819. /**
  98820. * Is parallax occlusion enabled or not.
  98821. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98822. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98823. */
  98824. useParallaxOcclusion: boolean;
  98825. /**
  98826. * 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.
  98827. */
  98828. parallaxScaleBias: number;
  98829. private _roughness;
  98830. /**
  98831. * Helps to define how blurry the reflections should appears in the material.
  98832. */
  98833. roughness: number;
  98834. /**
  98835. * In case of refraction, define the value of the indice of refraction.
  98836. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98837. */
  98838. indexOfRefraction: number;
  98839. /**
  98840. * Invert the refraction texture alongside the y axis.
  98841. * It can be useful with procedural textures or probe for instance.
  98842. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98843. */
  98844. invertRefractionY: boolean;
  98845. /**
  98846. * Defines the alpha limits in alpha test mode.
  98847. */
  98848. alphaCutOff: number;
  98849. private _useLightmapAsShadowmap;
  98850. /**
  98851. * In case of light mapping, define whether the map contains light or shadow informations.
  98852. */
  98853. useLightmapAsShadowmap: boolean;
  98854. private _diffuseFresnelParameters;
  98855. /**
  98856. * Define the diffuse fresnel parameters of the material.
  98857. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98858. */
  98859. diffuseFresnelParameters: FresnelParameters;
  98860. private _opacityFresnelParameters;
  98861. /**
  98862. * Define the opacity fresnel parameters of the material.
  98863. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98864. */
  98865. opacityFresnelParameters: FresnelParameters;
  98866. private _reflectionFresnelParameters;
  98867. /**
  98868. * Define the reflection fresnel parameters of the material.
  98869. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98870. */
  98871. reflectionFresnelParameters: FresnelParameters;
  98872. private _refractionFresnelParameters;
  98873. /**
  98874. * Define the refraction fresnel parameters of the material.
  98875. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98876. */
  98877. refractionFresnelParameters: FresnelParameters;
  98878. private _emissiveFresnelParameters;
  98879. /**
  98880. * Define the emissive fresnel parameters of the material.
  98881. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98882. */
  98883. emissiveFresnelParameters: FresnelParameters;
  98884. private _useReflectionFresnelFromSpecular;
  98885. /**
  98886. * If true automatically deducts the fresnels values from the material specularity.
  98887. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98888. */
  98889. useReflectionFresnelFromSpecular: boolean;
  98890. private _useGlossinessFromSpecularMapAlpha;
  98891. /**
  98892. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98893. */
  98894. useGlossinessFromSpecularMapAlpha: boolean;
  98895. private _maxSimultaneousLights;
  98896. /**
  98897. * Defines the maximum number of lights that can be used in the material
  98898. */
  98899. maxSimultaneousLights: number;
  98900. private _invertNormalMapX;
  98901. /**
  98902. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98903. */
  98904. invertNormalMapX: boolean;
  98905. private _invertNormalMapY;
  98906. /**
  98907. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98908. */
  98909. invertNormalMapY: boolean;
  98910. private _twoSidedLighting;
  98911. /**
  98912. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98913. */
  98914. twoSidedLighting: boolean;
  98915. /**
  98916. * Default configuration related to image processing available in the standard Material.
  98917. */
  98918. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98919. /**
  98920. * Gets the image processing configuration used either in this material.
  98921. */
  98922. /**
  98923. * Sets the Default image processing configuration used either in the this material.
  98924. *
  98925. * If sets to null, the scene one is in use.
  98926. */
  98927. imageProcessingConfiguration: ImageProcessingConfiguration;
  98928. /**
  98929. * Keep track of the image processing observer to allow dispose and replace.
  98930. */
  98931. private _imageProcessingObserver;
  98932. /**
  98933. * Attaches a new image processing configuration to the Standard Material.
  98934. * @param configuration
  98935. */
  98936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98937. /**
  98938. * Gets wether the color curves effect is enabled.
  98939. */
  98940. /**
  98941. * Sets wether the color curves effect is enabled.
  98942. */
  98943. cameraColorCurvesEnabled: boolean;
  98944. /**
  98945. * Gets wether the color grading effect is enabled.
  98946. */
  98947. /**
  98948. * Gets wether the color grading effect is enabled.
  98949. */
  98950. cameraColorGradingEnabled: boolean;
  98951. /**
  98952. * Gets wether tonemapping is enabled or not.
  98953. */
  98954. /**
  98955. * Sets wether tonemapping is enabled or not
  98956. */
  98957. cameraToneMappingEnabled: boolean;
  98958. /**
  98959. * The camera exposure used on this material.
  98960. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98961. * This corresponds to a photographic exposure.
  98962. */
  98963. /**
  98964. * The camera exposure used on this material.
  98965. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98966. * This corresponds to a photographic exposure.
  98967. */
  98968. cameraExposure: number;
  98969. /**
  98970. * Gets The camera contrast used on this material.
  98971. */
  98972. /**
  98973. * Sets The camera contrast used on this material.
  98974. */
  98975. cameraContrast: number;
  98976. /**
  98977. * Gets the Color Grading 2D Lookup Texture.
  98978. */
  98979. /**
  98980. * Sets the Color Grading 2D Lookup Texture.
  98981. */
  98982. cameraColorGradingTexture: Nullable<BaseTexture>;
  98983. /**
  98984. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98985. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98986. * 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;
  98987. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98988. */
  98989. /**
  98990. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98991. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98992. * 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;
  98993. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98994. */
  98995. cameraColorCurves: Nullable<ColorCurves>;
  98996. /**
  98997. * Custom callback helping to override the default shader used in the material.
  98998. */
  98999. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99000. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99001. protected _worldViewProjectionMatrix: Matrix;
  99002. protected _globalAmbientColor: Color3;
  99003. protected _useLogarithmicDepth: boolean;
  99004. /**
  99005. * Instantiates a new standard material.
  99006. * This is the default material used in Babylon. It is the best trade off between quality
  99007. * and performances.
  99008. * @see http://doc.babylonjs.com/babylon101/materials
  99009. * @param name Define the name of the material in the scene
  99010. * @param scene Define the scene the material belong to
  99011. */
  99012. constructor(name: string, scene: Scene);
  99013. /**
  99014. * Gets a boolean indicating that current material needs to register RTT
  99015. */
  99016. readonly hasRenderTargetTextures: boolean;
  99017. /**
  99018. * Gets the current class name of the material e.g. "StandardMaterial"
  99019. * Mainly use in serialization.
  99020. * @returns the class name
  99021. */
  99022. getClassName(): string;
  99023. /**
  99024. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99025. * You can try switching to logarithmic depth.
  99026. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99027. */
  99028. useLogarithmicDepth: boolean;
  99029. /**
  99030. * Specifies if the material will require alpha blending
  99031. * @returns a boolean specifying if alpha blending is needed
  99032. */
  99033. needAlphaBlending(): boolean;
  99034. /**
  99035. * Specifies if this material should be rendered in alpha test mode
  99036. * @returns a boolean specifying if an alpha test is needed.
  99037. */
  99038. needAlphaTesting(): boolean;
  99039. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99040. /**
  99041. * Get the texture used for alpha test purpose.
  99042. * @returns the diffuse texture in case of the standard material.
  99043. */
  99044. getAlphaTestTexture(): Nullable<BaseTexture>;
  99045. /**
  99046. * Get if the submesh is ready to be used and all its information available.
  99047. * Child classes can use it to update shaders
  99048. * @param mesh defines the mesh to check
  99049. * @param subMesh defines which submesh to check
  99050. * @param useInstances specifies that instances should be used
  99051. * @returns a boolean indicating that the submesh is ready or not
  99052. */
  99053. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99054. /**
  99055. * Builds the material UBO layouts.
  99056. * Used internally during the effect preparation.
  99057. */
  99058. buildUniformLayout(): void;
  99059. /**
  99060. * Unbinds the material from the mesh
  99061. */
  99062. unbind(): void;
  99063. /**
  99064. * Binds the submesh to this material by preparing the effect and shader to draw
  99065. * @param world defines the world transformation matrix
  99066. * @param mesh defines the mesh containing the submesh
  99067. * @param subMesh defines the submesh to bind the material to
  99068. */
  99069. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99070. /**
  99071. * Get the list of animatables in the material.
  99072. * @returns the list of animatables object used in the material
  99073. */
  99074. getAnimatables(): IAnimatable[];
  99075. /**
  99076. * Gets the active textures from the material
  99077. * @returns an array of textures
  99078. */
  99079. getActiveTextures(): BaseTexture[];
  99080. /**
  99081. * Specifies if the material uses a texture
  99082. * @param texture defines the texture to check against the material
  99083. * @returns a boolean specifying if the material uses the texture
  99084. */
  99085. hasTexture(texture: BaseTexture): boolean;
  99086. /**
  99087. * Disposes the material
  99088. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99089. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99090. */
  99091. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99092. /**
  99093. * Makes a duplicate of the material, and gives it a new name
  99094. * @param name defines the new name for the duplicated material
  99095. * @returns the cloned material
  99096. */
  99097. clone(name: string): StandardMaterial;
  99098. /**
  99099. * Serializes this material in a JSON representation
  99100. * @returns the serialized material object
  99101. */
  99102. serialize(): any;
  99103. /**
  99104. * Creates a standard material from parsed material data
  99105. * @param source defines the JSON representation of the material
  99106. * @param scene defines the hosting scene
  99107. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99108. * @returns a new standard material
  99109. */
  99110. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99111. /**
  99112. * Are diffuse textures enabled in the application.
  99113. */
  99114. static DiffuseTextureEnabled: boolean;
  99115. /**
  99116. * Are ambient textures enabled in the application.
  99117. */
  99118. static AmbientTextureEnabled: boolean;
  99119. /**
  99120. * Are opacity textures enabled in the application.
  99121. */
  99122. static OpacityTextureEnabled: boolean;
  99123. /**
  99124. * Are reflection textures enabled in the application.
  99125. */
  99126. static ReflectionTextureEnabled: boolean;
  99127. /**
  99128. * Are emissive textures enabled in the application.
  99129. */
  99130. static EmissiveTextureEnabled: boolean;
  99131. /**
  99132. * Are specular textures enabled in the application.
  99133. */
  99134. static SpecularTextureEnabled: boolean;
  99135. /**
  99136. * Are bump textures enabled in the application.
  99137. */
  99138. static BumpTextureEnabled: boolean;
  99139. /**
  99140. * Are lightmap textures enabled in the application.
  99141. */
  99142. static LightmapTextureEnabled: boolean;
  99143. /**
  99144. * Are refraction textures enabled in the application.
  99145. */
  99146. static RefractionTextureEnabled: boolean;
  99147. /**
  99148. * Are color grading textures enabled in the application.
  99149. */
  99150. static ColorGradingTextureEnabled: boolean;
  99151. /**
  99152. * Are fresnels enabled in the application.
  99153. */
  99154. static FresnelEnabled: boolean;
  99155. }
  99156. }
  99157. declare module BABYLON {
  99158. /**
  99159. * A class extending Texture allowing drawing on a texture
  99160. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99161. */
  99162. export class DynamicTexture extends Texture {
  99163. private _generateMipMaps;
  99164. private _canvas;
  99165. private _context;
  99166. private _engine;
  99167. /**
  99168. * Creates a DynamicTexture
  99169. * @param name defines the name of the texture
  99170. * @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
  99171. * @param scene defines the scene where you want the texture
  99172. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99173. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99174. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99175. */
  99176. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99177. /**
  99178. * Get the current class name of the texture useful for serialization or dynamic coding.
  99179. * @returns "DynamicTexture"
  99180. */
  99181. getClassName(): string;
  99182. /**
  99183. * Gets the current state of canRescale
  99184. */
  99185. readonly canRescale: boolean;
  99186. private _recreate;
  99187. /**
  99188. * Scales the texture
  99189. * @param ratio the scale factor to apply to both width and height
  99190. */
  99191. scale(ratio: number): void;
  99192. /**
  99193. * Resizes the texture
  99194. * @param width the new width
  99195. * @param height the new height
  99196. */
  99197. scaleTo(width: number, height: number): void;
  99198. /**
  99199. * Gets the context of the canvas used by the texture
  99200. * @returns the canvas context of the dynamic texture
  99201. */
  99202. getContext(): CanvasRenderingContext2D;
  99203. /**
  99204. * Clears the texture
  99205. */
  99206. clear(): void;
  99207. /**
  99208. * Updates the texture
  99209. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99210. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99211. */
  99212. update(invertY?: boolean, premulAlpha?: boolean): void;
  99213. /**
  99214. * Draws text onto the texture
  99215. * @param text defines the text to be drawn
  99216. * @param x defines the placement of the text from the left
  99217. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99218. * @param font defines the font to be used with font-style, font-size, font-name
  99219. * @param color defines the color used for the text
  99220. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99221. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99222. * @param update defines whether texture is immediately update (default is true)
  99223. */
  99224. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99225. /**
  99226. * Clones the texture
  99227. * @returns the clone of the texture.
  99228. */
  99229. clone(): DynamicTexture;
  99230. /**
  99231. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99232. * @returns a serialized dynamic texture object
  99233. */
  99234. serialize(): any;
  99235. /** @hidden */
  99236. _rebuild(): void;
  99237. }
  99238. }
  99239. declare module BABYLON {
  99240. /** @hidden */
  99241. export var imageProcessingPixelShader: {
  99242. name: string;
  99243. shader: string;
  99244. };
  99245. }
  99246. declare module BABYLON {
  99247. /**
  99248. * ImageProcessingPostProcess
  99249. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99250. */
  99251. export class ImageProcessingPostProcess extends PostProcess {
  99252. /**
  99253. * Default configuration related to image processing available in the PBR Material.
  99254. */
  99255. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99256. /**
  99257. * Gets the image processing configuration used either in this material.
  99258. */
  99259. /**
  99260. * Sets the Default image processing configuration used either in the this material.
  99261. *
  99262. * If sets to null, the scene one is in use.
  99263. */
  99264. imageProcessingConfiguration: ImageProcessingConfiguration;
  99265. /**
  99266. * Keep track of the image processing observer to allow dispose and replace.
  99267. */
  99268. private _imageProcessingObserver;
  99269. /**
  99270. * Attaches a new image processing configuration to the PBR Material.
  99271. * @param configuration
  99272. */
  99273. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99274. /**
  99275. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99276. */
  99277. /**
  99278. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99279. */
  99280. colorCurves: Nullable<ColorCurves>;
  99281. /**
  99282. * Gets wether the color curves effect is enabled.
  99283. */
  99284. /**
  99285. * Sets wether the color curves effect is enabled.
  99286. */
  99287. colorCurvesEnabled: boolean;
  99288. /**
  99289. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99290. */
  99291. /**
  99292. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99293. */
  99294. colorGradingTexture: Nullable<BaseTexture>;
  99295. /**
  99296. * Gets wether the color grading effect is enabled.
  99297. */
  99298. /**
  99299. * Gets wether the color grading effect is enabled.
  99300. */
  99301. colorGradingEnabled: boolean;
  99302. /**
  99303. * Gets exposure used in the effect.
  99304. */
  99305. /**
  99306. * Sets exposure used in the effect.
  99307. */
  99308. exposure: number;
  99309. /**
  99310. * Gets wether tonemapping is enabled or not.
  99311. */
  99312. /**
  99313. * Sets wether tonemapping is enabled or not
  99314. */
  99315. toneMappingEnabled: boolean;
  99316. /**
  99317. * Gets the type of tone mapping effect.
  99318. */
  99319. /**
  99320. * Sets the type of tone mapping effect.
  99321. */
  99322. toneMappingType: number;
  99323. /**
  99324. * Gets contrast used in the effect.
  99325. */
  99326. /**
  99327. * Sets contrast used in the effect.
  99328. */
  99329. contrast: number;
  99330. /**
  99331. * Gets Vignette stretch size.
  99332. */
  99333. /**
  99334. * Sets Vignette stretch size.
  99335. */
  99336. vignetteStretch: number;
  99337. /**
  99338. * Gets Vignette centre X Offset.
  99339. */
  99340. /**
  99341. * Sets Vignette centre X Offset.
  99342. */
  99343. vignetteCentreX: number;
  99344. /**
  99345. * Gets Vignette centre Y Offset.
  99346. */
  99347. /**
  99348. * Sets Vignette centre Y Offset.
  99349. */
  99350. vignetteCentreY: number;
  99351. /**
  99352. * Gets Vignette weight or intensity of the vignette effect.
  99353. */
  99354. /**
  99355. * Sets Vignette weight or intensity of the vignette effect.
  99356. */
  99357. vignetteWeight: number;
  99358. /**
  99359. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99360. * if vignetteEnabled is set to true.
  99361. */
  99362. /**
  99363. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99364. * if vignetteEnabled is set to true.
  99365. */
  99366. vignetteColor: Color4;
  99367. /**
  99368. * Gets Camera field of view used by the Vignette effect.
  99369. */
  99370. /**
  99371. * Sets Camera field of view used by the Vignette effect.
  99372. */
  99373. vignetteCameraFov: number;
  99374. /**
  99375. * Gets the vignette blend mode allowing different kind of effect.
  99376. */
  99377. /**
  99378. * Sets the vignette blend mode allowing different kind of effect.
  99379. */
  99380. vignetteBlendMode: number;
  99381. /**
  99382. * Gets wether the vignette effect is enabled.
  99383. */
  99384. /**
  99385. * Sets wether the vignette effect is enabled.
  99386. */
  99387. vignetteEnabled: boolean;
  99388. private _fromLinearSpace;
  99389. /**
  99390. * Gets wether the input of the processing is in Gamma or Linear Space.
  99391. */
  99392. /**
  99393. * Sets wether the input of the processing is in Gamma or Linear Space.
  99394. */
  99395. fromLinearSpace: boolean;
  99396. /**
  99397. * Defines cache preventing GC.
  99398. */
  99399. private _defines;
  99400. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99401. /**
  99402. * "ImageProcessingPostProcess"
  99403. * @returns "ImageProcessingPostProcess"
  99404. */
  99405. getClassName(): string;
  99406. protected _updateParameters(): void;
  99407. dispose(camera?: Camera): void;
  99408. }
  99409. }
  99410. declare module BABYLON {
  99411. /**
  99412. * Class containing static functions to help procedurally build meshes
  99413. */
  99414. export class GroundBuilder {
  99415. /**
  99416. * Creates a ground mesh
  99417. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99418. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99420. * @param name defines the name of the mesh
  99421. * @param options defines the options used to create the mesh
  99422. * @param scene defines the hosting scene
  99423. * @returns the ground mesh
  99424. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99425. */
  99426. static CreateGround(name: string, options: {
  99427. width?: number;
  99428. height?: number;
  99429. subdivisions?: number;
  99430. subdivisionsX?: number;
  99431. subdivisionsY?: number;
  99432. updatable?: boolean;
  99433. }, scene: any): Mesh;
  99434. /**
  99435. * Creates a tiled ground mesh
  99436. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99437. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99438. * * 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
  99439. * * 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
  99440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99441. * @param name defines the name of the mesh
  99442. * @param options defines the options used to create the mesh
  99443. * @param scene defines the hosting scene
  99444. * @returns the tiled ground mesh
  99445. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99446. */
  99447. static CreateTiledGround(name: string, options: {
  99448. xmin: number;
  99449. zmin: number;
  99450. xmax: number;
  99451. zmax: number;
  99452. subdivisions?: {
  99453. w: number;
  99454. h: number;
  99455. };
  99456. precision?: {
  99457. w: number;
  99458. h: number;
  99459. };
  99460. updatable?: boolean;
  99461. }, scene?: Nullable<Scene>): Mesh;
  99462. /**
  99463. * Creates a ground mesh from a height map
  99464. * * The parameter `url` sets the URL of the height map image resource.
  99465. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99466. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99467. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99468. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99469. * * 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.
  99470. * * 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).
  99471. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99473. * @param name defines the name of the mesh
  99474. * @param url defines the url to the height map
  99475. * @param options defines the options used to create the mesh
  99476. * @param scene defines the hosting scene
  99477. * @returns the ground mesh
  99478. * @see https://doc.babylonjs.com/babylon101/height_map
  99479. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99480. */
  99481. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99482. width?: number;
  99483. height?: number;
  99484. subdivisions?: number;
  99485. minHeight?: number;
  99486. maxHeight?: number;
  99487. colorFilter?: Color3;
  99488. alphaFilter?: number;
  99489. updatable?: boolean;
  99490. onReady?: (mesh: GroundMesh) => void;
  99491. }, scene?: Nullable<Scene>): GroundMesh;
  99492. }
  99493. }
  99494. declare module BABYLON {
  99495. /**
  99496. * Class containing static functions to help procedurally build meshes
  99497. */
  99498. export class TorusBuilder {
  99499. /**
  99500. * Creates a torus mesh
  99501. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99502. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99503. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99507. * @param name defines the name of the mesh
  99508. * @param options defines the options used to create the mesh
  99509. * @param scene defines the hosting scene
  99510. * @returns the torus mesh
  99511. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99512. */
  99513. static CreateTorus(name: string, options: {
  99514. diameter?: number;
  99515. thickness?: number;
  99516. tessellation?: number;
  99517. updatable?: boolean;
  99518. sideOrientation?: number;
  99519. frontUVs?: Vector4;
  99520. backUVs?: Vector4;
  99521. }, scene: any): Mesh;
  99522. }
  99523. }
  99524. declare module BABYLON {
  99525. /**
  99526. * Class containing static functions to help procedurally build meshes
  99527. */
  99528. export class CylinderBuilder {
  99529. /**
  99530. * Creates a cylinder or a cone mesh
  99531. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99532. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99533. * * 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.
  99534. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99535. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99536. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99537. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99538. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99539. * * 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).
  99540. * * 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
  99541. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99542. * * 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
  99543. * * 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.
  99544. * * If `enclose` is false, a ring surface is one element.
  99545. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99546. * * 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
  99547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99550. * @param name defines the name of the mesh
  99551. * @param options defines the options used to create the mesh
  99552. * @param scene defines the hosting scene
  99553. * @returns the cylinder mesh
  99554. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99555. */
  99556. static CreateCylinder(name: string, options: {
  99557. height?: number;
  99558. diameterTop?: number;
  99559. diameterBottom?: number;
  99560. diameter?: number;
  99561. tessellation?: number;
  99562. subdivisions?: number;
  99563. arc?: number;
  99564. faceColors?: Color4[];
  99565. faceUV?: Vector4[];
  99566. updatable?: boolean;
  99567. hasRings?: boolean;
  99568. enclose?: boolean;
  99569. sideOrientation?: number;
  99570. frontUVs?: Vector4;
  99571. backUVs?: Vector4;
  99572. }, scene: any): Mesh;
  99573. }
  99574. }
  99575. declare module BABYLON {
  99576. /**
  99577. * Options to modify the vr teleportation behavior.
  99578. */
  99579. export interface VRTeleportationOptions {
  99580. /**
  99581. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99582. */
  99583. floorMeshName?: string;
  99584. /**
  99585. * A list of meshes to be used as the teleportation floor. (default: empty)
  99586. */
  99587. floorMeshes?: Mesh[];
  99588. }
  99589. /**
  99590. * Options to modify the vr experience helper's behavior.
  99591. */
  99592. export interface VRExperienceHelperOptions extends WebVROptions {
  99593. /**
  99594. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99595. */
  99596. createDeviceOrientationCamera?: boolean;
  99597. /**
  99598. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99599. */
  99600. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99601. /**
  99602. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99603. */
  99604. laserToggle?: boolean;
  99605. /**
  99606. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99607. */
  99608. floorMeshes?: Mesh[];
  99609. /**
  99610. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99611. */
  99612. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99613. }
  99614. /**
  99615. * Event containing information after VR has been entered
  99616. */
  99617. export class OnAfterEnteringVRObservableEvent {
  99618. /**
  99619. * If entering vr was successful
  99620. */
  99621. success: boolean;
  99622. }
  99623. /**
  99624. * Helps to quickly add VR support to an existing scene.
  99625. * See http://doc.babylonjs.com/how_to/webvr_helper
  99626. */
  99627. export class VRExperienceHelper {
  99628. /** Options to modify the vr experience helper's behavior. */
  99629. webVROptions: VRExperienceHelperOptions;
  99630. private _scene;
  99631. private _position;
  99632. private _btnVR;
  99633. private _btnVRDisplayed;
  99634. private _webVRsupported;
  99635. private _webVRready;
  99636. private _webVRrequesting;
  99637. private _webVRpresenting;
  99638. private _hasEnteredVR;
  99639. private _fullscreenVRpresenting;
  99640. private _canvas;
  99641. private _webVRCamera;
  99642. private _vrDeviceOrientationCamera;
  99643. private _deviceOrientationCamera;
  99644. private _existingCamera;
  99645. private _onKeyDown;
  99646. private _onVrDisplayPresentChange;
  99647. private _onVRDisplayChanged;
  99648. private _onVRRequestPresentStart;
  99649. private _onVRRequestPresentComplete;
  99650. /**
  99651. * Observable raised right before entering VR.
  99652. */
  99653. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99654. /**
  99655. * Observable raised when entering VR has completed.
  99656. */
  99657. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99658. /**
  99659. * Observable raised when exiting VR.
  99660. */
  99661. onExitingVRObservable: Observable<VRExperienceHelper>;
  99662. /**
  99663. * Observable raised when controller mesh is loaded.
  99664. */
  99665. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99666. /** Return this.onEnteringVRObservable
  99667. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99668. */
  99669. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99670. /** Return this.onExitingVRObservable
  99671. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99672. */
  99673. readonly onExitingVR: Observable<VRExperienceHelper>;
  99674. /** Return this.onControllerMeshLoadedObservable
  99675. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99676. */
  99677. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99678. private _rayLength;
  99679. private _useCustomVRButton;
  99680. private _teleportationRequested;
  99681. private _teleportActive;
  99682. private _floorMeshName;
  99683. private _floorMeshesCollection;
  99684. private _rotationAllowed;
  99685. private _teleportBackwardsVector;
  99686. private _teleportationTarget;
  99687. private _isDefaultTeleportationTarget;
  99688. private _postProcessMove;
  99689. private _teleportationFillColor;
  99690. private _teleportationBorderColor;
  99691. private _rotationAngle;
  99692. private _haloCenter;
  99693. private _cameraGazer;
  99694. private _padSensibilityUp;
  99695. private _padSensibilityDown;
  99696. private _leftController;
  99697. private _rightController;
  99698. /**
  99699. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99700. */
  99701. onNewMeshSelected: Observable<AbstractMesh>;
  99702. /**
  99703. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99704. */
  99705. onNewMeshPicked: Observable<PickingInfo>;
  99706. private _circleEase;
  99707. /**
  99708. * Observable raised before camera teleportation
  99709. */
  99710. onBeforeCameraTeleport: Observable<Vector3>;
  99711. /**
  99712. * Observable raised after camera teleportation
  99713. */
  99714. onAfterCameraTeleport: Observable<Vector3>;
  99715. /**
  99716. * Observable raised when current selected mesh gets unselected
  99717. */
  99718. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99719. private _raySelectionPredicate;
  99720. /**
  99721. * To be optionaly changed by user to define custom ray selection
  99722. */
  99723. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99724. /**
  99725. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99726. */
  99727. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99728. /**
  99729. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99730. */
  99731. teleportationEnabled: boolean;
  99732. private _defaultHeight;
  99733. private _teleportationInitialized;
  99734. private _interactionsEnabled;
  99735. private _interactionsRequested;
  99736. private _displayGaze;
  99737. private _displayLaserPointer;
  99738. /**
  99739. * The mesh used to display where the user is going to teleport.
  99740. */
  99741. /**
  99742. * Sets the mesh to be used to display where the user is going to teleport.
  99743. */
  99744. teleportationTarget: Mesh;
  99745. /**
  99746. * 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
  99747. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99748. * See http://doc.babylonjs.com/resources/baking_transformations
  99749. */
  99750. gazeTrackerMesh: Mesh;
  99751. /**
  99752. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99753. */
  99754. updateGazeTrackerScale: boolean;
  99755. /**
  99756. * If the gaze trackers color should be updated when selecting meshes
  99757. */
  99758. updateGazeTrackerColor: boolean;
  99759. /**
  99760. * The gaze tracking mesh corresponding to the left controller
  99761. */
  99762. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99763. /**
  99764. * The gaze tracking mesh corresponding to the right controller
  99765. */
  99766. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99767. /**
  99768. * If the ray of the gaze should be displayed.
  99769. */
  99770. /**
  99771. * Sets if the ray of the gaze should be displayed.
  99772. */
  99773. displayGaze: boolean;
  99774. /**
  99775. * If the ray of the LaserPointer should be displayed.
  99776. */
  99777. /**
  99778. * Sets if the ray of the LaserPointer should be displayed.
  99779. */
  99780. displayLaserPointer: boolean;
  99781. /**
  99782. * The deviceOrientationCamera used as the camera when not in VR.
  99783. */
  99784. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99785. /**
  99786. * Based on the current WebVR support, returns the current VR camera used.
  99787. */
  99788. readonly currentVRCamera: Nullable<Camera>;
  99789. /**
  99790. * The webVRCamera which is used when in VR.
  99791. */
  99792. readonly webVRCamera: WebVRFreeCamera;
  99793. /**
  99794. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99795. */
  99796. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99797. private readonly _teleportationRequestInitiated;
  99798. /**
  99799. * Defines wether or not Pointer lock should be requested when switching to
  99800. * full screen.
  99801. */
  99802. requestPointerLockOnFullScreen: boolean;
  99803. /**
  99804. * Instantiates a VRExperienceHelper.
  99805. * Helps to quickly add VR support to an existing scene.
  99806. * @param scene The scene the VRExperienceHelper belongs to.
  99807. * @param webVROptions Options to modify the vr experience helper's behavior.
  99808. */
  99809. constructor(scene: Scene,
  99810. /** Options to modify the vr experience helper's behavior. */
  99811. webVROptions?: VRExperienceHelperOptions);
  99812. private _onDefaultMeshLoaded;
  99813. private _onResize;
  99814. private _onFullscreenChange;
  99815. /**
  99816. * Gets a value indicating if we are currently in VR mode.
  99817. */
  99818. readonly isInVRMode: boolean;
  99819. private onVrDisplayPresentChange;
  99820. private onVRDisplayChanged;
  99821. private moveButtonToBottomRight;
  99822. private displayVRButton;
  99823. private updateButtonVisibility;
  99824. private _cachedAngularSensibility;
  99825. /**
  99826. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99827. * Otherwise, will use the fullscreen API.
  99828. */
  99829. enterVR(): void;
  99830. /**
  99831. * Attempt to exit VR, or fullscreen.
  99832. */
  99833. exitVR(): void;
  99834. /**
  99835. * The position of the vr experience helper.
  99836. */
  99837. /**
  99838. * Sets the position of the vr experience helper.
  99839. */
  99840. position: Vector3;
  99841. /**
  99842. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99843. */
  99844. enableInteractions(): void;
  99845. private readonly _noControllerIsActive;
  99846. private beforeRender;
  99847. private _isTeleportationFloor;
  99848. /**
  99849. * Adds a floor mesh to be used for teleportation.
  99850. * @param floorMesh the mesh to be used for teleportation.
  99851. */
  99852. addFloorMesh(floorMesh: Mesh): void;
  99853. /**
  99854. * Removes a floor mesh from being used for teleportation.
  99855. * @param floorMesh the mesh to be removed.
  99856. */
  99857. removeFloorMesh(floorMesh: Mesh): void;
  99858. /**
  99859. * Enables interactions and teleportation using the VR controllers and gaze.
  99860. * @param vrTeleportationOptions options to modify teleportation behavior.
  99861. */
  99862. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99863. private _onNewGamepadConnected;
  99864. private _tryEnableInteractionOnController;
  99865. private _onNewGamepadDisconnected;
  99866. private _enableInteractionOnController;
  99867. private _checkTeleportWithRay;
  99868. private _checkRotate;
  99869. private _checkTeleportBackwards;
  99870. private _enableTeleportationOnController;
  99871. private _createTeleportationCircles;
  99872. private _displayTeleportationTarget;
  99873. private _hideTeleportationTarget;
  99874. private _rotateCamera;
  99875. private _moveTeleportationSelectorTo;
  99876. private _workingVector;
  99877. private _workingQuaternion;
  99878. private _workingMatrix;
  99879. /**
  99880. * Teleports the users feet to the desired location
  99881. * @param location The location where the user's feet should be placed
  99882. */
  99883. teleportCamera(location: Vector3): void;
  99884. private _convertNormalToDirectionOfRay;
  99885. private _castRayAndSelectObject;
  99886. private _notifySelectedMeshUnselected;
  99887. /**
  99888. * Sets the color of the laser ray from the vr controllers.
  99889. * @param color new color for the ray.
  99890. */
  99891. changeLaserColor(color: Color3): void;
  99892. /**
  99893. * Sets the color of the ray from the vr headsets gaze.
  99894. * @param color new color for the ray.
  99895. */
  99896. changeGazeColor(color: Color3): void;
  99897. /**
  99898. * Exits VR and disposes of the vr experience helper
  99899. */
  99900. dispose(): void;
  99901. /**
  99902. * Gets the name of the VRExperienceHelper class
  99903. * @returns "VRExperienceHelper"
  99904. */
  99905. getClassName(): string;
  99906. }
  99907. }
  99908. declare module BABYLON {
  99909. /**
  99910. * Manages an XRSession
  99911. * @see https://doc.babylonjs.com/how_to/webxr
  99912. */
  99913. export class WebXRSessionManager implements IDisposable {
  99914. private scene;
  99915. /**
  99916. * Fires every time a new xrFrame arrives which can be used to update the camera
  99917. */
  99918. onXRFrameObservable: Observable<any>;
  99919. /**
  99920. * Fires when the xr session is ended either by the device or manually done
  99921. */
  99922. onXRSessionEnded: Observable<any>;
  99923. /** @hidden */
  99924. _xrSession: XRSession;
  99925. /** @hidden */
  99926. _frameOfReference: XRFrameOfReference;
  99927. /** @hidden */
  99928. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99929. /** @hidden */
  99930. _currentXRFrame: Nullable<XRFrame>;
  99931. private _xrNavigator;
  99932. private _xrDevice;
  99933. private _tmpMatrix;
  99934. /**
  99935. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99936. * @param scene The scene which the session should be created for
  99937. */
  99938. constructor(scene: Scene);
  99939. /**
  99940. * Initializes the manager
  99941. * After initialization enterXR can be called to start an XR session
  99942. * @returns Promise which resolves after it is initialized
  99943. */
  99944. initializeAsync(): Promise<void>;
  99945. /**
  99946. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99947. * @param sessionCreationOptions xr options to create the session with
  99948. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99949. * @returns Promise which resolves after it enters XR
  99950. */
  99951. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99952. /**
  99953. * Stops the xrSession and restores the renderloop
  99954. * @returns Promise which resolves after it exits XR
  99955. */
  99956. exitXRAsync(): Promise<void>;
  99957. /**
  99958. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99959. * @param ray ray to cast into the environment
  99960. * @returns Promise which resolves with a collision point in the environment if it exists
  99961. */
  99962. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99963. /**
  99964. * Checks if a session would be supported for the creation options specified
  99965. * @param options creation options to check if they are supported
  99966. * @returns true if supported
  99967. */
  99968. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99969. /**
  99970. * @hidden
  99971. * Converts the render layer of xrSession to a render target
  99972. * @param session session to create render target for
  99973. * @param scene scene the new render target should be created for
  99974. */
  99975. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99976. /**
  99977. * Disposes of the session manager
  99978. */
  99979. dispose(): void;
  99980. }
  99981. }
  99982. declare module BABYLON {
  99983. /**
  99984. * WebXR Camera which holds the views for the xrSession
  99985. * @see https://doc.babylonjs.com/how_to/webxr
  99986. */
  99987. export class WebXRCamera extends FreeCamera {
  99988. private static _TmpMatrix;
  99989. /**
  99990. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99991. * @param name the name of the camera
  99992. * @param scene the scene to add the camera to
  99993. */
  99994. constructor(name: string, scene: Scene);
  99995. private _updateNumberOfRigCameras;
  99996. /** @hidden */
  99997. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99998. /**
  99999. * Updates the cameras position from the current pose information of the XR session
  100000. * @param xrSessionManager the session containing pose information
  100001. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  100002. */
  100003. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  100004. }
  100005. }
  100006. declare module BABYLON {
  100007. /**
  100008. * States of the webXR experience
  100009. */
  100010. export enum WebXRState {
  100011. /**
  100012. * Transitioning to being in XR mode
  100013. */
  100014. ENTERING_XR = 0,
  100015. /**
  100016. * Transitioning to non XR mode
  100017. */
  100018. EXITING_XR = 1,
  100019. /**
  100020. * In XR mode and presenting
  100021. */
  100022. IN_XR = 2,
  100023. /**
  100024. * Not entered XR mode
  100025. */
  100026. NOT_IN_XR = 3
  100027. }
  100028. /**
  100029. * Helper class used to enable XR
  100030. * @see https://doc.babylonjs.com/how_to/webxr
  100031. */
  100032. export class WebXRExperienceHelper implements IDisposable {
  100033. private scene;
  100034. /**
  100035. * 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
  100036. */
  100037. container: AbstractMesh;
  100038. /**
  100039. * Camera used to render xr content
  100040. */
  100041. camera: WebXRCamera;
  100042. /**
  100043. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100044. */
  100045. state: WebXRState;
  100046. private _setState;
  100047. private static _TmpVector;
  100048. /**
  100049. * Fires when the state of the experience helper has changed
  100050. */
  100051. onStateChangedObservable: Observable<WebXRState>;
  100052. /** @hidden */
  100053. _sessionManager: WebXRSessionManager;
  100054. private _nonVRCamera;
  100055. private _originalSceneAutoClear;
  100056. private _supported;
  100057. /**
  100058. * Creates the experience helper
  100059. * @param scene the scene to attach the experience helper to
  100060. * @returns a promise for the experience helper
  100061. */
  100062. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100063. /**
  100064. * Creates a WebXRExperienceHelper
  100065. * @param scene The scene the helper should be created in
  100066. */
  100067. private constructor();
  100068. /**
  100069. * Exits XR mode and returns the scene to its original state
  100070. * @returns promise that resolves after xr mode has exited
  100071. */
  100072. exitXRAsync(): Promise<void>;
  100073. /**
  100074. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100075. * @param sessionCreationOptions options for the XR session
  100076. * @param frameOfReference frame of reference of the XR session
  100077. * @returns promise that resolves after xr mode has entered
  100078. */
  100079. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100080. /**
  100081. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100082. * @param ray ray to cast into the environment
  100083. * @returns Promise which resolves with a collision point in the environment if it exists
  100084. */
  100085. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100086. /**
  100087. * Updates the global position of the camera by moving the camera's container
  100088. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100089. * @param position The desired global position of the camera
  100090. */
  100091. setPositionOfCameraUsingContainer(position: Vector3): void;
  100092. /**
  100093. * Rotates the xr camera by rotating the camera's container around the camera's position
  100094. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100095. * @param rotation the desired quaternion rotation to apply to the camera
  100096. */
  100097. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100098. /**
  100099. * Checks if the creation options are supported by the xr session
  100100. * @param options creation options
  100101. * @returns true if supported
  100102. */
  100103. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100104. /**
  100105. * Disposes of the experience helper
  100106. */
  100107. dispose(): void;
  100108. }
  100109. }
  100110. declare module BABYLON {
  100111. /**
  100112. * Button which can be used to enter a different mode of XR
  100113. */
  100114. export class WebXREnterExitUIButton {
  100115. /** button element */
  100116. element: HTMLElement;
  100117. /** XR initialization options for the button */
  100118. initializationOptions: XRSessionCreationOptions;
  100119. /**
  100120. * Creates a WebXREnterExitUIButton
  100121. * @param element button element
  100122. * @param initializationOptions XR initialization options for the button
  100123. */
  100124. constructor(
  100125. /** button element */
  100126. element: HTMLElement,
  100127. /** XR initialization options for the button */
  100128. initializationOptions: XRSessionCreationOptions);
  100129. /**
  100130. * Overwritable function which can be used to update the button's visuals when the state changes
  100131. * @param activeButton the current active button in the UI
  100132. */
  100133. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100134. }
  100135. /**
  100136. * Options to create the webXR UI
  100137. */
  100138. export class WebXREnterExitUIOptions {
  100139. /**
  100140. * Context to enter xr with
  100141. */
  100142. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100143. /**
  100144. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100145. */
  100146. customButtons?: Array<WebXREnterExitUIButton>;
  100147. }
  100148. /**
  100149. * UI to allow the user to enter/exit XR mode
  100150. */
  100151. export class WebXREnterExitUI implements IDisposable {
  100152. private scene;
  100153. private _overlay;
  100154. private _buttons;
  100155. private _activeButton;
  100156. /**
  100157. * Fired every time the active button is changed.
  100158. *
  100159. * When xr is entered via a button that launches xr that button will be the callback parameter
  100160. *
  100161. * When exiting xr the callback parameter will be null)
  100162. */
  100163. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100164. /**
  100165. * Creates UI to allow the user to enter/exit XR mode
  100166. * @param scene the scene to add the ui to
  100167. * @param helper the xr experience helper to enter/exit xr with
  100168. * @param options options to configure the UI
  100169. * @returns the created ui
  100170. */
  100171. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100172. private constructor();
  100173. private _updateButtons;
  100174. /**
  100175. * Disposes of the object
  100176. */
  100177. dispose(): void;
  100178. }
  100179. }
  100180. declare module BABYLON {
  100181. /**
  100182. * Represents an XR input
  100183. */
  100184. export class WebXRController {
  100185. /**
  100186. * 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
  100187. */
  100188. grip?: AbstractMesh;
  100189. /**
  100190. * Pointer which can be used to select objects or attach a visible laser to
  100191. */
  100192. pointer: AbstractMesh;
  100193. /**
  100194. * Creates the controller
  100195. * @see https://doc.babylonjs.com/how_to/webxr
  100196. * @param scene the scene which the controller should be associated to
  100197. */
  100198. constructor(scene: Scene);
  100199. /**
  100200. * Disposes of the object
  100201. */
  100202. dispose(): void;
  100203. }
  100204. /**
  100205. * XR input used to track XR inputs such as controllers/rays
  100206. */
  100207. export class WebXRInput implements IDisposable {
  100208. private helper;
  100209. /**
  100210. * XR controllers being tracked
  100211. */
  100212. controllers: Array<WebXRController>;
  100213. private _tmpMatrix;
  100214. private _frameObserver;
  100215. /**
  100216. * Initializes the WebXRInput
  100217. * @param helper experience helper which the input should be created for
  100218. */
  100219. constructor(helper: WebXRExperienceHelper);
  100220. /**
  100221. * Disposes of the object
  100222. */
  100223. dispose(): void;
  100224. }
  100225. }
  100226. declare module BABYLON {
  100227. /**
  100228. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100229. */
  100230. export class WebXRManagedOutputCanvas implements IDisposable {
  100231. private _canvas;
  100232. /**
  100233. * xrpresent context of the canvas which can be used to display/mirror xr content
  100234. */
  100235. canvasContext: Nullable<WebGLRenderingContext>;
  100236. /**
  100237. * Initializes the canvas to be added/removed upon entering/exiting xr
  100238. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100239. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100240. */
  100241. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100242. /**
  100243. * Disposes of the object
  100244. */
  100245. dispose(): void;
  100246. private _setManagedOutputCanvas;
  100247. private _addCanvas;
  100248. private _removeCanvas;
  100249. }
  100250. }
  100251. declare module BABYLON {
  100252. /**
  100253. * Contains an array of blocks representing the octree
  100254. */
  100255. export interface IOctreeContainer<T> {
  100256. /**
  100257. * Blocks within the octree
  100258. */
  100259. blocks: Array<OctreeBlock<T>>;
  100260. }
  100261. /**
  100262. * Class used to store a cell in an octree
  100263. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100264. */
  100265. export class OctreeBlock<T> {
  100266. /**
  100267. * Gets the content of the current block
  100268. */
  100269. entries: T[];
  100270. /**
  100271. * Gets the list of block children
  100272. */
  100273. blocks: Array<OctreeBlock<T>>;
  100274. private _depth;
  100275. private _maxDepth;
  100276. private _capacity;
  100277. private _minPoint;
  100278. private _maxPoint;
  100279. private _boundingVectors;
  100280. private _creationFunc;
  100281. /**
  100282. * Creates a new block
  100283. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100284. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100285. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100286. * @param depth defines the current depth of this block in the octree
  100287. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100288. * @param creationFunc defines a callback to call when an element is added to the block
  100289. */
  100290. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100291. /**
  100292. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100293. */
  100294. readonly capacity: number;
  100295. /**
  100296. * Gets the minimum vector (in world space) of the block's bounding box
  100297. */
  100298. readonly minPoint: Vector3;
  100299. /**
  100300. * Gets the maximum vector (in world space) of the block's bounding box
  100301. */
  100302. readonly maxPoint: Vector3;
  100303. /**
  100304. * Add a new element to this block
  100305. * @param entry defines the element to add
  100306. */
  100307. addEntry(entry: T): void;
  100308. /**
  100309. * Remove an element from this block
  100310. * @param entry defines the element to remove
  100311. */
  100312. removeEntry(entry: T): void;
  100313. /**
  100314. * Add an array of elements to this block
  100315. * @param entries defines the array of elements to add
  100316. */
  100317. addEntries(entries: T[]): void;
  100318. /**
  100319. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100320. * @param frustumPlanes defines the frustum planes to test
  100321. * @param selection defines the array to store current content if selection is positive
  100322. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100323. */
  100324. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100325. /**
  100326. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100327. * @param sphereCenter defines the bounding sphere center
  100328. * @param sphereRadius defines the bounding sphere radius
  100329. * @param selection defines the array to store current content if selection is positive
  100330. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100331. */
  100332. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100333. /**
  100334. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100335. * @param ray defines the ray to test with
  100336. * @param selection defines the array to store current content if selection is positive
  100337. */
  100338. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100339. /**
  100340. * Subdivide the content into child blocks (this block will then be empty)
  100341. */
  100342. createInnerBlocks(): void;
  100343. /**
  100344. * @hidden
  100345. */
  100346. 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;
  100347. }
  100348. }
  100349. declare module BABYLON {
  100350. /**
  100351. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100352. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100353. */
  100354. export class Octree<T> {
  100355. /** 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.) */
  100356. maxDepth: number;
  100357. /**
  100358. * Blocks within the octree containing objects
  100359. */
  100360. blocks: Array<OctreeBlock<T>>;
  100361. /**
  100362. * Content stored in the octree
  100363. */
  100364. dynamicContent: T[];
  100365. private _maxBlockCapacity;
  100366. private _selectionContent;
  100367. private _creationFunc;
  100368. /**
  100369. * Creates a octree
  100370. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100371. * @param creationFunc function to be used to instatiate the octree
  100372. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100373. * @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.)
  100374. */
  100375. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100376. /** 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.) */
  100377. maxDepth?: number);
  100378. /**
  100379. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100380. * @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);
  100381. * @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);
  100382. * @param entries meshes to be added to the octree blocks
  100383. */
  100384. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100385. /**
  100386. * Adds a mesh to the octree
  100387. * @param entry Mesh to add to the octree
  100388. */
  100389. addMesh(entry: T): void;
  100390. /**
  100391. * Remove an element from the octree
  100392. * @param entry defines the element to remove
  100393. */
  100394. removeMesh(entry: T): void;
  100395. /**
  100396. * Selects an array of meshes within the frustum
  100397. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100398. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100399. * @returns array of meshes within the frustum
  100400. */
  100401. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100402. /**
  100403. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100404. * @param sphereCenter defines the bounding sphere center
  100405. * @param sphereRadius defines the bounding sphere radius
  100406. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100407. * @returns an array of objects that intersect the sphere
  100408. */
  100409. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100410. /**
  100411. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100412. * @param ray defines the ray to test with
  100413. * @returns array of intersected objects
  100414. */
  100415. intersectsRay(ray: Ray): SmartArray<T>;
  100416. /**
  100417. * Adds a mesh into the octree block if it intersects the block
  100418. */
  100419. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100420. /**
  100421. * Adds a submesh into the octree block if it intersects the block
  100422. */
  100423. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100424. }
  100425. }
  100426. declare module BABYLON {
  100427. interface Scene {
  100428. /**
  100429. * @hidden
  100430. * Backing Filed
  100431. */
  100432. _selectionOctree: Octree<AbstractMesh>;
  100433. /**
  100434. * Gets the octree used to boost mesh selection (picking)
  100435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100436. */
  100437. selectionOctree: Octree<AbstractMesh>;
  100438. /**
  100439. * Creates or updates the octree used to boost selection (picking)
  100440. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100441. * @param maxCapacity defines the maximum capacity per leaf
  100442. * @param maxDepth defines the maximum depth of the octree
  100443. * @returns an octree of AbstractMesh
  100444. */
  100445. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100446. }
  100447. interface AbstractMesh {
  100448. /**
  100449. * @hidden
  100450. * Backing Field
  100451. */
  100452. _submeshesOctree: Octree<SubMesh>;
  100453. /**
  100454. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100455. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100456. * @param maxCapacity defines the maximum size of each block (64 by default)
  100457. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100458. * @returns the new octree
  100459. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100460. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100461. */
  100462. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100463. }
  100464. /**
  100465. * Defines the octree scene component responsible to manage any octrees
  100466. * in a given scene.
  100467. */
  100468. export class OctreeSceneComponent {
  100469. /**
  100470. * The component name help to identify the component in the list of scene components.
  100471. */
  100472. readonly name: string;
  100473. /**
  100474. * The scene the component belongs to.
  100475. */
  100476. scene: Scene;
  100477. /**
  100478. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100479. */
  100480. readonly checksIsEnabled: boolean;
  100481. /**
  100482. * Creates a new instance of the component for the given scene
  100483. * @param scene Defines the scene to register the component in
  100484. */
  100485. constructor(scene: Scene);
  100486. /**
  100487. * Registers the component in a given scene
  100488. */
  100489. register(): void;
  100490. /**
  100491. * Return the list of active meshes
  100492. * @returns the list of active meshes
  100493. */
  100494. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100495. /**
  100496. * Return the list of active sub meshes
  100497. * @param mesh The mesh to get the candidates sub meshes from
  100498. * @returns the list of active sub meshes
  100499. */
  100500. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100501. private _tempRay;
  100502. /**
  100503. * Return the list of sub meshes intersecting with a given local ray
  100504. * @param mesh defines the mesh to find the submesh for
  100505. * @param localRay defines the ray in local space
  100506. * @returns the list of intersecting sub meshes
  100507. */
  100508. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100509. /**
  100510. * Return the list of sub meshes colliding with a collider
  100511. * @param mesh defines the mesh to find the submesh for
  100512. * @param collider defines the collider to evaluate the collision against
  100513. * @returns the list of colliding sub meshes
  100514. */
  100515. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100516. /**
  100517. * Rebuilds the elements related to this component in case of
  100518. * context lost for instance.
  100519. */
  100520. rebuild(): void;
  100521. /**
  100522. * Disposes the component and the associated ressources.
  100523. */
  100524. dispose(): void;
  100525. }
  100526. }
  100527. declare module BABYLON {
  100528. /**
  100529. * Renders a layer on top of an existing scene
  100530. */
  100531. export class UtilityLayerRenderer implements IDisposable {
  100532. /** the original scene that will be rendered on top of */
  100533. originalScene: Scene;
  100534. private _pointerCaptures;
  100535. private _lastPointerEvents;
  100536. private static _DefaultUtilityLayer;
  100537. private static _DefaultKeepDepthUtilityLayer;
  100538. private _sharedGizmoLight;
  100539. /**
  100540. * @hidden
  100541. * Light which used by gizmos to get light shading
  100542. */
  100543. _getSharedGizmoLight(): HemisphericLight;
  100544. /**
  100545. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100546. */
  100547. pickUtilitySceneFirst: boolean;
  100548. /**
  100549. * 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)
  100550. */
  100551. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100552. /**
  100553. * 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)
  100554. */
  100555. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100556. /**
  100557. * The scene that is rendered on top of the original scene
  100558. */
  100559. utilityLayerScene: Scene;
  100560. /**
  100561. * If the utility layer should automatically be rendered on top of existing scene
  100562. */
  100563. shouldRender: boolean;
  100564. /**
  100565. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100566. */
  100567. onlyCheckPointerDownEvents: boolean;
  100568. /**
  100569. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100570. */
  100571. processAllEvents: boolean;
  100572. /**
  100573. * Observable raised when the pointer move from the utility layer scene to the main scene
  100574. */
  100575. onPointerOutObservable: Observable<number>;
  100576. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100577. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100578. private _afterRenderObserver;
  100579. private _sceneDisposeObserver;
  100580. private _originalPointerObserver;
  100581. /**
  100582. * Instantiates a UtilityLayerRenderer
  100583. * @param originalScene the original scene that will be rendered on top of
  100584. * @param handleEvents boolean indicating if the utility layer should handle events
  100585. */
  100586. constructor(
  100587. /** the original scene that will be rendered on top of */
  100588. originalScene: Scene, handleEvents?: boolean);
  100589. private _notifyObservers;
  100590. /**
  100591. * Renders the utility layers scene on top of the original scene
  100592. */
  100593. render(): void;
  100594. /**
  100595. * Disposes of the renderer
  100596. */
  100597. dispose(): void;
  100598. private _updateCamera;
  100599. }
  100600. }
  100601. declare module BABYLON {
  100602. /**
  100603. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100604. */
  100605. export class Gizmo implements IDisposable {
  100606. /** The utility layer the gizmo will be added to */
  100607. gizmoLayer: UtilityLayerRenderer;
  100608. /**
  100609. * The root mesh of the gizmo
  100610. */
  100611. _rootMesh: Mesh;
  100612. private _attachedMesh;
  100613. /**
  100614. * Ratio for the scale of the gizmo (Default: 1)
  100615. */
  100616. scaleRatio: number;
  100617. /**
  100618. * If a custom mesh has been set (Default: false)
  100619. */
  100620. protected _customMeshSet: boolean;
  100621. /**
  100622. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100623. * * When set, interactions will be enabled
  100624. */
  100625. attachedMesh: Nullable<AbstractMesh>;
  100626. /**
  100627. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100628. * @param mesh The mesh to replace the default mesh of the gizmo
  100629. */
  100630. setCustomMesh(mesh: Mesh): void;
  100631. /**
  100632. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100633. */
  100634. updateGizmoRotationToMatchAttachedMesh: boolean;
  100635. /**
  100636. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100637. */
  100638. updateGizmoPositionToMatchAttachedMesh: boolean;
  100639. /**
  100640. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100641. */
  100642. protected _updateScale: boolean;
  100643. protected _interactionsEnabled: boolean;
  100644. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100645. private _beforeRenderObserver;
  100646. private _tempVector;
  100647. /**
  100648. * Creates a gizmo
  100649. * @param gizmoLayer The utility layer the gizmo will be added to
  100650. */
  100651. constructor(
  100652. /** The utility layer the gizmo will be added to */
  100653. gizmoLayer?: UtilityLayerRenderer);
  100654. /**
  100655. * Updates the gizmo to match the attached mesh's position/rotation
  100656. */
  100657. protected _update(): void;
  100658. /**
  100659. * Disposes of the gizmo
  100660. */
  100661. dispose(): void;
  100662. }
  100663. }
  100664. declare module BABYLON {
  100665. /**
  100666. * Single axis drag gizmo
  100667. */
  100668. export class AxisDragGizmo extends Gizmo {
  100669. /**
  100670. * Drag behavior responsible for the gizmos dragging interactions
  100671. */
  100672. dragBehavior: PointerDragBehavior;
  100673. private _pointerObserver;
  100674. /**
  100675. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100676. */
  100677. snapDistance: number;
  100678. /**
  100679. * Event that fires each time the gizmo snaps to a new location.
  100680. * * snapDistance is the the change in distance
  100681. */
  100682. onSnapObservable: Observable<{
  100683. snapDistance: number;
  100684. }>;
  100685. /** @hidden */
  100686. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100687. /** @hidden */
  100688. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100689. /**
  100690. * Creates an AxisDragGizmo
  100691. * @param gizmoLayer The utility layer the gizmo will be added to
  100692. * @param dragAxis The axis which the gizmo will be able to drag on
  100693. * @param color The color of the gizmo
  100694. */
  100695. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100696. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100697. /**
  100698. * Disposes of the gizmo
  100699. */
  100700. dispose(): void;
  100701. }
  100702. }
  100703. declare module BABYLON.Debug {
  100704. /**
  100705. * The Axes viewer will show 3 axes in a specific point in space
  100706. */
  100707. export class AxesViewer {
  100708. private _xAxis;
  100709. private _yAxis;
  100710. private _zAxis;
  100711. private _scaleLinesFactor;
  100712. private _instanced;
  100713. /**
  100714. * Gets the hosting scene
  100715. */
  100716. scene: Scene;
  100717. /**
  100718. * Gets or sets a number used to scale line length
  100719. */
  100720. scaleLines: number;
  100721. /** Gets the node hierarchy used to render x-axis */
  100722. readonly xAxis: TransformNode;
  100723. /** Gets the node hierarchy used to render y-axis */
  100724. readonly yAxis: TransformNode;
  100725. /** Gets the node hierarchy used to render z-axis */
  100726. readonly zAxis: TransformNode;
  100727. /**
  100728. * Creates a new AxesViewer
  100729. * @param scene defines the hosting scene
  100730. * @param scaleLines defines a number used to scale line length (1 by default)
  100731. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100732. * @param xAxis defines the node hierarchy used to render the x-axis
  100733. * @param yAxis defines the node hierarchy used to render the y-axis
  100734. * @param zAxis defines the node hierarchy used to render the z-axis
  100735. */
  100736. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100737. /**
  100738. * Force the viewer to update
  100739. * @param position defines the position of the viewer
  100740. * @param xaxis defines the x axis of the viewer
  100741. * @param yaxis defines the y axis of the viewer
  100742. * @param zaxis defines the z axis of the viewer
  100743. */
  100744. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100745. /**
  100746. * Creates an instance of this axes viewer.
  100747. * @returns a new axes viewer with instanced meshes
  100748. */
  100749. createInstance(): AxesViewer;
  100750. /** Releases resources */
  100751. dispose(): void;
  100752. private static _SetRenderingGroupId;
  100753. }
  100754. }
  100755. declare module BABYLON.Debug {
  100756. /**
  100757. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100758. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100759. */
  100760. export class BoneAxesViewer extends AxesViewer {
  100761. /**
  100762. * Gets or sets the target mesh where to display the axes viewer
  100763. */
  100764. mesh: Nullable<Mesh>;
  100765. /**
  100766. * Gets or sets the target bone where to display the axes viewer
  100767. */
  100768. bone: Nullable<Bone>;
  100769. /** Gets current position */
  100770. pos: Vector3;
  100771. /** Gets direction of X axis */
  100772. xaxis: Vector3;
  100773. /** Gets direction of Y axis */
  100774. yaxis: Vector3;
  100775. /** Gets direction of Z axis */
  100776. zaxis: Vector3;
  100777. /**
  100778. * Creates a new BoneAxesViewer
  100779. * @param scene defines the hosting scene
  100780. * @param bone defines the target bone
  100781. * @param mesh defines the target mesh
  100782. * @param scaleLines defines a scaling factor for line length (1 by default)
  100783. */
  100784. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100785. /**
  100786. * Force the viewer to update
  100787. */
  100788. update(): void;
  100789. /** Releases resources */
  100790. dispose(): void;
  100791. }
  100792. }
  100793. declare module BABYLON {
  100794. /**
  100795. * Interface used to define scene explorer extensibility option
  100796. */
  100797. export interface IExplorerExtensibilityOption {
  100798. /**
  100799. * Define the option label
  100800. */
  100801. label: string;
  100802. /**
  100803. * Defines the action to execute on click
  100804. */
  100805. action: (entity: any) => void;
  100806. }
  100807. /**
  100808. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100809. */
  100810. export interface IExplorerExtensibilityGroup {
  100811. /**
  100812. * Defines a predicate to test if a given type mut be extended
  100813. */
  100814. predicate: (entity: any) => boolean;
  100815. /**
  100816. * Gets the list of options added to a type
  100817. */
  100818. entries: IExplorerExtensibilityOption[];
  100819. }
  100820. /**
  100821. * Interface used to define the options to use to create the Inspector
  100822. */
  100823. export interface IInspectorOptions {
  100824. /**
  100825. * Display in overlay mode (default: false)
  100826. */
  100827. overlay?: boolean;
  100828. /**
  100829. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100830. */
  100831. globalRoot?: HTMLElement;
  100832. /**
  100833. * Display the Scene explorer
  100834. */
  100835. showExplorer?: boolean;
  100836. /**
  100837. * Display the property inspector
  100838. */
  100839. showInspector?: boolean;
  100840. /**
  100841. * Display in embed mode (both panes on the right)
  100842. */
  100843. embedMode?: boolean;
  100844. /**
  100845. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100846. */
  100847. handleResize?: boolean;
  100848. /**
  100849. * Allow the panes to popup (default: true)
  100850. */
  100851. enablePopup?: boolean;
  100852. /**
  100853. * Allow the panes to be closed by users (default: true)
  100854. */
  100855. enableClose?: boolean;
  100856. /**
  100857. * Optional list of extensibility entries
  100858. */
  100859. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100860. /**
  100861. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100862. */
  100863. inspectorURL?: string;
  100864. }
  100865. interface Scene {
  100866. /**
  100867. * @hidden
  100868. * Backing field
  100869. */
  100870. _debugLayer: DebugLayer;
  100871. /**
  100872. * Gets the debug layer (aka Inspector) associated with the scene
  100873. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100874. */
  100875. debugLayer: DebugLayer;
  100876. }
  100877. /**
  100878. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100879. * what is happening in your scene
  100880. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100881. */
  100882. export class DebugLayer {
  100883. /**
  100884. * Define the url to get the inspector script from.
  100885. * By default it uses the babylonjs CDN.
  100886. * @ignoreNaming
  100887. */
  100888. static InspectorURL: string;
  100889. private _scene;
  100890. private BJSINSPECTOR;
  100891. /**
  100892. * Observable triggered when a property is changed through the inspector.
  100893. */
  100894. onPropertyChangedObservable: Observable<{
  100895. object: any;
  100896. property: string;
  100897. value: any;
  100898. initialValue: any;
  100899. }>;
  100900. /**
  100901. * Instantiates a new debug layer.
  100902. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100903. * what is happening in your scene
  100904. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100905. * @param scene Defines the scene to inspect
  100906. */
  100907. constructor(scene: Scene);
  100908. /** Creates the inspector window. */
  100909. private _createInspector;
  100910. /**
  100911. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100912. * @param entity defines the entity to select
  100913. * @param lineContainerTitle defines the specific block to highlight
  100914. */
  100915. select(entity: any, lineContainerTitle?: string): void;
  100916. /** Get the inspector from bundle or global */
  100917. private _getGlobalInspector;
  100918. /**
  100919. * Get if the inspector is visible or not.
  100920. * @returns true if visible otherwise, false
  100921. */
  100922. isVisible(): boolean;
  100923. /**
  100924. * Hide the inspector and close its window.
  100925. */
  100926. hide(): void;
  100927. /**
  100928. * Launch the debugLayer.
  100929. * @param config Define the configuration of the inspector
  100930. * @return a promise fulfilled when the debug layer is visible
  100931. */
  100932. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100933. }
  100934. }
  100935. declare module BABYLON {
  100936. /**
  100937. * Class containing static functions to help procedurally build meshes
  100938. */
  100939. export class BoxBuilder {
  100940. /**
  100941. * Creates a box mesh
  100942. * * The parameter `size` sets the size (float) of each box side (default 1)
  100943. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100944. * * 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)
  100945. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100949. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100950. * @param name defines the name of the mesh
  100951. * @param options defines the options used to create the mesh
  100952. * @param scene defines the hosting scene
  100953. * @returns the box mesh
  100954. */
  100955. static CreateBox(name: string, options: {
  100956. size?: number;
  100957. width?: number;
  100958. height?: number;
  100959. depth?: number;
  100960. faceUV?: Vector4[];
  100961. faceColors?: Color4[];
  100962. sideOrientation?: number;
  100963. frontUVs?: Vector4;
  100964. backUVs?: Vector4;
  100965. wrap?: boolean;
  100966. topBaseAt?: number;
  100967. bottomBaseAt?: number;
  100968. updatable?: boolean;
  100969. }, scene?: Nullable<Scene>): Mesh;
  100970. }
  100971. }
  100972. declare module BABYLON {
  100973. /**
  100974. * Class containing static functions to help procedurally build meshes
  100975. */
  100976. export class SphereBuilder {
  100977. /**
  100978. * Creates a sphere mesh
  100979. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100980. * * 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`)
  100981. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100982. * * 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
  100983. * * 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)
  100984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100985. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100987. * @param name defines the name of the mesh
  100988. * @param options defines the options used to create the mesh
  100989. * @param scene defines the hosting scene
  100990. * @returns the sphere mesh
  100991. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100992. */
  100993. static CreateSphere(name: string, options: {
  100994. segments?: number;
  100995. diameter?: number;
  100996. diameterX?: number;
  100997. diameterY?: number;
  100998. diameterZ?: number;
  100999. arc?: number;
  101000. slice?: number;
  101001. sideOrientation?: number;
  101002. frontUVs?: Vector4;
  101003. backUVs?: Vector4;
  101004. updatable?: boolean;
  101005. }, scene: any): Mesh;
  101006. }
  101007. }
  101008. declare module BABYLON.Debug {
  101009. /**
  101010. * Used to show the physics impostor around the specific mesh
  101011. */
  101012. export class PhysicsViewer {
  101013. /** @hidden */
  101014. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  101015. /** @hidden */
  101016. protected _meshes: Array<Nullable<AbstractMesh>>;
  101017. /** @hidden */
  101018. protected _scene: Nullable<Scene>;
  101019. /** @hidden */
  101020. protected _numMeshes: number;
  101021. /** @hidden */
  101022. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  101023. private _renderFunction;
  101024. private _utilityLayer;
  101025. private _debugBoxMesh;
  101026. private _debugSphereMesh;
  101027. private _debugCylinderMesh;
  101028. private _debugMaterial;
  101029. private _debugMeshMeshes;
  101030. /**
  101031. * Creates a new PhysicsViewer
  101032. * @param scene defines the hosting scene
  101033. */
  101034. constructor(scene: Scene);
  101035. /** @hidden */
  101036. protected _updateDebugMeshes(): void;
  101037. /**
  101038. * Renders a specified physic impostor
  101039. * @param impostor defines the impostor to render
  101040. * @param targetMesh defines the mesh represented by the impostor
  101041. * @returns the new debug mesh used to render the impostor
  101042. */
  101043. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101044. /**
  101045. * Hides a specified physic impostor
  101046. * @param impostor defines the impostor to hide
  101047. */
  101048. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101049. private _getDebugMaterial;
  101050. private _getDebugBoxMesh;
  101051. private _getDebugSphereMesh;
  101052. private _getDebugCylinderMesh;
  101053. private _getDebugMeshMesh;
  101054. private _getDebugMesh;
  101055. /** Releases all resources */
  101056. dispose(): void;
  101057. }
  101058. }
  101059. declare module BABYLON {
  101060. /**
  101061. * Class containing static functions to help procedurally build meshes
  101062. */
  101063. export class LinesBuilder {
  101064. /**
  101065. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101066. * * 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
  101067. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101068. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101069. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101070. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101071. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101072. * * 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
  101073. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101075. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101076. * @param name defines the name of the new line system
  101077. * @param options defines the options used to create the line system
  101078. * @param scene defines the hosting scene
  101079. * @returns a new line system mesh
  101080. */
  101081. static CreateLineSystem(name: string, options: {
  101082. lines: Vector3[][];
  101083. updatable?: boolean;
  101084. instance?: Nullable<LinesMesh>;
  101085. colors?: Nullable<Color4[][]>;
  101086. useVertexAlpha?: boolean;
  101087. }, scene: Nullable<Scene>): LinesMesh;
  101088. /**
  101089. * Creates a line mesh
  101090. * 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
  101091. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101092. * * The parameter `points` is an array successive Vector3
  101093. * * 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
  101094. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101095. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101096. * * When updating an instance, remember that only point positions can change, not the number of points
  101097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101099. * @param name defines the name of the new line system
  101100. * @param options defines the options used to create the line system
  101101. * @param scene defines the hosting scene
  101102. * @returns a new line mesh
  101103. */
  101104. static CreateLines(name: string, options: {
  101105. points: Vector3[];
  101106. updatable?: boolean;
  101107. instance?: Nullable<LinesMesh>;
  101108. colors?: Color4[];
  101109. useVertexAlpha?: boolean;
  101110. }, scene?: Nullable<Scene>): LinesMesh;
  101111. /**
  101112. * Creates a dashed line mesh
  101113. * * 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
  101114. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101115. * * The parameter `points` is an array successive Vector3
  101116. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101117. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101118. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101119. * * 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
  101120. * * When updating an instance, remember that only point positions can change, not the number of points
  101121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101122. * @param name defines the name of the mesh
  101123. * @param options defines the options used to create the mesh
  101124. * @param scene defines the hosting scene
  101125. * @returns the dashed line mesh
  101126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101127. */
  101128. static CreateDashedLines(name: string, options: {
  101129. points: Vector3[];
  101130. dashSize?: number;
  101131. gapSize?: number;
  101132. dashNb?: number;
  101133. updatable?: boolean;
  101134. instance?: LinesMesh;
  101135. }, scene?: Nullable<Scene>): LinesMesh;
  101136. }
  101137. }
  101138. declare module BABYLON {
  101139. /**
  101140. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101141. * in order to better appreciate the issue one might have.
  101142. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101143. */
  101144. export class RayHelper {
  101145. /**
  101146. * Defines the ray we are currently tryin to visualize.
  101147. */
  101148. ray: Nullable<Ray>;
  101149. private _renderPoints;
  101150. private _renderLine;
  101151. private _renderFunction;
  101152. private _scene;
  101153. private _updateToMeshFunction;
  101154. private _attachedToMesh;
  101155. private _meshSpaceDirection;
  101156. private _meshSpaceOrigin;
  101157. /**
  101158. * Helper function to create a colored helper in a scene in one line.
  101159. * @param ray Defines the ray we are currently tryin to visualize
  101160. * @param scene Defines the scene the ray is used in
  101161. * @param color Defines the color we want to see the ray in
  101162. * @returns The newly created ray helper.
  101163. */
  101164. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101165. /**
  101166. * Instantiate a new ray helper.
  101167. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101168. * in order to better appreciate the issue one might have.
  101169. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101170. * @param ray Defines the ray we are currently tryin to visualize
  101171. */
  101172. constructor(ray: Ray);
  101173. /**
  101174. * Shows the ray we are willing to debug.
  101175. * @param scene Defines the scene the ray needs to be rendered in
  101176. * @param color Defines the color the ray needs to be rendered in
  101177. */
  101178. show(scene: Scene, color?: Color3): void;
  101179. /**
  101180. * Hides the ray we are debugging.
  101181. */
  101182. hide(): void;
  101183. private _render;
  101184. /**
  101185. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101186. * @param mesh Defines the mesh we want the helper attached to
  101187. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101188. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101189. * @param length Defines the length of the ray
  101190. */
  101191. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101192. /**
  101193. * Detach the ray helper from the mesh it has previously been attached to.
  101194. */
  101195. detachFromMesh(): void;
  101196. private _updateToMesh;
  101197. /**
  101198. * Dispose the helper and release its associated resources.
  101199. */
  101200. dispose(): void;
  101201. }
  101202. }
  101203. declare module BABYLON.Debug {
  101204. /**
  101205. * Class used to render a debug view of a given skeleton
  101206. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101207. */
  101208. export class SkeletonViewer {
  101209. /** defines the skeleton to render */
  101210. skeleton: Skeleton;
  101211. /** defines the mesh attached to the skeleton */
  101212. mesh: AbstractMesh;
  101213. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101214. autoUpdateBonesMatrices: boolean;
  101215. /** defines the rendering group id to use with the viewer */
  101216. renderingGroupId: number;
  101217. /** Gets or sets the color used to render the skeleton */
  101218. color: Color3;
  101219. private _scene;
  101220. private _debugLines;
  101221. private _debugMesh;
  101222. private _isEnabled;
  101223. private _renderFunction;
  101224. private _utilityLayer;
  101225. /**
  101226. * Returns the mesh used to render the bones
  101227. */
  101228. readonly debugMesh: Nullable<LinesMesh>;
  101229. /**
  101230. * Creates a new SkeletonViewer
  101231. * @param skeleton defines the skeleton to render
  101232. * @param mesh defines the mesh attached to the skeleton
  101233. * @param scene defines the hosting scene
  101234. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101235. * @param renderingGroupId defines the rendering group id to use with the viewer
  101236. */
  101237. constructor(
  101238. /** defines the skeleton to render */
  101239. skeleton: Skeleton,
  101240. /** defines the mesh attached to the skeleton */
  101241. mesh: AbstractMesh, scene: Scene,
  101242. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101243. autoUpdateBonesMatrices?: boolean,
  101244. /** defines the rendering group id to use with the viewer */
  101245. renderingGroupId?: number);
  101246. /** Gets or sets a boolean indicating if the viewer is enabled */
  101247. isEnabled: boolean;
  101248. private _getBonePosition;
  101249. private _getLinesForBonesWithLength;
  101250. private _getLinesForBonesNoLength;
  101251. /** Update the viewer to sync with current skeleton state */
  101252. update(): void;
  101253. /** Release associated resources */
  101254. dispose(): void;
  101255. }
  101256. }
  101257. declare module BABYLON {
  101258. /**
  101259. * Options to create the null engine
  101260. */
  101261. export class NullEngineOptions {
  101262. /**
  101263. * Render width (Default: 512)
  101264. */
  101265. renderWidth: number;
  101266. /**
  101267. * Render height (Default: 256)
  101268. */
  101269. renderHeight: number;
  101270. /**
  101271. * Texture size (Default: 512)
  101272. */
  101273. textureSize: number;
  101274. /**
  101275. * If delta time between frames should be constant
  101276. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101277. */
  101278. deterministicLockstep: boolean;
  101279. /**
  101280. * Maximum about of steps between frames (Default: 4)
  101281. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101282. */
  101283. lockstepMaxSteps: number;
  101284. }
  101285. /**
  101286. * The null engine class provides support for headless version of babylon.js.
  101287. * This can be used in server side scenario or for testing purposes
  101288. */
  101289. export class NullEngine extends Engine {
  101290. private _options;
  101291. /**
  101292. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101293. */
  101294. isDeterministicLockStep(): boolean;
  101295. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101296. getLockstepMaxSteps(): number;
  101297. /**
  101298. * Sets hardware scaling, used to save performance if needed
  101299. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101300. */
  101301. getHardwareScalingLevel(): number;
  101302. constructor(options?: NullEngineOptions);
  101303. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101304. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101305. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101306. getRenderWidth(useScreen?: boolean): number;
  101307. getRenderHeight(useScreen?: boolean): number;
  101308. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101309. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101310. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101311. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101312. bindSamplers(effect: Effect): void;
  101313. enableEffect(effect: Effect): void;
  101314. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101315. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101316. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101317. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101318. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101319. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101320. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101321. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101322. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101323. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101324. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101325. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101326. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101327. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101328. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101329. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101330. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101331. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101332. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101333. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101334. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101335. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101336. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101337. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101338. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101339. bindBuffers(vertexBuffers: {
  101340. [key: string]: VertexBuffer;
  101341. }, indexBuffer: DataBuffer, effect: Effect): void;
  101342. wipeCaches(bruteForce?: boolean): void;
  101343. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101344. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101345. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101346. /** @hidden */
  101347. _createTexture(): WebGLTexture;
  101348. /** @hidden */
  101349. _releaseTexture(texture: InternalTexture): void;
  101350. 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;
  101351. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101352. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101353. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101354. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101355. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101356. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101357. areAllEffectsReady(): boolean;
  101358. /**
  101359. * @hidden
  101360. * Get the current error code of the webGL context
  101361. * @returns the error code
  101362. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101363. */
  101364. getError(): number;
  101365. /** @hidden */
  101366. _getUnpackAlignement(): number;
  101367. /** @hidden */
  101368. _unpackFlipY(value: boolean): void;
  101369. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101370. /**
  101371. * Updates a dynamic vertex buffer.
  101372. * @param vertexBuffer the vertex buffer to update
  101373. * @param data the data used to update the vertex buffer
  101374. * @param byteOffset the byte offset of the data (optional)
  101375. * @param byteLength the byte length of the data (optional)
  101376. */
  101377. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101378. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101379. /** @hidden */
  101380. _bindTexture(channel: number, texture: InternalTexture): void;
  101381. /** @hidden */
  101382. _releaseBuffer(buffer: DataBuffer): boolean;
  101383. releaseEffects(): void;
  101384. displayLoadingUI(): void;
  101385. hideLoadingUI(): void;
  101386. /** @hidden */
  101387. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101388. /** @hidden */
  101389. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101390. /** @hidden */
  101391. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101392. /** @hidden */
  101393. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101394. }
  101395. }
  101396. declare module BABYLON {
  101397. /** @hidden */
  101398. export class _OcclusionDataStorage {
  101399. /** @hidden */
  101400. occlusionInternalRetryCounter: number;
  101401. /** @hidden */
  101402. isOcclusionQueryInProgress: boolean;
  101403. /** @hidden */
  101404. isOccluded: boolean;
  101405. /** @hidden */
  101406. occlusionRetryCount: number;
  101407. /** @hidden */
  101408. occlusionType: number;
  101409. /** @hidden */
  101410. occlusionQueryAlgorithmType: number;
  101411. }
  101412. interface Engine {
  101413. /**
  101414. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101415. * @return the new query
  101416. */
  101417. createQuery(): WebGLQuery;
  101418. /**
  101419. * Delete and release a webGL query
  101420. * @param query defines the query to delete
  101421. * @return the current engine
  101422. */
  101423. deleteQuery(query: WebGLQuery): Engine;
  101424. /**
  101425. * Check if a given query has resolved and got its value
  101426. * @param query defines the query to check
  101427. * @returns true if the query got its value
  101428. */
  101429. isQueryResultAvailable(query: WebGLQuery): boolean;
  101430. /**
  101431. * Gets the value of a given query
  101432. * @param query defines the query to check
  101433. * @returns the value of the query
  101434. */
  101435. getQueryResult(query: WebGLQuery): number;
  101436. /**
  101437. * Initiates an occlusion query
  101438. * @param algorithmType defines the algorithm to use
  101439. * @param query defines the query to use
  101440. * @returns the current engine
  101441. * @see http://doc.babylonjs.com/features/occlusionquery
  101442. */
  101443. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101444. /**
  101445. * Ends an occlusion query
  101446. * @see http://doc.babylonjs.com/features/occlusionquery
  101447. * @param algorithmType defines the algorithm to use
  101448. * @returns the current engine
  101449. */
  101450. endOcclusionQuery(algorithmType: number): Engine;
  101451. /**
  101452. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101453. * Please note that only one query can be issued at a time
  101454. * @returns a time token used to track the time span
  101455. */
  101456. startTimeQuery(): Nullable<_TimeToken>;
  101457. /**
  101458. * Ends a time query
  101459. * @param token defines the token used to measure the time span
  101460. * @returns the time spent (in ns)
  101461. */
  101462. endTimeQuery(token: _TimeToken): int;
  101463. /** @hidden */
  101464. _currentNonTimestampToken: Nullable<_TimeToken>;
  101465. /** @hidden */
  101466. _createTimeQuery(): WebGLQuery;
  101467. /** @hidden */
  101468. _deleteTimeQuery(query: WebGLQuery): void;
  101469. /** @hidden */
  101470. _getGlAlgorithmType(algorithmType: number): number;
  101471. /** @hidden */
  101472. _getTimeQueryResult(query: WebGLQuery): any;
  101473. /** @hidden */
  101474. _getTimeQueryAvailability(query: WebGLQuery): any;
  101475. }
  101476. interface AbstractMesh {
  101477. /**
  101478. * Backing filed
  101479. * @hidden
  101480. */
  101481. __occlusionDataStorage: _OcclusionDataStorage;
  101482. /**
  101483. * Access property
  101484. * @hidden
  101485. */
  101486. _occlusionDataStorage: _OcclusionDataStorage;
  101487. /**
  101488. * 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.
  101489. * The default value is -1 which means don't break the query and wait till the result
  101490. * @see http://doc.babylonjs.com/features/occlusionquery
  101491. */
  101492. occlusionRetryCount: number;
  101493. /**
  101494. * 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:
  101495. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101496. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101497. * * 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.
  101498. * @see http://doc.babylonjs.com/features/occlusionquery
  101499. */
  101500. occlusionType: number;
  101501. /**
  101502. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101503. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101504. * * 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.
  101505. * @see http://doc.babylonjs.com/features/occlusionquery
  101506. */
  101507. occlusionQueryAlgorithmType: number;
  101508. /**
  101509. * 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
  101510. * @see http://doc.babylonjs.com/features/occlusionquery
  101511. */
  101512. isOccluded: boolean;
  101513. /**
  101514. * Flag to check the progress status of the query
  101515. * @see http://doc.babylonjs.com/features/occlusionquery
  101516. */
  101517. isOcclusionQueryInProgress: boolean;
  101518. }
  101519. }
  101520. declare module BABYLON {
  101521. /** @hidden */
  101522. export var _forceTransformFeedbackToBundle: boolean;
  101523. interface Engine {
  101524. /**
  101525. * Creates a webGL transform feedback object
  101526. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101527. * @returns the webGL transform feedback object
  101528. */
  101529. createTransformFeedback(): WebGLTransformFeedback;
  101530. /**
  101531. * Delete a webGL transform feedback object
  101532. * @param value defines the webGL transform feedback object to delete
  101533. */
  101534. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101535. /**
  101536. * Bind a webGL transform feedback object to the webgl context
  101537. * @param value defines the webGL transform feedback object to bind
  101538. */
  101539. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101540. /**
  101541. * Begins a transform feedback operation
  101542. * @param usePoints defines if points or triangles must be used
  101543. */
  101544. beginTransformFeedback(usePoints: boolean): void;
  101545. /**
  101546. * Ends a transform feedback operation
  101547. */
  101548. endTransformFeedback(): void;
  101549. /**
  101550. * Specify the varyings to use with transform feedback
  101551. * @param program defines the associated webGL program
  101552. * @param value defines the list of strings representing the varying names
  101553. */
  101554. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101555. /**
  101556. * Bind a webGL buffer for a transform feedback operation
  101557. * @param value defines the webGL buffer to bind
  101558. */
  101559. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  101560. }
  101561. }
  101562. declare module BABYLON {
  101563. /**
  101564. * Creation options of the multi render target texture.
  101565. */
  101566. export interface IMultiRenderTargetOptions {
  101567. /**
  101568. * Define if the texture needs to create mip maps after render.
  101569. */
  101570. generateMipMaps?: boolean;
  101571. /**
  101572. * Define the types of all the draw buffers we want to create
  101573. */
  101574. types?: number[];
  101575. /**
  101576. * Define the sampling modes of all the draw buffers we want to create
  101577. */
  101578. samplingModes?: number[];
  101579. /**
  101580. * Define if a depth buffer is required
  101581. */
  101582. generateDepthBuffer?: boolean;
  101583. /**
  101584. * Define if a stencil buffer is required
  101585. */
  101586. generateStencilBuffer?: boolean;
  101587. /**
  101588. * Define if a depth texture is required instead of a depth buffer
  101589. */
  101590. generateDepthTexture?: boolean;
  101591. /**
  101592. * Define the number of desired draw buffers
  101593. */
  101594. textureCount?: number;
  101595. /**
  101596. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101597. */
  101598. doNotChangeAspectRatio?: boolean;
  101599. /**
  101600. * Define the default type of the buffers we are creating
  101601. */
  101602. defaultType?: number;
  101603. }
  101604. /**
  101605. * A multi render target, like a render target provides the ability to render to a texture.
  101606. * Unlike the render target, it can render to several draw buffers in one draw.
  101607. * This is specially interesting in deferred rendering or for any effects requiring more than
  101608. * just one color from a single pass.
  101609. */
  101610. export class MultiRenderTarget extends RenderTargetTexture {
  101611. private _internalTextures;
  101612. private _textures;
  101613. private _multiRenderTargetOptions;
  101614. /**
  101615. * Get if draw buffers are currently supported by the used hardware and browser.
  101616. */
  101617. readonly isSupported: boolean;
  101618. /**
  101619. * Get the list of textures generated by the multi render target.
  101620. */
  101621. readonly textures: Texture[];
  101622. /**
  101623. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101624. */
  101625. readonly depthTexture: Texture;
  101626. /**
  101627. * Set the wrapping mode on U of all the textures we are rendering to.
  101628. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101629. */
  101630. wrapU: number;
  101631. /**
  101632. * Set the wrapping mode on V of all the textures we are rendering to.
  101633. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101634. */
  101635. wrapV: number;
  101636. /**
  101637. * Instantiate a new multi render target texture.
  101638. * A multi render target, like a render target provides the ability to render to a texture.
  101639. * Unlike the render target, it can render to several draw buffers in one draw.
  101640. * This is specially interesting in deferred rendering or for any effects requiring more than
  101641. * just one color from a single pass.
  101642. * @param name Define the name of the texture
  101643. * @param size Define the size of the buffers to render to
  101644. * @param count Define the number of target we are rendering into
  101645. * @param scene Define the scene the texture belongs to
  101646. * @param options Define the options used to create the multi render target
  101647. */
  101648. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101649. /** @hidden */
  101650. _rebuild(): void;
  101651. private _createInternalTextures;
  101652. private _createTextures;
  101653. /**
  101654. * Define the number of samples used if MSAA is enabled.
  101655. */
  101656. samples: number;
  101657. /**
  101658. * Resize all the textures in the multi render target.
  101659. * Be carrefull as it will recreate all the data in the new texture.
  101660. * @param size Define the new size
  101661. */
  101662. resize(size: any): void;
  101663. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101664. /**
  101665. * Dispose the render targets and their associated resources
  101666. */
  101667. dispose(): void;
  101668. /**
  101669. * Release all the underlying texture used as draw buffers.
  101670. */
  101671. releaseInternalTextures(): void;
  101672. }
  101673. }
  101674. declare module BABYLON {
  101675. interface Engine {
  101676. /**
  101677. * Unbind a list of render target textures from the webGL context
  101678. * This is used only when drawBuffer extension or webGL2 are active
  101679. * @param textures defines the render target textures to unbind
  101680. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101681. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101682. */
  101683. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101684. /**
  101685. * Create a multi render target texture
  101686. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101687. * @param size defines the size of the texture
  101688. * @param options defines the creation options
  101689. * @returns the cube texture as an InternalTexture
  101690. */
  101691. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101692. /**
  101693. * Update the sample count for a given multiple render target texture
  101694. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101695. * @param textures defines the textures to update
  101696. * @param samples defines the sample count to set
  101697. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101698. */
  101699. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101700. }
  101701. }
  101702. declare module BABYLON {
  101703. /**
  101704. * Gather the list of clipboard event types as constants.
  101705. */
  101706. export class ClipboardEventTypes {
  101707. /**
  101708. * The clipboard event is fired when a copy command is active (pressed).
  101709. */
  101710. static readonly COPY: number;
  101711. /**
  101712. * The clipboard event is fired when a cut command is active (pressed).
  101713. */
  101714. static readonly CUT: number;
  101715. /**
  101716. * The clipboard event is fired when a paste command is active (pressed).
  101717. */
  101718. static readonly PASTE: number;
  101719. }
  101720. /**
  101721. * This class is used to store clipboard related info for the onClipboardObservable event.
  101722. */
  101723. export class ClipboardInfo {
  101724. /**
  101725. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101726. */
  101727. type: number;
  101728. /**
  101729. * Defines the related dom event
  101730. */
  101731. event: ClipboardEvent;
  101732. /**
  101733. *Creates an instance of ClipboardInfo.
  101734. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101735. * @param event Defines the related dom event
  101736. */
  101737. constructor(
  101738. /**
  101739. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101740. */
  101741. type: number,
  101742. /**
  101743. * Defines the related dom event
  101744. */
  101745. event: ClipboardEvent);
  101746. /**
  101747. * Get the clipboard event's type from the keycode.
  101748. * @param keyCode Defines the keyCode for the current keyboard event.
  101749. * @return {number}
  101750. */
  101751. static GetTypeFromCharacter(keyCode: number): number;
  101752. }
  101753. }
  101754. declare module BABYLON {
  101755. /**
  101756. * Class used to represent data loading progression
  101757. */
  101758. export class SceneLoaderProgressEvent {
  101759. /** defines if data length to load can be evaluated */
  101760. readonly lengthComputable: boolean;
  101761. /** defines the loaded data length */
  101762. readonly loaded: number;
  101763. /** defines the data length to load */
  101764. readonly total: number;
  101765. /**
  101766. * Create a new progress event
  101767. * @param lengthComputable defines if data length to load can be evaluated
  101768. * @param loaded defines the loaded data length
  101769. * @param total defines the data length to load
  101770. */
  101771. constructor(
  101772. /** defines if data length to load can be evaluated */
  101773. lengthComputable: boolean,
  101774. /** defines the loaded data length */
  101775. loaded: number,
  101776. /** defines the data length to load */
  101777. total: number);
  101778. /**
  101779. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101780. * @param event defines the source event
  101781. * @returns a new SceneLoaderProgressEvent
  101782. */
  101783. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101784. }
  101785. /**
  101786. * Interface used by SceneLoader plugins to define supported file extensions
  101787. */
  101788. export interface ISceneLoaderPluginExtensions {
  101789. /**
  101790. * Defines the list of supported extensions
  101791. */
  101792. [extension: string]: {
  101793. isBinary: boolean;
  101794. };
  101795. }
  101796. /**
  101797. * Interface used by SceneLoader plugin factory
  101798. */
  101799. export interface ISceneLoaderPluginFactory {
  101800. /**
  101801. * Defines the name of the factory
  101802. */
  101803. name: string;
  101804. /**
  101805. * Function called to create a new plugin
  101806. * @return the new plugin
  101807. */
  101808. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101809. /**
  101810. * Boolean indicating if the plugin can direct load specific data
  101811. */
  101812. canDirectLoad?: (data: string) => boolean;
  101813. }
  101814. /**
  101815. * Interface used to define a SceneLoader plugin
  101816. */
  101817. export interface ISceneLoaderPlugin {
  101818. /**
  101819. * The friendly name of this plugin.
  101820. */
  101821. name: string;
  101822. /**
  101823. * The file extensions supported by this plugin.
  101824. */
  101825. extensions: string | ISceneLoaderPluginExtensions;
  101826. /**
  101827. * Import meshes into a scene.
  101828. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101829. * @param scene The scene to import into
  101830. * @param data The data to import
  101831. * @param rootUrl The root url for scene and resources
  101832. * @param meshes The meshes array to import into
  101833. * @param particleSystems The particle systems array to import into
  101834. * @param skeletons The skeletons array to import into
  101835. * @param onError The callback when import fails
  101836. * @returns True if successful or false otherwise
  101837. */
  101838. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101839. /**
  101840. * Load into a scene.
  101841. * @param scene The scene to load into
  101842. * @param data The data to import
  101843. * @param rootUrl The root url for scene and resources
  101844. * @param onError The callback when import fails
  101845. * @returns true if successful or false otherwise
  101846. */
  101847. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101848. /**
  101849. * The callback that returns true if the data can be directly loaded.
  101850. */
  101851. canDirectLoad?: (data: string) => boolean;
  101852. /**
  101853. * The callback that allows custom handling of the root url based on the response url.
  101854. */
  101855. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101856. /**
  101857. * Load into an asset container.
  101858. * @param scene The scene to load into
  101859. * @param data The data to import
  101860. * @param rootUrl The root url for scene and resources
  101861. * @param onError The callback when import fails
  101862. * @returns The loaded asset container
  101863. */
  101864. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101865. }
  101866. /**
  101867. * Interface used to define an async SceneLoader plugin
  101868. */
  101869. export interface ISceneLoaderPluginAsync {
  101870. /**
  101871. * The friendly name of this plugin.
  101872. */
  101873. name: string;
  101874. /**
  101875. * The file extensions supported by this plugin.
  101876. */
  101877. extensions: string | ISceneLoaderPluginExtensions;
  101878. /**
  101879. * Import meshes into a scene.
  101880. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101881. * @param scene The scene to import into
  101882. * @param data The data to import
  101883. * @param rootUrl The root url for scene and resources
  101884. * @param onProgress The callback when the load progresses
  101885. * @param fileName Defines the name of the file to load
  101886. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101887. */
  101888. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101889. meshes: AbstractMesh[];
  101890. particleSystems: IParticleSystem[];
  101891. skeletons: Skeleton[];
  101892. animationGroups: AnimationGroup[];
  101893. }>;
  101894. /**
  101895. * Load into a scene.
  101896. * @param scene The scene to load into
  101897. * @param data The data to import
  101898. * @param rootUrl The root url for scene and resources
  101899. * @param onProgress The callback when the load progresses
  101900. * @param fileName Defines the name of the file to load
  101901. * @returns Nothing
  101902. */
  101903. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101904. /**
  101905. * The callback that returns true if the data can be directly loaded.
  101906. */
  101907. canDirectLoad?: (data: string) => boolean;
  101908. /**
  101909. * The callback that allows custom handling of the root url based on the response url.
  101910. */
  101911. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101912. /**
  101913. * Load into an asset container.
  101914. * @param scene The scene to load into
  101915. * @param data The data to import
  101916. * @param rootUrl The root url for scene and resources
  101917. * @param onProgress The callback when the load progresses
  101918. * @param fileName Defines the name of the file to load
  101919. * @returns The loaded asset container
  101920. */
  101921. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101922. }
  101923. /**
  101924. * Class used to load scene from various file formats using registered plugins
  101925. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101926. */
  101927. export class SceneLoader {
  101928. /**
  101929. * No logging while loading
  101930. */
  101931. static readonly NO_LOGGING: number;
  101932. /**
  101933. * Minimal logging while loading
  101934. */
  101935. static readonly MINIMAL_LOGGING: number;
  101936. /**
  101937. * Summary logging while loading
  101938. */
  101939. static readonly SUMMARY_LOGGING: number;
  101940. /**
  101941. * Detailled logging while loading
  101942. */
  101943. static readonly DETAILED_LOGGING: number;
  101944. /**
  101945. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101946. */
  101947. static ForceFullSceneLoadingForIncremental: boolean;
  101948. /**
  101949. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101950. */
  101951. static ShowLoadingScreen: boolean;
  101952. /**
  101953. * Defines the current logging level (while loading the scene)
  101954. * @ignorenaming
  101955. */
  101956. static loggingLevel: number;
  101957. /**
  101958. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101959. */
  101960. static CleanBoneMatrixWeights: boolean;
  101961. /**
  101962. * Event raised when a plugin is used to load a scene
  101963. */
  101964. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101965. private static _registeredPlugins;
  101966. private static _getDefaultPlugin;
  101967. private static _getPluginForExtension;
  101968. private static _getPluginForDirectLoad;
  101969. private static _getPluginForFilename;
  101970. private static _getDirectLoad;
  101971. private static _loadData;
  101972. private static _getFileInfo;
  101973. /**
  101974. * Gets a plugin that can load the given extension
  101975. * @param extension defines the extension to load
  101976. * @returns a plugin or null if none works
  101977. */
  101978. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101979. /**
  101980. * Gets a boolean indicating that the given extension can be loaded
  101981. * @param extension defines the extension to load
  101982. * @returns true if the extension is supported
  101983. */
  101984. static IsPluginForExtensionAvailable(extension: string): boolean;
  101985. /**
  101986. * Adds a new plugin to the list of registered plugins
  101987. * @param plugin defines the plugin to add
  101988. */
  101989. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101990. /**
  101991. * Import meshes into a scene
  101992. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101993. * @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)
  101994. * @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)
  101995. * @param scene the instance of BABYLON.Scene to append to
  101996. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101997. * @param onProgress a callback with a progress event for each file being loaded
  101998. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101999. * @param pluginExtension the extension used to determine the plugin
  102000. * @returns The loaded plugin
  102001. */
  102002. 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>;
  102003. /**
  102004. * Import meshes into a scene
  102005. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102006. * @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)
  102007. * @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)
  102008. * @param scene the instance of BABYLON.Scene to append to
  102009. * @param onProgress a callback with a progress event for each file being loaded
  102010. * @param pluginExtension the extension used to determine the plugin
  102011. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  102012. */
  102013. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  102014. meshes: AbstractMesh[];
  102015. particleSystems: IParticleSystem[];
  102016. skeletons: Skeleton[];
  102017. animationGroups: AnimationGroup[];
  102018. }>;
  102019. /**
  102020. * Load a scene
  102021. * @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)
  102022. * @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)
  102023. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102024. * @param onSuccess a callback with the scene when import succeeds
  102025. * @param onProgress a callback with a progress event for each file being loaded
  102026. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102027. * @param pluginExtension the extension used to determine the plugin
  102028. * @returns The loaded plugin
  102029. */
  102030. 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>;
  102031. /**
  102032. * Load a scene
  102033. * @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)
  102034. * @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)
  102035. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102036. * @param onProgress a callback with a progress event for each file being loaded
  102037. * @param pluginExtension the extension used to determine the plugin
  102038. * @returns The loaded scene
  102039. */
  102040. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102041. /**
  102042. * Append a scene
  102043. * @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)
  102044. * @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)
  102045. * @param scene is the instance of BABYLON.Scene to append to
  102046. * @param onSuccess a callback with the scene when import succeeds
  102047. * @param onProgress a callback with a progress event for each file being loaded
  102048. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102049. * @param pluginExtension the extension used to determine the plugin
  102050. * @returns The loaded plugin
  102051. */
  102052. 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>;
  102053. /**
  102054. * Append a scene
  102055. * @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)
  102056. * @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)
  102057. * @param scene is the instance of BABYLON.Scene to append to
  102058. * @param onProgress a callback with a progress event for each file being loaded
  102059. * @param pluginExtension the extension used to determine the plugin
  102060. * @returns The given scene
  102061. */
  102062. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102063. /**
  102064. * Load a scene into an asset container
  102065. * @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)
  102066. * @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)
  102067. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102068. * @param onSuccess a callback with the scene when import succeeds
  102069. * @param onProgress a callback with a progress event for each file being loaded
  102070. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102071. * @param pluginExtension the extension used to determine the plugin
  102072. * @returns The loaded plugin
  102073. */
  102074. 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>;
  102075. /**
  102076. * Load a scene into an asset container
  102077. * @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)
  102078. * @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)
  102079. * @param scene is the instance of Scene to append to
  102080. * @param onProgress a callback with a progress event for each file being loaded
  102081. * @param pluginExtension the extension used to determine the plugin
  102082. * @returns The loaded asset container
  102083. */
  102084. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102085. }
  102086. }
  102087. declare module BABYLON {
  102088. /**
  102089. * Google Daydream controller
  102090. */
  102091. export class DaydreamController extends WebVRController {
  102092. /**
  102093. * Base Url for the controller model.
  102094. */
  102095. static MODEL_BASE_URL: string;
  102096. /**
  102097. * File name for the controller model.
  102098. */
  102099. static MODEL_FILENAME: string;
  102100. /**
  102101. * Gamepad Id prefix used to identify Daydream Controller.
  102102. */
  102103. static readonly GAMEPAD_ID_PREFIX: string;
  102104. /**
  102105. * Creates a new DaydreamController from a gamepad
  102106. * @param vrGamepad the gamepad that the controller should be created from
  102107. */
  102108. constructor(vrGamepad: any);
  102109. /**
  102110. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102111. * @param scene scene in which to add meshes
  102112. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102113. */
  102114. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102115. /**
  102116. * Called once for each button that changed state since the last frame
  102117. * @param buttonIdx Which button index changed
  102118. * @param state New state of the button
  102119. * @param changes Which properties on the state changed since last frame
  102120. */
  102121. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102122. }
  102123. }
  102124. declare module BABYLON {
  102125. /**
  102126. * Gear VR Controller
  102127. */
  102128. export class GearVRController extends WebVRController {
  102129. /**
  102130. * Base Url for the controller model.
  102131. */
  102132. static MODEL_BASE_URL: string;
  102133. /**
  102134. * File name for the controller model.
  102135. */
  102136. static MODEL_FILENAME: string;
  102137. /**
  102138. * Gamepad Id prefix used to identify this controller.
  102139. */
  102140. static readonly GAMEPAD_ID_PREFIX: string;
  102141. private readonly _buttonIndexToObservableNameMap;
  102142. /**
  102143. * Creates a new GearVRController from a gamepad
  102144. * @param vrGamepad the gamepad that the controller should be created from
  102145. */
  102146. constructor(vrGamepad: any);
  102147. /**
  102148. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102149. * @param scene scene in which to add meshes
  102150. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102151. */
  102152. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102153. /**
  102154. * Called once for each button that changed state since the last frame
  102155. * @param buttonIdx Which button index changed
  102156. * @param state New state of the button
  102157. * @param changes Which properties on the state changed since last frame
  102158. */
  102159. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102160. }
  102161. }
  102162. declare module BABYLON {
  102163. /**
  102164. * Generic Controller
  102165. */
  102166. export class GenericController extends WebVRController {
  102167. /**
  102168. * Base Url for the controller model.
  102169. */
  102170. static readonly MODEL_BASE_URL: string;
  102171. /**
  102172. * File name for the controller model.
  102173. */
  102174. static readonly MODEL_FILENAME: string;
  102175. /**
  102176. * Creates a new GenericController from a gamepad
  102177. * @param vrGamepad the gamepad that the controller should be created from
  102178. */
  102179. constructor(vrGamepad: any);
  102180. /**
  102181. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102182. * @param scene scene in which to add meshes
  102183. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102184. */
  102185. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102186. /**
  102187. * Called once for each button that changed state since the last frame
  102188. * @param buttonIdx Which button index changed
  102189. * @param state New state of the button
  102190. * @param changes Which properties on the state changed since last frame
  102191. */
  102192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102193. }
  102194. }
  102195. declare module BABYLON {
  102196. /**
  102197. * Oculus Touch Controller
  102198. */
  102199. export class OculusTouchController extends WebVRController {
  102200. /**
  102201. * Base Url for the controller model.
  102202. */
  102203. static MODEL_BASE_URL: string;
  102204. /**
  102205. * File name for the left controller model.
  102206. */
  102207. static MODEL_LEFT_FILENAME: string;
  102208. /**
  102209. * File name for the right controller model.
  102210. */
  102211. static MODEL_RIGHT_FILENAME: string;
  102212. /**
  102213. * Fired when the secondary trigger on this controller is modified
  102214. */
  102215. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102216. /**
  102217. * Fired when the thumb rest on this controller is modified
  102218. */
  102219. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102220. /**
  102221. * Creates a new OculusTouchController from a gamepad
  102222. * @param vrGamepad the gamepad that the controller should be created from
  102223. */
  102224. constructor(vrGamepad: any);
  102225. /**
  102226. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102227. * @param scene scene in which to add meshes
  102228. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102229. */
  102230. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102231. /**
  102232. * Fired when the A button on this controller is modified
  102233. */
  102234. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102235. /**
  102236. * Fired when the B button on this controller is modified
  102237. */
  102238. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102239. /**
  102240. * Fired when the X button on this controller is modified
  102241. */
  102242. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102243. /**
  102244. * Fired when the Y button on this controller is modified
  102245. */
  102246. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102247. /**
  102248. * Called once for each button that changed state since the last frame
  102249. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102250. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102251. * 2) secondary trigger (same)
  102252. * 3) A (right) X (left), touch, pressed = value
  102253. * 4) B / Y
  102254. * 5) thumb rest
  102255. * @param buttonIdx Which button index changed
  102256. * @param state New state of the button
  102257. * @param changes Which properties on the state changed since last frame
  102258. */
  102259. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102260. }
  102261. }
  102262. declare module BABYLON {
  102263. /**
  102264. * Vive Controller
  102265. */
  102266. export class ViveController extends WebVRController {
  102267. /**
  102268. * Base Url for the controller model.
  102269. */
  102270. static MODEL_BASE_URL: string;
  102271. /**
  102272. * File name for the controller model.
  102273. */
  102274. static MODEL_FILENAME: string;
  102275. /**
  102276. * Creates a new ViveController from a gamepad
  102277. * @param vrGamepad the gamepad that the controller should be created from
  102278. */
  102279. constructor(vrGamepad: any);
  102280. /**
  102281. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102282. * @param scene scene in which to add meshes
  102283. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102284. */
  102285. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102286. /**
  102287. * Fired when the left button on this controller is modified
  102288. */
  102289. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102290. /**
  102291. * Fired when the right button on this controller is modified
  102292. */
  102293. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102294. /**
  102295. * Fired when the menu button on this controller is modified
  102296. */
  102297. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102298. /**
  102299. * Called once for each button that changed state since the last frame
  102300. * Vive mapping:
  102301. * 0: touchpad
  102302. * 1: trigger
  102303. * 2: left AND right buttons
  102304. * 3: menu button
  102305. * @param buttonIdx Which button index changed
  102306. * @param state New state of the button
  102307. * @param changes Which properties on the state changed since last frame
  102308. */
  102309. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102310. }
  102311. }
  102312. declare module BABYLON {
  102313. /**
  102314. * Defines the WindowsMotionController object that the state of the windows motion controller
  102315. */
  102316. export class WindowsMotionController extends WebVRController {
  102317. /**
  102318. * The base url used to load the left and right controller models
  102319. */
  102320. static MODEL_BASE_URL: string;
  102321. /**
  102322. * The name of the left controller model file
  102323. */
  102324. static MODEL_LEFT_FILENAME: string;
  102325. /**
  102326. * The name of the right controller model file
  102327. */
  102328. static MODEL_RIGHT_FILENAME: string;
  102329. /**
  102330. * The controller name prefix for this controller type
  102331. */
  102332. static readonly GAMEPAD_ID_PREFIX: string;
  102333. /**
  102334. * The controller id pattern for this controller type
  102335. */
  102336. private static readonly GAMEPAD_ID_PATTERN;
  102337. private _loadedMeshInfo;
  102338. private readonly _mapping;
  102339. /**
  102340. * Fired when the trackpad on this controller is clicked
  102341. */
  102342. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102343. /**
  102344. * Fired when the trackpad on this controller is modified
  102345. */
  102346. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102347. /**
  102348. * The current x and y values of this controller's trackpad
  102349. */
  102350. trackpad: StickValues;
  102351. /**
  102352. * Creates a new WindowsMotionController from a gamepad
  102353. * @param vrGamepad the gamepad that the controller should be created from
  102354. */
  102355. constructor(vrGamepad: any);
  102356. /**
  102357. * Fired when the trigger on this controller is modified
  102358. */
  102359. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102360. /**
  102361. * Fired when the menu button on this controller is modified
  102362. */
  102363. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102364. /**
  102365. * Fired when the grip button on this controller is modified
  102366. */
  102367. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102368. /**
  102369. * Fired when the thumbstick button on this controller is modified
  102370. */
  102371. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102372. /**
  102373. * Fired when the touchpad button on this controller is modified
  102374. */
  102375. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102376. /**
  102377. * Fired when the touchpad values on this controller are modified
  102378. */
  102379. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102380. private _updateTrackpad;
  102381. /**
  102382. * Called once per frame by the engine.
  102383. */
  102384. update(): void;
  102385. /**
  102386. * Called once for each button that changed state since the last frame
  102387. * @param buttonIdx Which button index changed
  102388. * @param state New state of the button
  102389. * @param changes Which properties on the state changed since last frame
  102390. */
  102391. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102392. /**
  102393. * Moves the buttons on the controller mesh based on their current state
  102394. * @param buttonName the name of the button to move
  102395. * @param buttonValue the value of the button which determines the buttons new position
  102396. */
  102397. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102398. /**
  102399. * Moves the axis on the controller mesh based on its current state
  102400. * @param axis the index of the axis
  102401. * @param axisValue the value of the axis which determines the meshes new position
  102402. * @hidden
  102403. */
  102404. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102405. /**
  102406. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102407. * @param scene scene in which to add meshes
  102408. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102409. */
  102410. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102411. /**
  102412. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102413. * can be transformed by button presses and axes values, based on this._mapping.
  102414. *
  102415. * @param scene scene in which the meshes exist
  102416. * @param meshes list of meshes that make up the controller model to process
  102417. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102418. */
  102419. private processModel;
  102420. private createMeshInfo;
  102421. /**
  102422. * Gets the ray of the controller in the direction the controller is pointing
  102423. * @param length the length the resulting ray should be
  102424. * @returns a ray in the direction the controller is pointing
  102425. */
  102426. getForwardRay(length?: number): Ray;
  102427. /**
  102428. * Disposes of the controller
  102429. */
  102430. dispose(): void;
  102431. }
  102432. }
  102433. declare module BABYLON {
  102434. /**
  102435. * Single axis scale gizmo
  102436. */
  102437. export class AxisScaleGizmo extends Gizmo {
  102438. private _coloredMaterial;
  102439. /**
  102440. * Drag behavior responsible for the gizmos dragging interactions
  102441. */
  102442. dragBehavior: PointerDragBehavior;
  102443. private _pointerObserver;
  102444. /**
  102445. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102446. */
  102447. snapDistance: number;
  102448. /**
  102449. * Event that fires each time the gizmo snaps to a new location.
  102450. * * snapDistance is the the change in distance
  102451. */
  102452. onSnapObservable: Observable<{
  102453. snapDistance: number;
  102454. }>;
  102455. /**
  102456. * If the scaling operation should be done on all axis (default: false)
  102457. */
  102458. uniformScaling: boolean;
  102459. /**
  102460. * Creates an AxisScaleGizmo
  102461. * @param gizmoLayer The utility layer the gizmo will be added to
  102462. * @param dragAxis The axis which the gizmo will be able to scale on
  102463. * @param color The color of the gizmo
  102464. */
  102465. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102466. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102467. /**
  102468. * Disposes of the gizmo
  102469. */
  102470. dispose(): void;
  102471. /**
  102472. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102473. * @param mesh The mesh to replace the default mesh of the gizmo
  102474. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102475. */
  102476. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102477. }
  102478. }
  102479. declare module BABYLON {
  102480. /**
  102481. * Bounding box gizmo
  102482. */
  102483. export class BoundingBoxGizmo extends Gizmo {
  102484. private _lineBoundingBox;
  102485. private _rotateSpheresParent;
  102486. private _scaleBoxesParent;
  102487. private _boundingDimensions;
  102488. private _renderObserver;
  102489. private _pointerObserver;
  102490. private _scaleDragSpeed;
  102491. private _tmpQuaternion;
  102492. private _tmpVector;
  102493. private _tmpRotationMatrix;
  102494. /**
  102495. * 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)
  102496. */
  102497. ignoreChildren: boolean;
  102498. /**
  102499. * 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)
  102500. */
  102501. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102502. /**
  102503. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102504. */
  102505. rotationSphereSize: number;
  102506. /**
  102507. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102508. */
  102509. scaleBoxSize: number;
  102510. /**
  102511. * 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)
  102512. */
  102513. fixedDragMeshScreenSize: boolean;
  102514. /**
  102515. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102516. */
  102517. fixedDragMeshScreenSizeDistanceFactor: number;
  102518. /**
  102519. * Fired when a rotation sphere or scale box is dragged
  102520. */
  102521. onDragStartObservable: Observable<{}>;
  102522. /**
  102523. * Fired when a scale box is dragged
  102524. */
  102525. onScaleBoxDragObservable: Observable<{}>;
  102526. /**
  102527. * Fired when a scale box drag is ended
  102528. */
  102529. onScaleBoxDragEndObservable: Observable<{}>;
  102530. /**
  102531. * Fired when a rotation sphere is dragged
  102532. */
  102533. onRotationSphereDragObservable: Observable<{}>;
  102534. /**
  102535. * Fired when a rotation sphere drag is ended
  102536. */
  102537. onRotationSphereDragEndObservable: Observable<{}>;
  102538. /**
  102539. * 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)
  102540. */
  102541. scalePivot: Nullable<Vector3>;
  102542. /**
  102543. * Mesh used as a pivot to rotate the attached mesh
  102544. */
  102545. private _anchorMesh;
  102546. private _existingMeshScale;
  102547. private _dragMesh;
  102548. private pointerDragBehavior;
  102549. private coloredMaterial;
  102550. private hoverColoredMaterial;
  102551. /**
  102552. * Sets the color of the bounding box gizmo
  102553. * @param color the color to set
  102554. */
  102555. setColor(color: Color3): void;
  102556. /**
  102557. * Creates an BoundingBoxGizmo
  102558. * @param gizmoLayer The utility layer the gizmo will be added to
  102559. * @param color The color of the gizmo
  102560. */
  102561. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102562. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102563. private _selectNode;
  102564. /**
  102565. * Updates the bounding box information for the Gizmo
  102566. */
  102567. updateBoundingBox(): void;
  102568. private _updateRotationSpheres;
  102569. private _updateScaleBoxes;
  102570. /**
  102571. * Enables rotation on the specified axis and disables rotation on the others
  102572. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102573. */
  102574. setEnabledRotationAxis(axis: string): void;
  102575. /**
  102576. * Enables/disables scaling
  102577. * @param enable if scaling should be enabled
  102578. */
  102579. setEnabledScaling(enable: boolean): void;
  102580. private _updateDummy;
  102581. /**
  102582. * Enables a pointer drag behavior on the bounding box of the gizmo
  102583. */
  102584. enableDragBehavior(): void;
  102585. /**
  102586. * Disposes of the gizmo
  102587. */
  102588. dispose(): void;
  102589. /**
  102590. * 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)
  102591. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102592. * @returns the bounding box mesh with the passed in mesh as a child
  102593. */
  102594. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102595. /**
  102596. * CustomMeshes are not supported by this gizmo
  102597. * @param mesh The mesh to replace the default mesh of the gizmo
  102598. */
  102599. setCustomMesh(mesh: Mesh): void;
  102600. }
  102601. }
  102602. declare module BABYLON {
  102603. /**
  102604. * Single plane rotation gizmo
  102605. */
  102606. export class PlaneRotationGizmo extends Gizmo {
  102607. /**
  102608. * Drag behavior responsible for the gizmos dragging interactions
  102609. */
  102610. dragBehavior: PointerDragBehavior;
  102611. private _pointerObserver;
  102612. /**
  102613. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102614. */
  102615. snapDistance: number;
  102616. /**
  102617. * Event that fires each time the gizmo snaps to a new location.
  102618. * * snapDistance is the the change in distance
  102619. */
  102620. onSnapObservable: Observable<{
  102621. snapDistance: number;
  102622. }>;
  102623. /**
  102624. * Creates a PlaneRotationGizmo
  102625. * @param gizmoLayer The utility layer the gizmo will be added to
  102626. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102627. * @param color The color of the gizmo
  102628. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102629. */
  102630. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102631. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102632. /**
  102633. * Disposes of the gizmo
  102634. */
  102635. dispose(): void;
  102636. }
  102637. }
  102638. declare module BABYLON {
  102639. /**
  102640. * Gizmo that enables rotating a mesh along 3 axis
  102641. */
  102642. export class RotationGizmo extends Gizmo {
  102643. /**
  102644. * Internal gizmo used for interactions on the x axis
  102645. */
  102646. xGizmo: PlaneRotationGizmo;
  102647. /**
  102648. * Internal gizmo used for interactions on the y axis
  102649. */
  102650. yGizmo: PlaneRotationGizmo;
  102651. /**
  102652. * Internal gizmo used for interactions on the z axis
  102653. */
  102654. zGizmo: PlaneRotationGizmo;
  102655. /** Fires an event when any of it's sub gizmos are dragged */
  102656. onDragStartObservable: Observable<{}>;
  102657. /** Fires an event when any of it's sub gizmos are released from dragging */
  102658. onDragEndObservable: Observable<{}>;
  102659. attachedMesh: Nullable<AbstractMesh>;
  102660. /**
  102661. * Creates a RotationGizmo
  102662. * @param gizmoLayer The utility layer the gizmo will be added to
  102663. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102664. */
  102665. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102666. updateGizmoRotationToMatchAttachedMesh: boolean;
  102667. /**
  102668. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102669. */
  102670. snapDistance: number;
  102671. /**
  102672. * Ratio for the scale of the gizmo (Default: 1)
  102673. */
  102674. scaleRatio: number;
  102675. /**
  102676. * Disposes of the gizmo
  102677. */
  102678. dispose(): void;
  102679. /**
  102680. * CustomMeshes are not supported by this gizmo
  102681. * @param mesh The mesh to replace the default mesh of the gizmo
  102682. */
  102683. setCustomMesh(mesh: Mesh): void;
  102684. }
  102685. }
  102686. declare module BABYLON {
  102687. /**
  102688. * Gizmo that enables dragging a mesh along 3 axis
  102689. */
  102690. export class PositionGizmo extends Gizmo {
  102691. /**
  102692. * Internal gizmo used for interactions on the x axis
  102693. */
  102694. xGizmo: AxisDragGizmo;
  102695. /**
  102696. * Internal gizmo used for interactions on the y axis
  102697. */
  102698. yGizmo: AxisDragGizmo;
  102699. /**
  102700. * Internal gizmo used for interactions on the z axis
  102701. */
  102702. zGizmo: AxisDragGizmo;
  102703. /** Fires an event when any of it's sub gizmos are dragged */
  102704. onDragStartObservable: Observable<{}>;
  102705. /** Fires an event when any of it's sub gizmos are released from dragging */
  102706. onDragEndObservable: Observable<{}>;
  102707. attachedMesh: Nullable<AbstractMesh>;
  102708. /**
  102709. * Creates a PositionGizmo
  102710. * @param gizmoLayer The utility layer the gizmo will be added to
  102711. */
  102712. constructor(gizmoLayer?: UtilityLayerRenderer);
  102713. updateGizmoRotationToMatchAttachedMesh: boolean;
  102714. /**
  102715. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102716. */
  102717. snapDistance: number;
  102718. /**
  102719. * Ratio for the scale of the gizmo (Default: 1)
  102720. */
  102721. scaleRatio: number;
  102722. /**
  102723. * Disposes of the gizmo
  102724. */
  102725. dispose(): void;
  102726. /**
  102727. * CustomMeshes are not supported by this gizmo
  102728. * @param mesh The mesh to replace the default mesh of the gizmo
  102729. */
  102730. setCustomMesh(mesh: Mesh): void;
  102731. }
  102732. }
  102733. declare module BABYLON {
  102734. /**
  102735. * Class containing static functions to help procedurally build meshes
  102736. */
  102737. export class PolyhedronBuilder {
  102738. /**
  102739. * Creates a polyhedron mesh
  102740. * * 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
  102741. * * The parameter `size` (positive float, default 1) sets the polygon size
  102742. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102743. * * 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`
  102744. * * 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
  102745. * * 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)`)
  102746. * * 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
  102747. * * 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
  102748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102751. * @param name defines the name of the mesh
  102752. * @param options defines the options used to create the mesh
  102753. * @param scene defines the hosting scene
  102754. * @returns the polyhedron mesh
  102755. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102756. */
  102757. static CreatePolyhedron(name: string, options: {
  102758. type?: number;
  102759. size?: number;
  102760. sizeX?: number;
  102761. sizeY?: number;
  102762. sizeZ?: number;
  102763. custom?: any;
  102764. faceUV?: Vector4[];
  102765. faceColors?: Color4[];
  102766. flat?: boolean;
  102767. updatable?: boolean;
  102768. sideOrientation?: number;
  102769. frontUVs?: Vector4;
  102770. backUVs?: Vector4;
  102771. }, scene?: Nullable<Scene>): Mesh;
  102772. }
  102773. }
  102774. declare module BABYLON {
  102775. /**
  102776. * Gizmo that enables scaling a mesh along 3 axis
  102777. */
  102778. export class ScaleGizmo extends Gizmo {
  102779. /**
  102780. * Internal gizmo used for interactions on the x axis
  102781. */
  102782. xGizmo: AxisScaleGizmo;
  102783. /**
  102784. * Internal gizmo used for interactions on the y axis
  102785. */
  102786. yGizmo: AxisScaleGizmo;
  102787. /**
  102788. * Internal gizmo used for interactions on the z axis
  102789. */
  102790. zGizmo: AxisScaleGizmo;
  102791. /**
  102792. * Internal gizmo used to scale all axis equally
  102793. */
  102794. uniformScaleGizmo: AxisScaleGizmo;
  102795. /** Fires an event when any of it's sub gizmos are dragged */
  102796. onDragStartObservable: Observable<{}>;
  102797. /** Fires an event when any of it's sub gizmos are released from dragging */
  102798. onDragEndObservable: Observable<{}>;
  102799. attachedMesh: Nullable<AbstractMesh>;
  102800. /**
  102801. * Creates a ScaleGizmo
  102802. * @param gizmoLayer The utility layer the gizmo will be added to
  102803. */
  102804. constructor(gizmoLayer?: UtilityLayerRenderer);
  102805. updateGizmoRotationToMatchAttachedMesh: boolean;
  102806. /**
  102807. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102808. */
  102809. snapDistance: number;
  102810. /**
  102811. * Ratio for the scale of the gizmo (Default: 1)
  102812. */
  102813. scaleRatio: number;
  102814. /**
  102815. * Disposes of the gizmo
  102816. */
  102817. dispose(): void;
  102818. }
  102819. }
  102820. declare module BABYLON {
  102821. /**
  102822. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102823. */
  102824. export class GizmoManager implements IDisposable {
  102825. private scene;
  102826. /**
  102827. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102828. */
  102829. gizmos: {
  102830. positionGizmo: Nullable<PositionGizmo>;
  102831. rotationGizmo: Nullable<RotationGizmo>;
  102832. scaleGizmo: Nullable<ScaleGizmo>;
  102833. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102834. };
  102835. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102836. clearGizmoOnEmptyPointerEvent: boolean;
  102837. /** Fires an event when the manager is attached to a mesh */
  102838. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102839. private _gizmosEnabled;
  102840. private _pointerObserver;
  102841. private _attachedMesh;
  102842. private _boundingBoxColor;
  102843. private _defaultUtilityLayer;
  102844. private _defaultKeepDepthUtilityLayer;
  102845. /**
  102846. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102847. */
  102848. boundingBoxDragBehavior: SixDofDragBehavior;
  102849. /**
  102850. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102851. */
  102852. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102853. /**
  102854. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102855. */
  102856. usePointerToAttachGizmos: boolean;
  102857. /**
  102858. * Instatiates a gizmo manager
  102859. * @param scene the scene to overlay the gizmos on top of
  102860. */
  102861. constructor(scene: Scene);
  102862. /**
  102863. * Attaches a set of gizmos to the specified mesh
  102864. * @param mesh The mesh the gizmo's should be attached to
  102865. */
  102866. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102867. /**
  102868. * If the position gizmo is enabled
  102869. */
  102870. positionGizmoEnabled: boolean;
  102871. /**
  102872. * If the rotation gizmo is enabled
  102873. */
  102874. rotationGizmoEnabled: boolean;
  102875. /**
  102876. * If the scale gizmo is enabled
  102877. */
  102878. scaleGizmoEnabled: boolean;
  102879. /**
  102880. * If the boundingBox gizmo is enabled
  102881. */
  102882. boundingBoxGizmoEnabled: boolean;
  102883. /**
  102884. * Disposes of the gizmo manager
  102885. */
  102886. dispose(): void;
  102887. }
  102888. }
  102889. declare module BABYLON {
  102890. /**
  102891. * A directional light is defined by a direction (what a surprise!).
  102892. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102893. * 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.
  102894. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102895. */
  102896. export class DirectionalLight extends ShadowLight {
  102897. private _shadowFrustumSize;
  102898. /**
  102899. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102900. */
  102901. /**
  102902. * Specifies a fix frustum size for the shadow generation.
  102903. */
  102904. shadowFrustumSize: number;
  102905. private _shadowOrthoScale;
  102906. /**
  102907. * Gets the shadow projection scale against the optimal computed one.
  102908. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102909. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102910. */
  102911. /**
  102912. * Sets the shadow projection scale against the optimal computed one.
  102913. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102914. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102915. */
  102916. shadowOrthoScale: number;
  102917. /**
  102918. * Automatically compute the projection matrix to best fit (including all the casters)
  102919. * on each frame.
  102920. */
  102921. autoUpdateExtends: boolean;
  102922. private _orthoLeft;
  102923. private _orthoRight;
  102924. private _orthoTop;
  102925. private _orthoBottom;
  102926. /**
  102927. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102928. * The directional light is emitted from everywhere in the given direction.
  102929. * It can cast shadows.
  102930. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102931. * @param name The friendly name of the light
  102932. * @param direction The direction of the light
  102933. * @param scene The scene the light belongs to
  102934. */
  102935. constructor(name: string, direction: Vector3, scene: Scene);
  102936. /**
  102937. * Returns the string "DirectionalLight".
  102938. * @return The class name
  102939. */
  102940. getClassName(): string;
  102941. /**
  102942. * Returns the integer 1.
  102943. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102944. */
  102945. getTypeID(): number;
  102946. /**
  102947. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102948. * Returns the DirectionalLight Shadow projection matrix.
  102949. */
  102950. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102951. /**
  102952. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102953. * Returns the DirectionalLight Shadow projection matrix.
  102954. */
  102955. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102956. /**
  102957. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102958. * Returns the DirectionalLight Shadow projection matrix.
  102959. */
  102960. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102961. protected _buildUniformLayout(): void;
  102962. /**
  102963. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102964. * @param effect The effect to update
  102965. * @param lightIndex The index of the light in the effect to update
  102966. * @returns The directional light
  102967. */
  102968. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102969. /**
  102970. * Gets the minZ used for shadow according to both the scene and the light.
  102971. *
  102972. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102973. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102974. * @param activeCamera The camera we are returning the min for
  102975. * @returns the depth min z
  102976. */
  102977. getDepthMinZ(activeCamera: Camera): number;
  102978. /**
  102979. * Gets the maxZ used for shadow according to both the scene and the light.
  102980. *
  102981. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102982. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102983. * @param activeCamera The camera we are returning the max for
  102984. * @returns the depth max z
  102985. */
  102986. getDepthMaxZ(activeCamera: Camera): number;
  102987. /**
  102988. * Prepares the list of defines specific to the light type.
  102989. * @param defines the list of defines
  102990. * @param lightIndex defines the index of the light for the effect
  102991. */
  102992. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102993. }
  102994. }
  102995. declare module BABYLON {
  102996. /**
  102997. * Class containing static functions to help procedurally build meshes
  102998. */
  102999. export class HemisphereBuilder {
  103000. /**
  103001. * Creates a hemisphere mesh
  103002. * @param name defines the name of the mesh
  103003. * @param options defines the options used to create the mesh
  103004. * @param scene defines the hosting scene
  103005. * @returns the hemisphere mesh
  103006. */
  103007. static CreateHemisphere(name: string, options: {
  103008. segments?: number;
  103009. diameter?: number;
  103010. sideOrientation?: number;
  103011. }, scene: any): Mesh;
  103012. }
  103013. }
  103014. declare module BABYLON {
  103015. /**
  103016. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103017. * These values define a cone of light starting from the position, emitting toward the direction.
  103018. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103019. * and the exponent defines the speed of the decay of the light with distance (reach).
  103020. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103021. */
  103022. export class SpotLight extends ShadowLight {
  103023. private _angle;
  103024. private _innerAngle;
  103025. private _cosHalfAngle;
  103026. private _lightAngleScale;
  103027. private _lightAngleOffset;
  103028. /**
  103029. * Gets the cone angle of the spot light in Radians.
  103030. */
  103031. /**
  103032. * Sets the cone angle of the spot light in Radians.
  103033. */
  103034. angle: number;
  103035. /**
  103036. * Only used in gltf falloff mode, this defines the angle where
  103037. * the directional falloff will start before cutting at angle which could be seen
  103038. * as outer angle.
  103039. */
  103040. /**
  103041. * Only used in gltf falloff mode, this defines the angle where
  103042. * the directional falloff will start before cutting at angle which could be seen
  103043. * as outer angle.
  103044. */
  103045. innerAngle: number;
  103046. private _shadowAngleScale;
  103047. /**
  103048. * Allows scaling the angle of the light for shadow generation only.
  103049. */
  103050. /**
  103051. * Allows scaling the angle of the light for shadow generation only.
  103052. */
  103053. shadowAngleScale: number;
  103054. /**
  103055. * The light decay speed with the distance from the emission spot.
  103056. */
  103057. exponent: number;
  103058. private _projectionTextureMatrix;
  103059. /**
  103060. * Allows reading the projecton texture
  103061. */
  103062. readonly projectionTextureMatrix: Matrix;
  103063. protected _projectionTextureLightNear: number;
  103064. /**
  103065. * Gets the near clip of the Spotlight for texture projection.
  103066. */
  103067. /**
  103068. * Sets the near clip of the Spotlight for texture projection.
  103069. */
  103070. projectionTextureLightNear: number;
  103071. protected _projectionTextureLightFar: number;
  103072. /**
  103073. * Gets the far clip of the Spotlight for texture projection.
  103074. */
  103075. /**
  103076. * Sets the far clip of the Spotlight for texture projection.
  103077. */
  103078. projectionTextureLightFar: number;
  103079. protected _projectionTextureUpDirection: Vector3;
  103080. /**
  103081. * Gets the Up vector of the Spotlight for texture projection.
  103082. */
  103083. /**
  103084. * Sets the Up vector of the Spotlight for texture projection.
  103085. */
  103086. projectionTextureUpDirection: Vector3;
  103087. private _projectionTexture;
  103088. /**
  103089. * Gets the projection texture of the light.
  103090. */
  103091. /**
  103092. * Sets the projection texture of the light.
  103093. */
  103094. projectionTexture: Nullable<BaseTexture>;
  103095. private _projectionTextureViewLightDirty;
  103096. private _projectionTextureProjectionLightDirty;
  103097. private _projectionTextureDirty;
  103098. private _projectionTextureViewTargetVector;
  103099. private _projectionTextureViewLightMatrix;
  103100. private _projectionTextureProjectionLightMatrix;
  103101. private _projectionTextureScalingMatrix;
  103102. /**
  103103. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103104. * It can cast shadows.
  103105. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103106. * @param name The light friendly name
  103107. * @param position The position of the spot light in the scene
  103108. * @param direction The direction of the light in the scene
  103109. * @param angle The cone angle of the light in Radians
  103110. * @param exponent The light decay speed with the distance from the emission spot
  103111. * @param scene The scene the lights belongs to
  103112. */
  103113. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103114. /**
  103115. * Returns the string "SpotLight".
  103116. * @returns the class name
  103117. */
  103118. getClassName(): string;
  103119. /**
  103120. * Returns the integer 2.
  103121. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103122. */
  103123. getTypeID(): number;
  103124. /**
  103125. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103126. */
  103127. protected _setDirection(value: Vector3): void;
  103128. /**
  103129. * Overrides the position setter to recompute the projection texture view light Matrix.
  103130. */
  103131. protected _setPosition(value: Vector3): void;
  103132. /**
  103133. * 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.
  103134. * Returns the SpotLight.
  103135. */
  103136. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103137. protected _computeProjectionTextureViewLightMatrix(): void;
  103138. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103139. /**
  103140. * Main function for light texture projection matrix computing.
  103141. */
  103142. protected _computeProjectionTextureMatrix(): void;
  103143. protected _buildUniformLayout(): void;
  103144. private _computeAngleValues;
  103145. /**
  103146. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103147. * @param effect The effect to update
  103148. * @param lightIndex The index of the light in the effect to update
  103149. * @returns The spot light
  103150. */
  103151. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103152. /**
  103153. * Disposes the light and the associated resources.
  103154. */
  103155. dispose(): void;
  103156. /**
  103157. * Prepares the list of defines specific to the light type.
  103158. * @param defines the list of defines
  103159. * @param lightIndex defines the index of the light for the effect
  103160. */
  103161. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103162. }
  103163. }
  103164. declare module BABYLON {
  103165. /**
  103166. * Gizmo that enables viewing a light
  103167. */
  103168. export class LightGizmo extends Gizmo {
  103169. private _lightMesh;
  103170. private _material;
  103171. private cachedPosition;
  103172. private cachedForward;
  103173. /**
  103174. * Creates a LightGizmo
  103175. * @param gizmoLayer The utility layer the gizmo will be added to
  103176. */
  103177. constructor(gizmoLayer?: UtilityLayerRenderer);
  103178. private _light;
  103179. /**
  103180. * The light that the gizmo is attached to
  103181. */
  103182. light: Nullable<Light>;
  103183. /**
  103184. * @hidden
  103185. * Updates the gizmo to match the attached mesh's position/rotation
  103186. */
  103187. protected _update(): void;
  103188. private static _Scale;
  103189. /**
  103190. * Creates the lines for a light mesh
  103191. */
  103192. private static _createLightLines;
  103193. private static _CreateHemisphericLightMesh;
  103194. private static _CreatePointLightMesh;
  103195. private static _CreateSpotLightMesh;
  103196. private static _CreateDirectionalLightMesh;
  103197. }
  103198. }
  103199. declare module BABYLON {
  103200. /** @hidden */
  103201. export var backgroundFragmentDeclaration: {
  103202. name: string;
  103203. shader: string;
  103204. };
  103205. }
  103206. declare module BABYLON {
  103207. /** @hidden */
  103208. export var backgroundUboDeclaration: {
  103209. name: string;
  103210. shader: string;
  103211. };
  103212. }
  103213. declare module BABYLON {
  103214. /** @hidden */
  103215. export var backgroundPixelShader: {
  103216. name: string;
  103217. shader: string;
  103218. };
  103219. }
  103220. declare module BABYLON {
  103221. /** @hidden */
  103222. export var backgroundVertexDeclaration: {
  103223. name: string;
  103224. shader: string;
  103225. };
  103226. }
  103227. declare module BABYLON {
  103228. /** @hidden */
  103229. export var backgroundVertexShader: {
  103230. name: string;
  103231. shader: string;
  103232. };
  103233. }
  103234. declare module BABYLON {
  103235. /**
  103236. * Background material used to create an efficient environement around your scene.
  103237. */
  103238. export class BackgroundMaterial extends PushMaterial {
  103239. /**
  103240. * Standard reflectance value at parallel view angle.
  103241. */
  103242. static StandardReflectance0: number;
  103243. /**
  103244. * Standard reflectance value at grazing angle.
  103245. */
  103246. static StandardReflectance90: number;
  103247. protected _primaryColor: Color3;
  103248. /**
  103249. * Key light Color (multiply against the environement texture)
  103250. */
  103251. primaryColor: Color3;
  103252. protected __perceptualColor: Nullable<Color3>;
  103253. /**
  103254. * Experimental Internal Use Only.
  103255. *
  103256. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103257. * This acts as a helper to set the primary color to a more "human friendly" value.
  103258. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103259. * output color as close as possible from the chosen value.
  103260. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103261. * part of lighting setup.)
  103262. */
  103263. _perceptualColor: Nullable<Color3>;
  103264. protected _primaryColorShadowLevel: float;
  103265. /**
  103266. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103267. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103268. */
  103269. primaryColorShadowLevel: float;
  103270. protected _primaryColorHighlightLevel: float;
  103271. /**
  103272. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103273. * The primary color is used at the level chosen to define what the white area would look.
  103274. */
  103275. primaryColorHighlightLevel: float;
  103276. protected _reflectionTexture: Nullable<BaseTexture>;
  103277. /**
  103278. * Reflection Texture used in the material.
  103279. * Should be author in a specific way for the best result (refer to the documentation).
  103280. */
  103281. reflectionTexture: Nullable<BaseTexture>;
  103282. protected _reflectionBlur: float;
  103283. /**
  103284. * Reflection Texture level of blur.
  103285. *
  103286. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103287. * texture twice.
  103288. */
  103289. reflectionBlur: float;
  103290. protected _diffuseTexture: Nullable<BaseTexture>;
  103291. /**
  103292. * Diffuse Texture used in the material.
  103293. * Should be author in a specific way for the best result (refer to the documentation).
  103294. */
  103295. diffuseTexture: Nullable<BaseTexture>;
  103296. protected _shadowLights: Nullable<IShadowLight[]>;
  103297. /**
  103298. * Specify the list of lights casting shadow on the material.
  103299. * All scene shadow lights will be included if null.
  103300. */
  103301. shadowLights: Nullable<IShadowLight[]>;
  103302. protected _shadowLevel: float;
  103303. /**
  103304. * Helps adjusting the shadow to a softer level if required.
  103305. * 0 means black shadows and 1 means no shadows.
  103306. */
  103307. shadowLevel: float;
  103308. protected _sceneCenter: Vector3;
  103309. /**
  103310. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103311. * It is usually zero but might be interesting to modify according to your setup.
  103312. */
  103313. sceneCenter: Vector3;
  103314. protected _opacityFresnel: boolean;
  103315. /**
  103316. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103317. * This helps ensuring a nice transition when the camera goes under the ground.
  103318. */
  103319. opacityFresnel: boolean;
  103320. protected _reflectionFresnel: boolean;
  103321. /**
  103322. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103323. * This helps adding a mirror texture on the ground.
  103324. */
  103325. reflectionFresnel: boolean;
  103326. protected _reflectionFalloffDistance: number;
  103327. /**
  103328. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103329. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103330. */
  103331. reflectionFalloffDistance: number;
  103332. protected _reflectionAmount: number;
  103333. /**
  103334. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103335. */
  103336. reflectionAmount: number;
  103337. protected _reflectionReflectance0: number;
  103338. /**
  103339. * This specifies the weight of the reflection at grazing angle.
  103340. */
  103341. reflectionReflectance0: number;
  103342. protected _reflectionReflectance90: number;
  103343. /**
  103344. * This specifies the weight of the reflection at a perpendicular point of view.
  103345. */
  103346. reflectionReflectance90: number;
  103347. /**
  103348. * Sets the reflection reflectance fresnel values according to the default standard
  103349. * empirically know to work well :-)
  103350. */
  103351. reflectionStandardFresnelWeight: number;
  103352. protected _useRGBColor: boolean;
  103353. /**
  103354. * Helps to directly use the maps channels instead of their level.
  103355. */
  103356. useRGBColor: boolean;
  103357. protected _enableNoise: boolean;
  103358. /**
  103359. * This helps reducing the banding effect that could occur on the background.
  103360. */
  103361. enableNoise: boolean;
  103362. /**
  103363. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103364. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103365. * Recommended to be keep at 1.0 except for special cases.
  103366. */
  103367. fovMultiplier: number;
  103368. private _fovMultiplier;
  103369. /**
  103370. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103371. */
  103372. useEquirectangularFOV: boolean;
  103373. private _maxSimultaneousLights;
  103374. /**
  103375. * Number of Simultaneous lights allowed on the material.
  103376. */
  103377. maxSimultaneousLights: int;
  103378. /**
  103379. * Default configuration related to image processing available in the Background Material.
  103380. */
  103381. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103382. /**
  103383. * Keep track of the image processing observer to allow dispose and replace.
  103384. */
  103385. private _imageProcessingObserver;
  103386. /**
  103387. * Attaches a new image processing configuration to the PBR Material.
  103388. * @param configuration (if null the scene configuration will be use)
  103389. */
  103390. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103391. /**
  103392. * Gets the image processing configuration used either in this material.
  103393. */
  103394. /**
  103395. * Sets the Default image processing configuration used either in the this material.
  103396. *
  103397. * If sets to null, the scene one is in use.
  103398. */
  103399. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103400. /**
  103401. * Gets wether the color curves effect is enabled.
  103402. */
  103403. /**
  103404. * Sets wether the color curves effect is enabled.
  103405. */
  103406. cameraColorCurvesEnabled: boolean;
  103407. /**
  103408. * Gets wether the color grading effect is enabled.
  103409. */
  103410. /**
  103411. * Gets wether the color grading effect is enabled.
  103412. */
  103413. cameraColorGradingEnabled: boolean;
  103414. /**
  103415. * Gets wether tonemapping is enabled or not.
  103416. */
  103417. /**
  103418. * Sets wether tonemapping is enabled or not
  103419. */
  103420. cameraToneMappingEnabled: boolean;
  103421. /**
  103422. * The camera exposure used on this material.
  103423. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103424. * This corresponds to a photographic exposure.
  103425. */
  103426. /**
  103427. * The camera exposure used on this material.
  103428. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103429. * This corresponds to a photographic exposure.
  103430. */
  103431. cameraExposure: float;
  103432. /**
  103433. * Gets The camera contrast used on this material.
  103434. */
  103435. /**
  103436. * Sets The camera contrast used on this material.
  103437. */
  103438. cameraContrast: float;
  103439. /**
  103440. * Gets the Color Grading 2D Lookup Texture.
  103441. */
  103442. /**
  103443. * Sets the Color Grading 2D Lookup Texture.
  103444. */
  103445. cameraColorGradingTexture: Nullable<BaseTexture>;
  103446. /**
  103447. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103448. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103449. * 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;
  103450. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103451. */
  103452. /**
  103453. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103454. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103455. * 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;
  103456. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103457. */
  103458. cameraColorCurves: Nullable<ColorCurves>;
  103459. /**
  103460. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103461. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103462. */
  103463. switchToBGR: boolean;
  103464. private _renderTargets;
  103465. private _reflectionControls;
  103466. private _white;
  103467. private _primaryShadowColor;
  103468. private _primaryHighlightColor;
  103469. /**
  103470. * Instantiates a Background Material in the given scene
  103471. * @param name The friendly name of the material
  103472. * @param scene The scene to add the material to
  103473. */
  103474. constructor(name: string, scene: Scene);
  103475. /**
  103476. * Gets a boolean indicating that current material needs to register RTT
  103477. */
  103478. readonly hasRenderTargetTextures: boolean;
  103479. /**
  103480. * The entire material has been created in order to prevent overdraw.
  103481. * @returns false
  103482. */
  103483. needAlphaTesting(): boolean;
  103484. /**
  103485. * The entire material has been created in order to prevent overdraw.
  103486. * @returns true if blending is enable
  103487. */
  103488. needAlphaBlending(): boolean;
  103489. /**
  103490. * Checks wether the material is ready to be rendered for a given mesh.
  103491. * @param mesh The mesh to render
  103492. * @param subMesh The submesh to check against
  103493. * @param useInstances Specify wether or not the material is used with instances
  103494. * @returns true if all the dependencies are ready (Textures, Effects...)
  103495. */
  103496. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103497. /**
  103498. * Compute the primary color according to the chosen perceptual color.
  103499. */
  103500. private _computePrimaryColorFromPerceptualColor;
  103501. /**
  103502. * Compute the highlights and shadow colors according to their chosen levels.
  103503. */
  103504. private _computePrimaryColors;
  103505. /**
  103506. * Build the uniform buffer used in the material.
  103507. */
  103508. buildUniformLayout(): void;
  103509. /**
  103510. * Unbind the material.
  103511. */
  103512. unbind(): void;
  103513. /**
  103514. * Bind only the world matrix to the material.
  103515. * @param world The world matrix to bind.
  103516. */
  103517. bindOnlyWorldMatrix(world: Matrix): void;
  103518. /**
  103519. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103520. * @param world The world matrix to bind.
  103521. * @param subMesh The submesh to bind for.
  103522. */
  103523. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103524. /**
  103525. * Dispose the material.
  103526. * @param forceDisposeEffect Force disposal of the associated effect.
  103527. * @param forceDisposeTextures Force disposal of the associated textures.
  103528. */
  103529. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103530. /**
  103531. * Clones the material.
  103532. * @param name The cloned name.
  103533. * @returns The cloned material.
  103534. */
  103535. clone(name: string): BackgroundMaterial;
  103536. /**
  103537. * Serializes the current material to its JSON representation.
  103538. * @returns The JSON representation.
  103539. */
  103540. serialize(): any;
  103541. /**
  103542. * Gets the class name of the material
  103543. * @returns "BackgroundMaterial"
  103544. */
  103545. getClassName(): string;
  103546. /**
  103547. * Parse a JSON input to create back a background material.
  103548. * @param source The JSON data to parse
  103549. * @param scene The scene to create the parsed material in
  103550. * @param rootUrl The root url of the assets the material depends upon
  103551. * @returns the instantiated BackgroundMaterial.
  103552. */
  103553. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103554. }
  103555. }
  103556. declare module BABYLON {
  103557. /**
  103558. * Represents the different options available during the creation of
  103559. * a Environment helper.
  103560. *
  103561. * This can control the default ground, skybox and image processing setup of your scene.
  103562. */
  103563. export interface IEnvironmentHelperOptions {
  103564. /**
  103565. * Specifies wether or not to create a ground.
  103566. * True by default.
  103567. */
  103568. createGround: boolean;
  103569. /**
  103570. * Specifies the ground size.
  103571. * 15 by default.
  103572. */
  103573. groundSize: number;
  103574. /**
  103575. * The texture used on the ground for the main color.
  103576. * Comes from the BabylonJS CDN by default.
  103577. *
  103578. * Remarks: Can be either a texture or a url.
  103579. */
  103580. groundTexture: string | BaseTexture;
  103581. /**
  103582. * The color mixed in the ground texture by default.
  103583. * BabylonJS clearColor by default.
  103584. */
  103585. groundColor: Color3;
  103586. /**
  103587. * Specifies the ground opacity.
  103588. * 1 by default.
  103589. */
  103590. groundOpacity: number;
  103591. /**
  103592. * Enables the ground to receive shadows.
  103593. * True by default.
  103594. */
  103595. enableGroundShadow: boolean;
  103596. /**
  103597. * Helps preventing the shadow to be fully black on the ground.
  103598. * 0.5 by default.
  103599. */
  103600. groundShadowLevel: number;
  103601. /**
  103602. * Creates a mirror texture attach to the ground.
  103603. * false by default.
  103604. */
  103605. enableGroundMirror: boolean;
  103606. /**
  103607. * Specifies the ground mirror size ratio.
  103608. * 0.3 by default as the default kernel is 64.
  103609. */
  103610. groundMirrorSizeRatio: number;
  103611. /**
  103612. * Specifies the ground mirror blur kernel size.
  103613. * 64 by default.
  103614. */
  103615. groundMirrorBlurKernel: number;
  103616. /**
  103617. * Specifies the ground mirror visibility amount.
  103618. * 1 by default
  103619. */
  103620. groundMirrorAmount: number;
  103621. /**
  103622. * Specifies the ground mirror reflectance weight.
  103623. * This uses the standard weight of the background material to setup the fresnel effect
  103624. * of the mirror.
  103625. * 1 by default.
  103626. */
  103627. groundMirrorFresnelWeight: number;
  103628. /**
  103629. * Specifies the ground mirror Falloff distance.
  103630. * This can helps reducing the size of the reflection.
  103631. * 0 by Default.
  103632. */
  103633. groundMirrorFallOffDistance: number;
  103634. /**
  103635. * Specifies the ground mirror texture type.
  103636. * Unsigned Int by Default.
  103637. */
  103638. groundMirrorTextureType: number;
  103639. /**
  103640. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103641. * the shown objects.
  103642. */
  103643. groundYBias: number;
  103644. /**
  103645. * Specifies wether or not to create a skybox.
  103646. * True by default.
  103647. */
  103648. createSkybox: boolean;
  103649. /**
  103650. * Specifies the skybox size.
  103651. * 20 by default.
  103652. */
  103653. skyboxSize: number;
  103654. /**
  103655. * The texture used on the skybox for the main color.
  103656. * Comes from the BabylonJS CDN by default.
  103657. *
  103658. * Remarks: Can be either a texture or a url.
  103659. */
  103660. skyboxTexture: string | BaseTexture;
  103661. /**
  103662. * The color mixed in the skybox texture by default.
  103663. * BabylonJS clearColor by default.
  103664. */
  103665. skyboxColor: Color3;
  103666. /**
  103667. * The background rotation around the Y axis of the scene.
  103668. * This helps aligning the key lights of your scene with the background.
  103669. * 0 by default.
  103670. */
  103671. backgroundYRotation: number;
  103672. /**
  103673. * Compute automatically the size of the elements to best fit with the scene.
  103674. */
  103675. sizeAuto: boolean;
  103676. /**
  103677. * Default position of the rootMesh if autoSize is not true.
  103678. */
  103679. rootPosition: Vector3;
  103680. /**
  103681. * Sets up the image processing in the scene.
  103682. * true by default.
  103683. */
  103684. setupImageProcessing: boolean;
  103685. /**
  103686. * The texture used as your environment texture in the scene.
  103687. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103688. *
  103689. * Remarks: Can be either a texture or a url.
  103690. */
  103691. environmentTexture: string | BaseTexture;
  103692. /**
  103693. * The value of the exposure to apply to the scene.
  103694. * 0.6 by default if setupImageProcessing is true.
  103695. */
  103696. cameraExposure: number;
  103697. /**
  103698. * The value of the contrast to apply to the scene.
  103699. * 1.6 by default if setupImageProcessing is true.
  103700. */
  103701. cameraContrast: number;
  103702. /**
  103703. * Specifies wether or not tonemapping should be enabled in the scene.
  103704. * true by default if setupImageProcessing is true.
  103705. */
  103706. toneMappingEnabled: boolean;
  103707. }
  103708. /**
  103709. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103710. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103711. * It also helps with the default setup of your imageProcessing configuration.
  103712. */
  103713. export class EnvironmentHelper {
  103714. /**
  103715. * Default ground texture URL.
  103716. */
  103717. private static _groundTextureCDNUrl;
  103718. /**
  103719. * Default skybox texture URL.
  103720. */
  103721. private static _skyboxTextureCDNUrl;
  103722. /**
  103723. * Default environment texture URL.
  103724. */
  103725. private static _environmentTextureCDNUrl;
  103726. /**
  103727. * Creates the default options for the helper.
  103728. */
  103729. private static _getDefaultOptions;
  103730. private _rootMesh;
  103731. /**
  103732. * Gets the root mesh created by the helper.
  103733. */
  103734. readonly rootMesh: Mesh;
  103735. private _skybox;
  103736. /**
  103737. * Gets the skybox created by the helper.
  103738. */
  103739. readonly skybox: Nullable<Mesh>;
  103740. private _skyboxTexture;
  103741. /**
  103742. * Gets the skybox texture created by the helper.
  103743. */
  103744. readonly skyboxTexture: Nullable<BaseTexture>;
  103745. private _skyboxMaterial;
  103746. /**
  103747. * Gets the skybox material created by the helper.
  103748. */
  103749. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103750. private _ground;
  103751. /**
  103752. * Gets the ground mesh created by the helper.
  103753. */
  103754. readonly ground: Nullable<Mesh>;
  103755. private _groundTexture;
  103756. /**
  103757. * Gets the ground texture created by the helper.
  103758. */
  103759. readonly groundTexture: Nullable<BaseTexture>;
  103760. private _groundMirror;
  103761. /**
  103762. * Gets the ground mirror created by the helper.
  103763. */
  103764. readonly groundMirror: Nullable<MirrorTexture>;
  103765. /**
  103766. * Gets the ground mirror render list to helps pushing the meshes
  103767. * you wish in the ground reflection.
  103768. */
  103769. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103770. private _groundMaterial;
  103771. /**
  103772. * Gets the ground material created by the helper.
  103773. */
  103774. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103775. /**
  103776. * Stores the creation options.
  103777. */
  103778. private readonly _scene;
  103779. private _options;
  103780. /**
  103781. * This observable will be notified with any error during the creation of the environment,
  103782. * mainly texture creation errors.
  103783. */
  103784. onErrorObservable: Observable<{
  103785. message?: string;
  103786. exception?: any;
  103787. }>;
  103788. /**
  103789. * constructor
  103790. * @param options Defines the options we want to customize the helper
  103791. * @param scene The scene to add the material to
  103792. */
  103793. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103794. /**
  103795. * Updates the background according to the new options
  103796. * @param options
  103797. */
  103798. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103799. /**
  103800. * Sets the primary color of all the available elements.
  103801. * @param color the main color to affect to the ground and the background
  103802. */
  103803. setMainColor(color: Color3): void;
  103804. /**
  103805. * Setup the image processing according to the specified options.
  103806. */
  103807. private _setupImageProcessing;
  103808. /**
  103809. * Setup the environment texture according to the specified options.
  103810. */
  103811. private _setupEnvironmentTexture;
  103812. /**
  103813. * Setup the background according to the specified options.
  103814. */
  103815. private _setupBackground;
  103816. /**
  103817. * Get the scene sizes according to the setup.
  103818. */
  103819. private _getSceneSize;
  103820. /**
  103821. * Setup the ground according to the specified options.
  103822. */
  103823. private _setupGround;
  103824. /**
  103825. * Setup the ground material according to the specified options.
  103826. */
  103827. private _setupGroundMaterial;
  103828. /**
  103829. * Setup the ground diffuse texture according to the specified options.
  103830. */
  103831. private _setupGroundDiffuseTexture;
  103832. /**
  103833. * Setup the ground mirror texture according to the specified options.
  103834. */
  103835. private _setupGroundMirrorTexture;
  103836. /**
  103837. * Setup the ground to receive the mirror texture.
  103838. */
  103839. private _setupMirrorInGroundMaterial;
  103840. /**
  103841. * Setup the skybox according to the specified options.
  103842. */
  103843. private _setupSkybox;
  103844. /**
  103845. * Setup the skybox material according to the specified options.
  103846. */
  103847. private _setupSkyboxMaterial;
  103848. /**
  103849. * Setup the skybox reflection texture according to the specified options.
  103850. */
  103851. private _setupSkyboxReflectionTexture;
  103852. private _errorHandler;
  103853. /**
  103854. * Dispose all the elements created by the Helper.
  103855. */
  103856. dispose(): void;
  103857. }
  103858. }
  103859. declare module BABYLON {
  103860. /**
  103861. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103862. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103863. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103864. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103865. */
  103866. export class PhotoDome extends TransformNode {
  103867. private _useDirectMapping;
  103868. /**
  103869. * The texture being displayed on the sphere
  103870. */
  103871. protected _photoTexture: Texture;
  103872. /**
  103873. * Gets or sets the texture being displayed on the sphere
  103874. */
  103875. photoTexture: Texture;
  103876. /**
  103877. * Observable raised when an error occured while loading the 360 image
  103878. */
  103879. onLoadErrorObservable: Observable<string>;
  103880. /**
  103881. * The skybox material
  103882. */
  103883. protected _material: BackgroundMaterial;
  103884. /**
  103885. * The surface used for the skybox
  103886. */
  103887. protected _mesh: Mesh;
  103888. /**
  103889. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103890. * Also see the options.resolution property.
  103891. */
  103892. fovMultiplier: number;
  103893. /**
  103894. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103895. * @param name Element's name, child elements will append suffixes for their own names.
  103896. * @param urlsOfPhoto defines the url of the photo to display
  103897. * @param options defines an object containing optional or exposed sub element properties
  103898. * @param onError defines a callback called when an error occured while loading the texture
  103899. */
  103900. constructor(name: string, urlOfPhoto: string, options: {
  103901. resolution?: number;
  103902. size?: number;
  103903. useDirectMapping?: boolean;
  103904. faceForward?: boolean;
  103905. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103906. /**
  103907. * Releases resources associated with this node.
  103908. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103909. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103910. */
  103911. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103912. }
  103913. }
  103914. declare module BABYLON {
  103915. /** @hidden */
  103916. export var rgbdDecodePixelShader: {
  103917. name: string;
  103918. shader: string;
  103919. };
  103920. }
  103921. declare module BABYLON {
  103922. /**
  103923. * Class used to host texture specific utilities
  103924. */
  103925. export class BRDFTextureTools {
  103926. /**
  103927. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103928. * @param texture the texture to expand.
  103929. */
  103930. private static _ExpandDefaultBRDFTexture;
  103931. /**
  103932. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103933. * @param scene defines the hosting scene
  103934. * @returns the environment BRDF texture
  103935. */
  103936. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103937. private static _environmentBRDFBase64Texture;
  103938. }
  103939. }
  103940. declare module BABYLON {
  103941. /**
  103942. * @hidden
  103943. */
  103944. export interface IMaterialClearCoatDefines {
  103945. CLEARCOAT: boolean;
  103946. CLEARCOAT_DEFAULTIOR: boolean;
  103947. CLEARCOAT_TEXTURE: boolean;
  103948. CLEARCOAT_TEXTUREDIRECTUV: number;
  103949. CLEARCOAT_BUMP: boolean;
  103950. CLEARCOAT_BUMPDIRECTUV: number;
  103951. CLEARCOAT_TINT: boolean;
  103952. CLEARCOAT_TINT_TEXTURE: boolean;
  103953. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103954. /** @hidden */
  103955. _areTexturesDirty: boolean;
  103956. }
  103957. /**
  103958. * Define the code related to the clear coat parameters of the pbr material.
  103959. */
  103960. export class PBRClearCoatConfiguration {
  103961. /**
  103962. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103963. * The default fits with a polyurethane material.
  103964. */
  103965. private static readonly _DefaultIndiceOfRefraction;
  103966. private _isEnabled;
  103967. /**
  103968. * Defines if the clear coat is enabled in the material.
  103969. */
  103970. isEnabled: boolean;
  103971. /**
  103972. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103973. */
  103974. intensity: number;
  103975. /**
  103976. * Defines the clear coat layer roughness.
  103977. */
  103978. roughness: number;
  103979. private _indiceOfRefraction;
  103980. /**
  103981. * Defines the indice of refraction of the clear coat.
  103982. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103983. * The default fits with a polyurethane material.
  103984. * Changing the default value is more performance intensive.
  103985. */
  103986. indiceOfRefraction: number;
  103987. private _texture;
  103988. /**
  103989. * Stores the clear coat values in a texture.
  103990. */
  103991. texture: Nullable<BaseTexture>;
  103992. private _bumpTexture;
  103993. /**
  103994. * Define the clear coat specific bump texture.
  103995. */
  103996. bumpTexture: Nullable<BaseTexture>;
  103997. private _isTintEnabled;
  103998. /**
  103999. * Defines if the clear coat tint is enabled in the material.
  104000. */
  104001. isTintEnabled: boolean;
  104002. /**
  104003. * Defines the clear coat tint of the material.
  104004. * This is only use if tint is enabled
  104005. */
  104006. tintColor: Color3;
  104007. /**
  104008. * Defines the distance at which the tint color should be found in the
  104009. * clear coat media.
  104010. * This is only use if tint is enabled
  104011. */
  104012. tintColorAtDistance: number;
  104013. /**
  104014. * Defines the clear coat layer thickness.
  104015. * This is only use if tint is enabled
  104016. */
  104017. tintThickness: number;
  104018. private _tintTexture;
  104019. /**
  104020. * Stores the clear tint values in a texture.
  104021. * rgb is tint
  104022. * a is a thickness factor
  104023. */
  104024. tintTexture: Nullable<BaseTexture>;
  104025. /** @hidden */
  104026. private _internalMarkAllSubMeshesAsTexturesDirty;
  104027. /** @hidden */
  104028. _markAllSubMeshesAsTexturesDirty(): void;
  104029. /**
  104030. * Instantiate a new istance of clear coat configuration.
  104031. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104032. */
  104033. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104034. /**
  104035. * Gets wehter the submesh is ready to be used or not.
  104036. * @param defines the list of "defines" to update.
  104037. * @param scene defines the scene the material belongs to.
  104038. * @param engine defines the engine the material belongs to.
  104039. * @param disableBumpMap defines wether the material disables bump or not.
  104040. * @returns - boolean indicating that the submesh is ready or not.
  104041. */
  104042. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104043. /**
  104044. * Checks to see if a texture is used in the material.
  104045. * @param defines the list of "defines" to update.
  104046. * @param scene defines the scene to the material belongs to.
  104047. */
  104048. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104049. /**
  104050. * Binds the material data.
  104051. * @param uniformBuffer defines the Uniform buffer to fill in.
  104052. * @param scene defines the scene the material belongs to.
  104053. * @param engine defines the engine the material belongs to.
  104054. * @param disableBumpMap defines wether the material disables bump or not.
  104055. * @param isFrozen defines wether the material is frozen or not.
  104056. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104057. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104058. */
  104059. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104060. /**
  104061. * Checks to see if a texture is used in the material.
  104062. * @param texture - Base texture to use.
  104063. * @returns - Boolean specifying if a texture is used in the material.
  104064. */
  104065. hasTexture(texture: BaseTexture): boolean;
  104066. /**
  104067. * Returns an array of the actively used textures.
  104068. * @param activeTextures Array of BaseTextures
  104069. */
  104070. getActiveTextures(activeTextures: BaseTexture[]): void;
  104071. /**
  104072. * Returns the animatable textures.
  104073. * @param animatables Array of animatable textures.
  104074. */
  104075. getAnimatables(animatables: IAnimatable[]): void;
  104076. /**
  104077. * Disposes the resources of the material.
  104078. * @param forceDisposeTextures - Forces the disposal of all textures.
  104079. */
  104080. dispose(forceDisposeTextures?: boolean): void;
  104081. /**
  104082. * Get the current class name of the texture useful for serialization or dynamic coding.
  104083. * @returns "PBRClearCoatConfiguration"
  104084. */
  104085. getClassName(): string;
  104086. /**
  104087. * Add fallbacks to the effect fallbacks list.
  104088. * @param defines defines the Base texture to use.
  104089. * @param fallbacks defines the current fallback list.
  104090. * @param currentRank defines the current fallback rank.
  104091. * @returns the new fallback rank.
  104092. */
  104093. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104094. /**
  104095. * Add the required uniforms to the current list.
  104096. * @param uniforms defines the current uniform list.
  104097. */
  104098. static AddUniforms(uniforms: string[]): void;
  104099. /**
  104100. * Add the required samplers to the current list.
  104101. * @param samplers defines the current sampler list.
  104102. */
  104103. static AddSamplers(samplers: string[]): void;
  104104. /**
  104105. * Add the required uniforms to the current buffer.
  104106. * @param uniformBuffer defines the current uniform buffer.
  104107. */
  104108. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104109. /**
  104110. * Makes a duplicate of the current configuration into another one.
  104111. * @param clearCoatConfiguration define the config where to copy the info
  104112. */
  104113. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104114. /**
  104115. * Serializes this clear coat configuration.
  104116. * @returns - An object with the serialized config.
  104117. */
  104118. serialize(): any;
  104119. /**
  104120. * Parses a Clear Coat Configuration from a serialized object.
  104121. * @param source - Serialized object.
  104122. */
  104123. parse(source: any): void;
  104124. }
  104125. }
  104126. declare module BABYLON {
  104127. /**
  104128. * @hidden
  104129. */
  104130. export interface IMaterialAnisotropicDefines {
  104131. ANISOTROPIC: boolean;
  104132. ANISOTROPIC_TEXTURE: boolean;
  104133. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104134. MAINUV1: boolean;
  104135. _areTexturesDirty: boolean;
  104136. _needUVs: boolean;
  104137. }
  104138. /**
  104139. * Define the code related to the anisotropic parameters of the pbr material.
  104140. */
  104141. export class PBRAnisotropicConfiguration {
  104142. private _isEnabled;
  104143. /**
  104144. * Defines if the anisotropy is enabled in the material.
  104145. */
  104146. isEnabled: boolean;
  104147. /**
  104148. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104149. */
  104150. intensity: number;
  104151. /**
  104152. * Defines if the effect is along the tangents, bitangents or in between.
  104153. * By default, the effect is "strectching" the highlights along the tangents.
  104154. */
  104155. direction: Vector2;
  104156. private _texture;
  104157. /**
  104158. * Stores the anisotropy values in a texture.
  104159. * rg is direction (like normal from -1 to 1)
  104160. * b is a intensity
  104161. */
  104162. texture: Nullable<BaseTexture>;
  104163. /** @hidden */
  104164. private _internalMarkAllSubMeshesAsTexturesDirty;
  104165. /** @hidden */
  104166. _markAllSubMeshesAsTexturesDirty(): void;
  104167. /**
  104168. * Instantiate a new istance of anisotropy configuration.
  104169. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104170. */
  104171. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104172. /**
  104173. * Specifies that the submesh is ready to be used.
  104174. * @param defines the list of "defines" to update.
  104175. * @param scene defines the scene the material belongs to.
  104176. * @returns - boolean indicating that the submesh is ready or not.
  104177. */
  104178. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104179. /**
  104180. * Checks to see if a texture is used in the material.
  104181. * @param defines the list of "defines" to update.
  104182. * @param mesh the mesh we are preparing the defines for.
  104183. * @param scene defines the scene the material belongs to.
  104184. */
  104185. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104186. /**
  104187. * Binds the material data.
  104188. * @param uniformBuffer defines the Uniform buffer to fill in.
  104189. * @param scene defines the scene the material belongs to.
  104190. * @param isFrozen defines wether the material is frozen or not.
  104191. */
  104192. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104193. /**
  104194. * Checks to see if a texture is used in the material.
  104195. * @param texture - Base texture to use.
  104196. * @returns - Boolean specifying if a texture is used in the material.
  104197. */
  104198. hasTexture(texture: BaseTexture): boolean;
  104199. /**
  104200. * Returns an array of the actively used textures.
  104201. * @param activeTextures Array of BaseTextures
  104202. */
  104203. getActiveTextures(activeTextures: BaseTexture[]): void;
  104204. /**
  104205. * Returns the animatable textures.
  104206. * @param animatables Array of animatable textures.
  104207. */
  104208. getAnimatables(animatables: IAnimatable[]): void;
  104209. /**
  104210. * Disposes the resources of the material.
  104211. * @param forceDisposeTextures - Forces the disposal of all textures.
  104212. */
  104213. dispose(forceDisposeTextures?: boolean): void;
  104214. /**
  104215. * Get the current class name of the texture useful for serialization or dynamic coding.
  104216. * @returns "PBRAnisotropicConfiguration"
  104217. */
  104218. getClassName(): string;
  104219. /**
  104220. * Add fallbacks to the effect fallbacks list.
  104221. * @param defines defines the Base texture to use.
  104222. * @param fallbacks defines the current fallback list.
  104223. * @param currentRank defines the current fallback rank.
  104224. * @returns the new fallback rank.
  104225. */
  104226. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104227. /**
  104228. * Add the required uniforms to the current list.
  104229. * @param uniforms defines the current uniform list.
  104230. */
  104231. static AddUniforms(uniforms: string[]): void;
  104232. /**
  104233. * Add the required uniforms to the current buffer.
  104234. * @param uniformBuffer defines the current uniform buffer.
  104235. */
  104236. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104237. /**
  104238. * Add the required samplers to the current list.
  104239. * @param samplers defines the current sampler list.
  104240. */
  104241. static AddSamplers(samplers: string[]): void;
  104242. /**
  104243. * Makes a duplicate of the current configuration into another one.
  104244. * @param anisotropicConfiguration define the config where to copy the info
  104245. */
  104246. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104247. /**
  104248. * Serializes this anisotropy configuration.
  104249. * @returns - An object with the serialized config.
  104250. */
  104251. serialize(): any;
  104252. /**
  104253. * Parses a anisotropy Configuration from a serialized object.
  104254. * @param source - Serialized object.
  104255. */
  104256. parse(source: any): void;
  104257. }
  104258. }
  104259. declare module BABYLON {
  104260. /**
  104261. * @hidden
  104262. */
  104263. export interface IMaterialBRDFDefines {
  104264. BRDF_V_HEIGHT_CORRELATED: boolean;
  104265. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104266. SPHERICAL_HARMONICS: boolean;
  104267. /** @hidden */
  104268. _areMiscDirty: boolean;
  104269. }
  104270. /**
  104271. * Define the code related to the BRDF parameters of the pbr material.
  104272. */
  104273. export class PBRBRDFConfiguration {
  104274. /**
  104275. * Default value used for the energy conservation.
  104276. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104277. */
  104278. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104279. /**
  104280. * Default value used for the Smith Visibility Height Correlated mode.
  104281. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104282. */
  104283. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104284. /**
  104285. * Default value used for the IBL diffuse part.
  104286. * This can help switching back to the polynomials mode globally which is a tiny bit
  104287. * less GPU intensive at the drawback of a lower quality.
  104288. */
  104289. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104290. private _useEnergyConservation;
  104291. /**
  104292. * Defines if the material uses energy conservation.
  104293. */
  104294. useEnergyConservation: boolean;
  104295. private _useSmithVisibilityHeightCorrelated;
  104296. /**
  104297. * LEGACY Mode set to false
  104298. * Defines if the material uses height smith correlated visibility term.
  104299. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104300. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104301. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104302. * Not relying on height correlated will also disable energy conservation.
  104303. */
  104304. useSmithVisibilityHeightCorrelated: boolean;
  104305. private _useSphericalHarmonics;
  104306. /**
  104307. * LEGACY Mode set to false
  104308. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104309. * diffuse part of the IBL.
  104310. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104311. * to the ground truth.
  104312. */
  104313. useSphericalHarmonics: boolean;
  104314. /** @hidden */
  104315. private _internalMarkAllSubMeshesAsMiscDirty;
  104316. /** @hidden */
  104317. _markAllSubMeshesAsMiscDirty(): void;
  104318. /**
  104319. * Instantiate a new istance of clear coat configuration.
  104320. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104321. */
  104322. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104323. /**
  104324. * Checks to see if a texture is used in the material.
  104325. * @param defines the list of "defines" to update.
  104326. */
  104327. prepareDefines(defines: IMaterialBRDFDefines): void;
  104328. /**
  104329. * Get the current class name of the texture useful for serialization or dynamic coding.
  104330. * @returns "PBRClearCoatConfiguration"
  104331. */
  104332. getClassName(): string;
  104333. /**
  104334. * Makes a duplicate of the current configuration into another one.
  104335. * @param brdfConfiguration define the config where to copy the info
  104336. */
  104337. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104338. /**
  104339. * Serializes this BRDF configuration.
  104340. * @returns - An object with the serialized config.
  104341. */
  104342. serialize(): any;
  104343. /**
  104344. * Parses a BRDF Configuration from a serialized object.
  104345. * @param source - Serialized object.
  104346. */
  104347. parse(source: any): void;
  104348. }
  104349. }
  104350. declare module BABYLON {
  104351. /**
  104352. * @hidden
  104353. */
  104354. export interface IMaterialSheenDefines {
  104355. SHEEN: boolean;
  104356. SHEEN_TEXTURE: boolean;
  104357. SHEEN_TEXTUREDIRECTUV: number;
  104358. SHEEN_LINKWITHALBEDO: boolean;
  104359. /** @hidden */
  104360. _areTexturesDirty: boolean;
  104361. }
  104362. /**
  104363. * Define the code related to the Sheen parameters of the pbr material.
  104364. */
  104365. export class PBRSheenConfiguration {
  104366. private _isEnabled;
  104367. /**
  104368. * Defines if the material uses sheen.
  104369. */
  104370. isEnabled: boolean;
  104371. private _linkSheenWithAlbedo;
  104372. /**
  104373. * Defines if the sheen is linked to the sheen color.
  104374. */
  104375. linkSheenWithAlbedo: boolean;
  104376. /**
  104377. * Defines the sheen intensity.
  104378. */
  104379. intensity: number;
  104380. /**
  104381. * Defines the sheen color.
  104382. */
  104383. color: Color3;
  104384. private _texture;
  104385. /**
  104386. * Stores the sheen tint values in a texture.
  104387. * rgb is tint
  104388. * a is a intensity
  104389. */
  104390. texture: Nullable<BaseTexture>;
  104391. /** @hidden */
  104392. private _internalMarkAllSubMeshesAsTexturesDirty;
  104393. /** @hidden */
  104394. _markAllSubMeshesAsTexturesDirty(): void;
  104395. /**
  104396. * Instantiate a new istance of clear coat configuration.
  104397. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104398. */
  104399. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104400. /**
  104401. * Specifies that the submesh is ready to be used.
  104402. * @param defines the list of "defines" to update.
  104403. * @param scene defines the scene the material belongs to.
  104404. * @returns - boolean indicating that the submesh is ready or not.
  104405. */
  104406. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104407. /**
  104408. * Checks to see if a texture is used in the material.
  104409. * @param defines the list of "defines" to update.
  104410. * @param scene defines the scene the material belongs to.
  104411. */
  104412. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104413. /**
  104414. * Binds the material data.
  104415. * @param uniformBuffer defines the Uniform buffer to fill in.
  104416. * @param scene defines the scene the material belongs to.
  104417. * @param isFrozen defines wether the material is frozen or not.
  104418. */
  104419. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104420. /**
  104421. * Checks to see if a texture is used in the material.
  104422. * @param texture - Base texture to use.
  104423. * @returns - Boolean specifying if a texture is used in the material.
  104424. */
  104425. hasTexture(texture: BaseTexture): boolean;
  104426. /**
  104427. * Returns an array of the actively used textures.
  104428. * @param activeTextures Array of BaseTextures
  104429. */
  104430. getActiveTextures(activeTextures: BaseTexture[]): void;
  104431. /**
  104432. * Returns the animatable textures.
  104433. * @param animatables Array of animatable textures.
  104434. */
  104435. getAnimatables(animatables: IAnimatable[]): void;
  104436. /**
  104437. * Disposes the resources of the material.
  104438. * @param forceDisposeTextures - Forces the disposal of all textures.
  104439. */
  104440. dispose(forceDisposeTextures?: boolean): void;
  104441. /**
  104442. * Get the current class name of the texture useful for serialization or dynamic coding.
  104443. * @returns "PBRSheenConfiguration"
  104444. */
  104445. getClassName(): string;
  104446. /**
  104447. * Add fallbacks to the effect fallbacks list.
  104448. * @param defines defines the Base texture to use.
  104449. * @param fallbacks defines the current fallback list.
  104450. * @param currentRank defines the current fallback rank.
  104451. * @returns the new fallback rank.
  104452. */
  104453. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104454. /**
  104455. * Add the required uniforms to the current list.
  104456. * @param uniforms defines the current uniform list.
  104457. */
  104458. static AddUniforms(uniforms: string[]): void;
  104459. /**
  104460. * Add the required uniforms to the current buffer.
  104461. * @param uniformBuffer defines the current uniform buffer.
  104462. */
  104463. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104464. /**
  104465. * Add the required samplers to the current list.
  104466. * @param samplers defines the current sampler list.
  104467. */
  104468. static AddSamplers(samplers: string[]): void;
  104469. /**
  104470. * Makes a duplicate of the current configuration into another one.
  104471. * @param sheenConfiguration define the config where to copy the info
  104472. */
  104473. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104474. /**
  104475. * Serializes this BRDF configuration.
  104476. * @returns - An object with the serialized config.
  104477. */
  104478. serialize(): any;
  104479. /**
  104480. * Parses a Sheen Configuration from a serialized object.
  104481. * @param source - Serialized object.
  104482. */
  104483. parse(source: any): void;
  104484. }
  104485. }
  104486. declare module BABYLON {
  104487. /**
  104488. * @hidden
  104489. */
  104490. export interface IMaterialSubSurfaceDefines {
  104491. SUBSURFACE: boolean;
  104492. SS_REFRACTION: boolean;
  104493. SS_TRANSLUCENCY: boolean;
  104494. SS_SCATERRING: boolean;
  104495. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104496. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104497. SS_REFRACTIONMAP_3D: boolean;
  104498. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104499. SS_LODINREFRACTIONALPHA: boolean;
  104500. SS_GAMMAREFRACTION: boolean;
  104501. SS_RGBDREFRACTION: boolean;
  104502. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104503. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104504. /** @hidden */
  104505. _areTexturesDirty: boolean;
  104506. }
  104507. /**
  104508. * Define the code related to the sub surface parameters of the pbr material.
  104509. */
  104510. export class PBRSubSurfaceConfiguration {
  104511. private _isRefractionEnabled;
  104512. /**
  104513. * Defines if the refraction is enabled in the material.
  104514. */
  104515. isRefractionEnabled: boolean;
  104516. private _isTranslucencyEnabled;
  104517. /**
  104518. * Defines if the translucency is enabled in the material.
  104519. */
  104520. isTranslucencyEnabled: boolean;
  104521. private _isScatteringEnabled;
  104522. /**
  104523. * Defines the refraction intensity of the material.
  104524. * The refraction when enabled replaces the Diffuse part of the material.
  104525. * The intensity helps transitionning between diffuse and refraction.
  104526. */
  104527. refractionIntensity: number;
  104528. /**
  104529. * Defines the translucency intensity of the material.
  104530. * When translucency has been enabled, this defines how much of the "translucency"
  104531. * is addded to the diffuse part of the material.
  104532. */
  104533. translucencyIntensity: number;
  104534. /**
  104535. * Defines the scattering intensity of the material.
  104536. * When scattering has been enabled, this defines how much of the "scattered light"
  104537. * is addded to the diffuse part of the material.
  104538. */
  104539. scatteringIntensity: number;
  104540. private _thicknessTexture;
  104541. /**
  104542. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104543. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104544. * 0 would mean minimumThickness
  104545. * 1 would mean maximumThickness
  104546. * The other channels might be use as a mask to vary the different effects intensity.
  104547. */
  104548. thicknessTexture: Nullable<BaseTexture>;
  104549. private _refractionTexture;
  104550. /**
  104551. * Defines the texture to use for refraction.
  104552. */
  104553. refractionTexture: Nullable<BaseTexture>;
  104554. private _indexOfRefraction;
  104555. /**
  104556. * Defines the indice of refraction used in the material.
  104557. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104558. */
  104559. indexOfRefraction: number;
  104560. private _invertRefractionY;
  104561. /**
  104562. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104563. */
  104564. invertRefractionY: boolean;
  104565. private _linkRefractionWithTransparency;
  104566. /**
  104567. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104568. * Materials half opaque for instance using refraction could benefit from this control.
  104569. */
  104570. linkRefractionWithTransparency: boolean;
  104571. /**
  104572. * Defines the minimum thickness stored in the thickness map.
  104573. * If no thickness map is defined, this value will be used to simulate thickness.
  104574. */
  104575. minimumThickness: number;
  104576. /**
  104577. * Defines the maximum thickness stored in the thickness map.
  104578. */
  104579. maximumThickness: number;
  104580. /**
  104581. * Defines the volume tint of the material.
  104582. * This is used for both translucency and scattering.
  104583. */
  104584. tintColor: Color3;
  104585. /**
  104586. * Defines the distance at which the tint color should be found in the media.
  104587. * This is used for refraction only.
  104588. */
  104589. tintColorAtDistance: number;
  104590. /**
  104591. * Defines how far each channel transmit through the media.
  104592. * It is defined as a color to simplify it selection.
  104593. */
  104594. diffusionDistance: Color3;
  104595. private _useMaskFromThicknessTexture;
  104596. /**
  104597. * Stores the intensity of the different subsurface effects in the thickness texture.
  104598. * * the green channel is the translucency intensity.
  104599. * * the blue channel is the scattering intensity.
  104600. * * the alpha channel is the refraction intensity.
  104601. */
  104602. useMaskFromThicknessTexture: boolean;
  104603. /** @hidden */
  104604. private _internalMarkAllSubMeshesAsTexturesDirty;
  104605. /** @hidden */
  104606. _markAllSubMeshesAsTexturesDirty(): void;
  104607. /**
  104608. * Instantiate a new istance of sub surface configuration.
  104609. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104610. */
  104611. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104612. /**
  104613. * Gets wehter the submesh is ready to be used or not.
  104614. * @param defines the list of "defines" to update.
  104615. * @param scene defines the scene the material belongs to.
  104616. * @returns - boolean indicating that the submesh is ready or not.
  104617. */
  104618. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104619. /**
  104620. * Checks to see if a texture is used in the material.
  104621. * @param defines the list of "defines" to update.
  104622. * @param scene defines the scene to the material belongs to.
  104623. */
  104624. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104625. /**
  104626. * Binds the material data.
  104627. * @param uniformBuffer defines the Uniform buffer to fill in.
  104628. * @param scene defines the scene the material belongs to.
  104629. * @param engine defines the engine the material belongs to.
  104630. * @param isFrozen defines wether the material is frozen or not.
  104631. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104632. */
  104633. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104634. /**
  104635. * Unbinds the material from the mesh.
  104636. * @param activeEffect defines the effect that should be unbound from.
  104637. * @returns true if unbound, otherwise false
  104638. */
  104639. unbind(activeEffect: Effect): boolean;
  104640. /**
  104641. * Returns the texture used for refraction or null if none is used.
  104642. * @param scene defines the scene the material belongs to.
  104643. * @returns - Refraction texture if present. If no refraction texture and refraction
  104644. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104645. */
  104646. private _getRefractionTexture;
  104647. /**
  104648. * Returns true if alpha blending should be disabled.
  104649. */
  104650. readonly disableAlphaBlending: boolean;
  104651. /**
  104652. * Fills the list of render target textures.
  104653. * @param renderTargets the list of render targets to update
  104654. */
  104655. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104656. /**
  104657. * Checks to see if a texture is used in the material.
  104658. * @param texture - Base texture to use.
  104659. * @returns - Boolean specifying if a texture is used in the material.
  104660. */
  104661. hasTexture(texture: BaseTexture): boolean;
  104662. /**
  104663. * Gets a boolean indicating that current material needs to register RTT
  104664. * @returns true if this uses a render target otherwise false.
  104665. */
  104666. hasRenderTargetTextures(): boolean;
  104667. /**
  104668. * Returns an array of the actively used textures.
  104669. * @param activeTextures Array of BaseTextures
  104670. */
  104671. getActiveTextures(activeTextures: BaseTexture[]): void;
  104672. /**
  104673. * Returns the animatable textures.
  104674. * @param animatables Array of animatable textures.
  104675. */
  104676. getAnimatables(animatables: IAnimatable[]): void;
  104677. /**
  104678. * Disposes the resources of the material.
  104679. * @param forceDisposeTextures - Forces the disposal of all textures.
  104680. */
  104681. dispose(forceDisposeTextures?: boolean): void;
  104682. /**
  104683. * Get the current class name of the texture useful for serialization or dynamic coding.
  104684. * @returns "PBRSubSurfaceConfiguration"
  104685. */
  104686. getClassName(): string;
  104687. /**
  104688. * Add fallbacks to the effect fallbacks list.
  104689. * @param defines defines the Base texture to use.
  104690. * @param fallbacks defines the current fallback list.
  104691. * @param currentRank defines the current fallback rank.
  104692. * @returns the new fallback rank.
  104693. */
  104694. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104695. /**
  104696. * Add the required uniforms to the current list.
  104697. * @param uniforms defines the current uniform list.
  104698. */
  104699. static AddUniforms(uniforms: string[]): void;
  104700. /**
  104701. * Add the required samplers to the current list.
  104702. * @param samplers defines the current sampler list.
  104703. */
  104704. static AddSamplers(samplers: string[]): void;
  104705. /**
  104706. * Add the required uniforms to the current buffer.
  104707. * @param uniformBuffer defines the current uniform buffer.
  104708. */
  104709. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104710. /**
  104711. * Makes a duplicate of the current configuration into another one.
  104712. * @param configuration define the config where to copy the info
  104713. */
  104714. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104715. /**
  104716. * Serializes this Sub Surface configuration.
  104717. * @returns - An object with the serialized config.
  104718. */
  104719. serialize(): any;
  104720. /**
  104721. * Parses a Sub Surface Configuration from a serialized object.
  104722. * @param source - Serialized object.
  104723. */
  104724. parse(source: any): void;
  104725. }
  104726. }
  104727. declare module BABYLON {
  104728. /** @hidden */
  104729. export var pbrFragmentDeclaration: {
  104730. name: string;
  104731. shader: string;
  104732. };
  104733. }
  104734. declare module BABYLON {
  104735. /** @hidden */
  104736. export var pbrUboDeclaration: {
  104737. name: string;
  104738. shader: string;
  104739. };
  104740. }
  104741. declare module BABYLON {
  104742. /** @hidden */
  104743. export var pbrFragmentExtraDeclaration: {
  104744. name: string;
  104745. shader: string;
  104746. };
  104747. }
  104748. declare module BABYLON {
  104749. /** @hidden */
  104750. export var pbrFragmentSamplersDeclaration: {
  104751. name: string;
  104752. shader: string;
  104753. };
  104754. }
  104755. declare module BABYLON {
  104756. /** @hidden */
  104757. export var pbrHelperFunctions: {
  104758. name: string;
  104759. shader: string;
  104760. };
  104761. }
  104762. declare module BABYLON {
  104763. /** @hidden */
  104764. export var harmonicsFunctions: {
  104765. name: string;
  104766. shader: string;
  104767. };
  104768. }
  104769. declare module BABYLON {
  104770. /** @hidden */
  104771. export var pbrDirectLightingSetupFunctions: {
  104772. name: string;
  104773. shader: string;
  104774. };
  104775. }
  104776. declare module BABYLON {
  104777. /** @hidden */
  104778. export var pbrDirectLightingFalloffFunctions: {
  104779. name: string;
  104780. shader: string;
  104781. };
  104782. }
  104783. declare module BABYLON {
  104784. /** @hidden */
  104785. export var pbrBRDFFunctions: {
  104786. name: string;
  104787. shader: string;
  104788. };
  104789. }
  104790. declare module BABYLON {
  104791. /** @hidden */
  104792. export var pbrDirectLightingFunctions: {
  104793. name: string;
  104794. shader: string;
  104795. };
  104796. }
  104797. declare module BABYLON {
  104798. /** @hidden */
  104799. export var pbrIBLFunctions: {
  104800. name: string;
  104801. shader: string;
  104802. };
  104803. }
  104804. declare module BABYLON {
  104805. /** @hidden */
  104806. export var pbrDebug: {
  104807. name: string;
  104808. shader: string;
  104809. };
  104810. }
  104811. declare module BABYLON {
  104812. /** @hidden */
  104813. export var pbrPixelShader: {
  104814. name: string;
  104815. shader: string;
  104816. };
  104817. }
  104818. declare module BABYLON {
  104819. /** @hidden */
  104820. export var pbrVertexDeclaration: {
  104821. name: string;
  104822. shader: string;
  104823. };
  104824. }
  104825. declare module BABYLON {
  104826. /** @hidden */
  104827. export var pbrVertexShader: {
  104828. name: string;
  104829. shader: string;
  104830. };
  104831. }
  104832. declare module BABYLON {
  104833. /**
  104834. * Manages the defines for the PBR Material.
  104835. * @hidden
  104836. */
  104837. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104838. PBR: boolean;
  104839. MAINUV1: boolean;
  104840. MAINUV2: boolean;
  104841. UV1: boolean;
  104842. UV2: boolean;
  104843. ALBEDO: boolean;
  104844. ALBEDODIRECTUV: number;
  104845. VERTEXCOLOR: boolean;
  104846. AMBIENT: boolean;
  104847. AMBIENTDIRECTUV: number;
  104848. AMBIENTINGRAYSCALE: boolean;
  104849. OPACITY: boolean;
  104850. VERTEXALPHA: boolean;
  104851. OPACITYDIRECTUV: number;
  104852. OPACITYRGB: boolean;
  104853. ALPHATEST: boolean;
  104854. DEPTHPREPASS: boolean;
  104855. ALPHABLEND: boolean;
  104856. ALPHAFROMALBEDO: boolean;
  104857. ALPHATESTVALUE: string;
  104858. SPECULAROVERALPHA: boolean;
  104859. RADIANCEOVERALPHA: boolean;
  104860. ALPHAFRESNEL: boolean;
  104861. LINEARALPHAFRESNEL: boolean;
  104862. PREMULTIPLYALPHA: boolean;
  104863. EMISSIVE: boolean;
  104864. EMISSIVEDIRECTUV: number;
  104865. REFLECTIVITY: boolean;
  104866. REFLECTIVITYDIRECTUV: number;
  104867. SPECULARTERM: boolean;
  104868. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104869. MICROSURFACEAUTOMATIC: boolean;
  104870. LODBASEDMICROSFURACE: boolean;
  104871. MICROSURFACEMAP: boolean;
  104872. MICROSURFACEMAPDIRECTUV: number;
  104873. METALLICWORKFLOW: boolean;
  104874. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104875. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104876. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104877. AOSTOREINMETALMAPRED: boolean;
  104878. ENVIRONMENTBRDF: boolean;
  104879. ENVIRONMENTBRDF_RGBD: boolean;
  104880. NORMAL: boolean;
  104881. TANGENT: boolean;
  104882. BUMP: boolean;
  104883. BUMPDIRECTUV: number;
  104884. OBJECTSPACE_NORMALMAP: boolean;
  104885. PARALLAX: boolean;
  104886. PARALLAXOCCLUSION: boolean;
  104887. NORMALXYSCALE: boolean;
  104888. LIGHTMAP: boolean;
  104889. LIGHTMAPDIRECTUV: number;
  104890. USELIGHTMAPASSHADOWMAP: boolean;
  104891. GAMMALIGHTMAP: boolean;
  104892. REFLECTION: boolean;
  104893. REFLECTIONMAP_3D: boolean;
  104894. REFLECTIONMAP_SPHERICAL: boolean;
  104895. REFLECTIONMAP_PLANAR: boolean;
  104896. REFLECTIONMAP_CUBIC: boolean;
  104897. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104898. REFLECTIONMAP_PROJECTION: boolean;
  104899. REFLECTIONMAP_SKYBOX: boolean;
  104900. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104901. REFLECTIONMAP_EXPLICIT: boolean;
  104902. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104903. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104904. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104905. INVERTCUBICMAP: boolean;
  104906. USESPHERICALFROMREFLECTIONMAP: boolean;
  104907. SPHERICAL_HARMONICS: boolean;
  104908. USESPHERICALINVERTEX: boolean;
  104909. REFLECTIONMAP_OPPOSITEZ: boolean;
  104910. LODINREFLECTIONALPHA: boolean;
  104911. GAMMAREFLECTION: boolean;
  104912. RGBDREFLECTION: boolean;
  104913. RADIANCEOCCLUSION: boolean;
  104914. HORIZONOCCLUSION: boolean;
  104915. INSTANCES: boolean;
  104916. NUM_BONE_INFLUENCERS: number;
  104917. BonesPerMesh: number;
  104918. BONETEXTURE: boolean;
  104919. NONUNIFORMSCALING: boolean;
  104920. MORPHTARGETS: boolean;
  104921. MORPHTARGETS_NORMAL: boolean;
  104922. MORPHTARGETS_TANGENT: boolean;
  104923. NUM_MORPH_INFLUENCERS: number;
  104924. IMAGEPROCESSING: boolean;
  104925. VIGNETTE: boolean;
  104926. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104927. VIGNETTEBLENDMODEOPAQUE: boolean;
  104928. TONEMAPPING: boolean;
  104929. TONEMAPPING_ACES: boolean;
  104930. CONTRAST: boolean;
  104931. COLORCURVES: boolean;
  104932. COLORGRADING: boolean;
  104933. COLORGRADING3D: boolean;
  104934. SAMPLER3DGREENDEPTH: boolean;
  104935. SAMPLER3DBGRMAP: boolean;
  104936. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104937. EXPOSURE: boolean;
  104938. MULTIVIEW: boolean;
  104939. USEPHYSICALLIGHTFALLOFF: boolean;
  104940. USEGLTFLIGHTFALLOFF: boolean;
  104941. TWOSIDEDLIGHTING: boolean;
  104942. SHADOWFLOAT: boolean;
  104943. CLIPPLANE: boolean;
  104944. CLIPPLANE2: boolean;
  104945. CLIPPLANE3: boolean;
  104946. CLIPPLANE4: boolean;
  104947. POINTSIZE: boolean;
  104948. FOG: boolean;
  104949. LOGARITHMICDEPTH: boolean;
  104950. FORCENORMALFORWARD: boolean;
  104951. SPECULARAA: boolean;
  104952. CLEARCOAT: boolean;
  104953. CLEARCOAT_DEFAULTIOR: boolean;
  104954. CLEARCOAT_TEXTURE: boolean;
  104955. CLEARCOAT_TEXTUREDIRECTUV: number;
  104956. CLEARCOAT_BUMP: boolean;
  104957. CLEARCOAT_BUMPDIRECTUV: number;
  104958. CLEARCOAT_TINT: boolean;
  104959. CLEARCOAT_TINT_TEXTURE: boolean;
  104960. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104961. ANISOTROPIC: boolean;
  104962. ANISOTROPIC_TEXTURE: boolean;
  104963. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104964. BRDF_V_HEIGHT_CORRELATED: boolean;
  104965. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104966. SHEEN: boolean;
  104967. SHEEN_TEXTURE: boolean;
  104968. SHEEN_TEXTUREDIRECTUV: number;
  104969. SHEEN_LINKWITHALBEDO: boolean;
  104970. SUBSURFACE: boolean;
  104971. SS_REFRACTION: boolean;
  104972. SS_TRANSLUCENCY: boolean;
  104973. SS_SCATERRING: boolean;
  104974. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104975. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104976. SS_REFRACTIONMAP_3D: boolean;
  104977. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104978. SS_LODINREFRACTIONALPHA: boolean;
  104979. SS_GAMMAREFRACTION: boolean;
  104980. SS_RGBDREFRACTION: boolean;
  104981. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104982. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104983. UNLIT: boolean;
  104984. DEBUGMODE: number;
  104985. /**
  104986. * Initializes the PBR Material defines.
  104987. */
  104988. constructor();
  104989. /**
  104990. * Resets the PBR Material defines.
  104991. */
  104992. reset(): void;
  104993. }
  104994. /**
  104995. * The Physically based material base class of BJS.
  104996. *
  104997. * This offers the main features of a standard PBR material.
  104998. * For more information, please refer to the documentation :
  104999. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105000. */
  105001. export abstract class PBRBaseMaterial extends PushMaterial {
  105002. /**
  105003. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105004. */
  105005. static readonly PBRMATERIAL_OPAQUE: number;
  105006. /**
  105007. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105008. */
  105009. static readonly PBRMATERIAL_ALPHATEST: number;
  105010. /**
  105011. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105012. */
  105013. static readonly PBRMATERIAL_ALPHABLEND: number;
  105014. /**
  105015. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105016. * They are also discarded below the alpha cutoff threshold to improve performances.
  105017. */
  105018. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105019. /**
  105020. * Defines the default value of how much AO map is occluding the analytical lights
  105021. * (point spot...).
  105022. */
  105023. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105024. /**
  105025. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  105026. */
  105027. static readonly LIGHTFALLOFF_PHYSICAL: number;
  105028. /**
  105029. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  105030. * to enhance interoperability with other engines.
  105031. */
  105032. static readonly LIGHTFALLOFF_GLTF: number;
  105033. /**
  105034. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  105035. * to enhance interoperability with other materials.
  105036. */
  105037. static readonly LIGHTFALLOFF_STANDARD: number;
  105038. /**
  105039. * Intensity of the direct lights e.g. the four lights available in your scene.
  105040. * This impacts both the direct diffuse and specular highlights.
  105041. */
  105042. protected _directIntensity: number;
  105043. /**
  105044. * Intensity of the emissive part of the material.
  105045. * This helps controlling the emissive effect without modifying the emissive color.
  105046. */
  105047. protected _emissiveIntensity: number;
  105048. /**
  105049. * Intensity of the environment e.g. how much the environment will light the object
  105050. * either through harmonics for rough material or through the refelction for shiny ones.
  105051. */
  105052. protected _environmentIntensity: number;
  105053. /**
  105054. * This is a special control allowing the reduction of the specular highlights coming from the
  105055. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105056. */
  105057. protected _specularIntensity: number;
  105058. /**
  105059. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105060. */
  105061. private _lightingInfos;
  105062. /**
  105063. * Debug Control allowing disabling the bump map on this material.
  105064. */
  105065. protected _disableBumpMap: boolean;
  105066. /**
  105067. * AKA Diffuse Texture in standard nomenclature.
  105068. */
  105069. protected _albedoTexture: Nullable<BaseTexture>;
  105070. /**
  105071. * AKA Occlusion Texture in other nomenclature.
  105072. */
  105073. protected _ambientTexture: Nullable<BaseTexture>;
  105074. /**
  105075. * AKA Occlusion Texture Intensity in other nomenclature.
  105076. */
  105077. protected _ambientTextureStrength: number;
  105078. /**
  105079. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105080. * 1 means it completely occludes it
  105081. * 0 mean it has no impact
  105082. */
  105083. protected _ambientTextureImpactOnAnalyticalLights: number;
  105084. /**
  105085. * Stores the alpha values in a texture.
  105086. */
  105087. protected _opacityTexture: Nullable<BaseTexture>;
  105088. /**
  105089. * Stores the reflection values in a texture.
  105090. */
  105091. protected _reflectionTexture: Nullable<BaseTexture>;
  105092. /**
  105093. * Stores the emissive values in a texture.
  105094. */
  105095. protected _emissiveTexture: Nullable<BaseTexture>;
  105096. /**
  105097. * AKA Specular texture in other nomenclature.
  105098. */
  105099. protected _reflectivityTexture: Nullable<BaseTexture>;
  105100. /**
  105101. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105102. */
  105103. protected _metallicTexture: Nullable<BaseTexture>;
  105104. /**
  105105. * Specifies the metallic scalar of the metallic/roughness workflow.
  105106. * Can also be used to scale the metalness values of the metallic texture.
  105107. */
  105108. protected _metallic: Nullable<number>;
  105109. /**
  105110. * Specifies the roughness scalar of the metallic/roughness workflow.
  105111. * Can also be used to scale the roughness values of the metallic texture.
  105112. */
  105113. protected _roughness: Nullable<number>;
  105114. /**
  105115. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105116. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105117. */
  105118. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105119. /**
  105120. * Stores surface normal data used to displace a mesh in a texture.
  105121. */
  105122. protected _bumpTexture: Nullable<BaseTexture>;
  105123. /**
  105124. * Stores the pre-calculated light information of a mesh in a texture.
  105125. */
  105126. protected _lightmapTexture: Nullable<BaseTexture>;
  105127. /**
  105128. * The color of a material in ambient lighting.
  105129. */
  105130. protected _ambientColor: Color3;
  105131. /**
  105132. * AKA Diffuse Color in other nomenclature.
  105133. */
  105134. protected _albedoColor: Color3;
  105135. /**
  105136. * AKA Specular Color in other nomenclature.
  105137. */
  105138. protected _reflectivityColor: Color3;
  105139. /**
  105140. * The color applied when light is reflected from a material.
  105141. */
  105142. protected _reflectionColor: Color3;
  105143. /**
  105144. * The color applied when light is emitted from a material.
  105145. */
  105146. protected _emissiveColor: Color3;
  105147. /**
  105148. * AKA Glossiness in other nomenclature.
  105149. */
  105150. protected _microSurface: number;
  105151. /**
  105152. * Specifies that the material will use the light map as a show map.
  105153. */
  105154. protected _useLightmapAsShadowmap: boolean;
  105155. /**
  105156. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105157. * makes the reflect vector face the model (under horizon).
  105158. */
  105159. protected _useHorizonOcclusion: boolean;
  105160. /**
  105161. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105162. * too much the area relying on ambient texture to define their ambient occlusion.
  105163. */
  105164. protected _useRadianceOcclusion: boolean;
  105165. /**
  105166. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105167. */
  105168. protected _useAlphaFromAlbedoTexture: boolean;
  105169. /**
  105170. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105171. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105172. */
  105173. protected _useSpecularOverAlpha: boolean;
  105174. /**
  105175. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105176. */
  105177. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105178. /**
  105179. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105180. */
  105181. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105182. /**
  105183. * Specifies if the metallic texture contains the roughness information in its green channel.
  105184. */
  105185. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105186. /**
  105187. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105188. */
  105189. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105190. /**
  105191. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105192. */
  105193. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105194. /**
  105195. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105196. */
  105197. protected _useAmbientInGrayScale: boolean;
  105198. /**
  105199. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105200. * The material will try to infer what glossiness each pixel should be.
  105201. */
  105202. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105203. /**
  105204. * Defines the falloff type used in this material.
  105205. * It by default is Physical.
  105206. */
  105207. protected _lightFalloff: number;
  105208. /**
  105209. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105210. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105211. */
  105212. protected _useRadianceOverAlpha: boolean;
  105213. /**
  105214. * Allows using an object space normal map (instead of tangent space).
  105215. */
  105216. protected _useObjectSpaceNormalMap: boolean;
  105217. /**
  105218. * Allows using the bump map in parallax mode.
  105219. */
  105220. protected _useParallax: boolean;
  105221. /**
  105222. * Allows using the bump map in parallax occlusion mode.
  105223. */
  105224. protected _useParallaxOcclusion: boolean;
  105225. /**
  105226. * Controls the scale bias of the parallax mode.
  105227. */
  105228. protected _parallaxScaleBias: number;
  105229. /**
  105230. * If sets to true, disables all the lights affecting the material.
  105231. */
  105232. protected _disableLighting: boolean;
  105233. /**
  105234. * Number of Simultaneous lights allowed on the material.
  105235. */
  105236. protected _maxSimultaneousLights: number;
  105237. /**
  105238. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105239. */
  105240. protected _invertNormalMapX: boolean;
  105241. /**
  105242. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105243. */
  105244. protected _invertNormalMapY: boolean;
  105245. /**
  105246. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105247. */
  105248. protected _twoSidedLighting: boolean;
  105249. /**
  105250. * Defines the alpha limits in alpha test mode.
  105251. */
  105252. protected _alphaCutOff: number;
  105253. /**
  105254. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105255. */
  105256. protected _forceAlphaTest: boolean;
  105257. /**
  105258. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105259. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105260. */
  105261. protected _useAlphaFresnel: boolean;
  105262. /**
  105263. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105264. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105265. */
  105266. protected _useLinearAlphaFresnel: boolean;
  105267. /**
  105268. * The transparency mode of the material.
  105269. */
  105270. protected _transparencyMode: Nullable<number>;
  105271. /**
  105272. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105273. * from cos thetav and roughness:
  105274. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105275. */
  105276. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105277. /**
  105278. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105279. */
  105280. protected _forceIrradianceInFragment: boolean;
  105281. /**
  105282. * Force normal to face away from face.
  105283. */
  105284. protected _forceNormalForward: boolean;
  105285. /**
  105286. * Enables specular anti aliasing in the PBR shader.
  105287. * It will both interacts on the Geometry for analytical and IBL lighting.
  105288. * It also prefilter the roughness map based on the bump values.
  105289. */
  105290. protected _enableSpecularAntiAliasing: boolean;
  105291. /**
  105292. * Default configuration related to image processing available in the PBR Material.
  105293. */
  105294. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105295. /**
  105296. * Keep track of the image processing observer to allow dispose and replace.
  105297. */
  105298. private _imageProcessingObserver;
  105299. /**
  105300. * Attaches a new image processing configuration to the PBR Material.
  105301. * @param configuration
  105302. */
  105303. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105304. /**
  105305. * Stores the available render targets.
  105306. */
  105307. private _renderTargets;
  105308. /**
  105309. * Sets the global ambient color for the material used in lighting calculations.
  105310. */
  105311. private _globalAmbientColor;
  105312. /**
  105313. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105314. */
  105315. private _useLogarithmicDepth;
  105316. /**
  105317. * If set to true, no lighting calculations will be applied.
  105318. */
  105319. private _unlit;
  105320. private _debugMode;
  105321. /**
  105322. * @hidden
  105323. * This is reserved for the inspector.
  105324. * Defines the material debug mode.
  105325. * It helps seeing only some components of the material while troubleshooting.
  105326. */
  105327. debugMode: number;
  105328. /**
  105329. * @hidden
  105330. * This is reserved for the inspector.
  105331. * Specify from where on screen the debug mode should start.
  105332. * The value goes from -1 (full screen) to 1 (not visible)
  105333. * It helps with side by side comparison against the final render
  105334. * This defaults to -1
  105335. */
  105336. private debugLimit;
  105337. /**
  105338. * @hidden
  105339. * This is reserved for the inspector.
  105340. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105341. * You can use the factor to better multiply the final value.
  105342. */
  105343. private debugFactor;
  105344. /**
  105345. * Defines the clear coat layer parameters for the material.
  105346. */
  105347. readonly clearCoat: PBRClearCoatConfiguration;
  105348. /**
  105349. * Defines the anisotropic parameters for the material.
  105350. */
  105351. readonly anisotropy: PBRAnisotropicConfiguration;
  105352. /**
  105353. * Defines the BRDF parameters for the material.
  105354. */
  105355. readonly brdf: PBRBRDFConfiguration;
  105356. /**
  105357. * Defines the Sheen parameters for the material.
  105358. */
  105359. readonly sheen: PBRSheenConfiguration;
  105360. /**
  105361. * Defines the SubSurface parameters for the material.
  105362. */
  105363. readonly subSurface: PBRSubSurfaceConfiguration;
  105364. /**
  105365. * Custom callback helping to override the default shader used in the material.
  105366. */
  105367. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105368. /**
  105369. * Instantiates a new PBRMaterial instance.
  105370. *
  105371. * @param name The material name
  105372. * @param scene The scene the material will be use in.
  105373. */
  105374. constructor(name: string, scene: Scene);
  105375. /**
  105376. * Gets a boolean indicating that current material needs to register RTT
  105377. */
  105378. readonly hasRenderTargetTextures: boolean;
  105379. /**
  105380. * Gets the name of the material class.
  105381. */
  105382. getClassName(): string;
  105383. /**
  105384. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105385. */
  105386. /**
  105387. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105388. */
  105389. useLogarithmicDepth: boolean;
  105390. /**
  105391. * Gets the current transparency mode.
  105392. */
  105393. /**
  105394. * Sets the transparency mode of the material.
  105395. *
  105396. * | Value | Type | Description |
  105397. * | ----- | ----------------------------------- | ----------- |
  105398. * | 0 | OPAQUE | |
  105399. * | 1 | ALPHATEST | |
  105400. * | 2 | ALPHABLEND | |
  105401. * | 3 | ALPHATESTANDBLEND | |
  105402. *
  105403. */
  105404. transparencyMode: Nullable<number>;
  105405. /**
  105406. * Returns true if alpha blending should be disabled.
  105407. */
  105408. private readonly _disableAlphaBlending;
  105409. /**
  105410. * Specifies whether or not this material should be rendered in alpha blend mode.
  105411. */
  105412. needAlphaBlending(): boolean;
  105413. /**
  105414. * Specifies if the mesh will require alpha blending.
  105415. * @param mesh - BJS mesh.
  105416. */
  105417. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105418. /**
  105419. * Specifies whether or not this material should be rendered in alpha test mode.
  105420. */
  105421. needAlphaTesting(): boolean;
  105422. /**
  105423. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105424. */
  105425. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105426. /**
  105427. * Gets the texture used for the alpha test.
  105428. */
  105429. getAlphaTestTexture(): Nullable<BaseTexture>;
  105430. /**
  105431. * Specifies that the submesh is ready to be used.
  105432. * @param mesh - BJS mesh.
  105433. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105434. * @param useInstances - Specifies that instances should be used.
  105435. * @returns - boolean indicating that the submesh is ready or not.
  105436. */
  105437. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105438. /**
  105439. * Specifies if the material uses metallic roughness workflow.
  105440. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105441. */
  105442. isMetallicWorkflow(): boolean;
  105443. private _prepareEffect;
  105444. private _prepareDefines;
  105445. /**
  105446. * Force shader compilation
  105447. */
  105448. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105449. clipPlane: boolean;
  105450. }>): void;
  105451. /**
  105452. * Initializes the uniform buffer layout for the shader.
  105453. */
  105454. buildUniformLayout(): void;
  105455. /**
  105456. * Unbinds the material from the mesh
  105457. */
  105458. unbind(): void;
  105459. /**
  105460. * Binds the submesh data.
  105461. * @param world - The world matrix.
  105462. * @param mesh - The BJS mesh.
  105463. * @param subMesh - A submesh of the BJS mesh.
  105464. */
  105465. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105466. /**
  105467. * Returns the animatable textures.
  105468. * @returns - Array of animatable textures.
  105469. */
  105470. getAnimatables(): IAnimatable[];
  105471. /**
  105472. * Returns the texture used for reflections.
  105473. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105474. */
  105475. private _getReflectionTexture;
  105476. /**
  105477. * Returns an array of the actively used textures.
  105478. * @returns - Array of BaseTextures
  105479. */
  105480. getActiveTextures(): BaseTexture[];
  105481. /**
  105482. * Checks to see if a texture is used in the material.
  105483. * @param texture - Base texture to use.
  105484. * @returns - Boolean specifying if a texture is used in the material.
  105485. */
  105486. hasTexture(texture: BaseTexture): boolean;
  105487. /**
  105488. * Disposes the resources of the material.
  105489. * @param forceDisposeEffect - Forces the disposal of effects.
  105490. * @param forceDisposeTextures - Forces the disposal of all textures.
  105491. */
  105492. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105493. }
  105494. }
  105495. declare module BABYLON {
  105496. /**
  105497. * The Physically based material of BJS.
  105498. *
  105499. * This offers the main features of a standard PBR material.
  105500. * For more information, please refer to the documentation :
  105501. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105502. */
  105503. export class PBRMaterial extends PBRBaseMaterial {
  105504. /**
  105505. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105506. */
  105507. static readonly PBRMATERIAL_OPAQUE: number;
  105508. /**
  105509. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105510. */
  105511. static readonly PBRMATERIAL_ALPHATEST: number;
  105512. /**
  105513. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105514. */
  105515. static readonly PBRMATERIAL_ALPHABLEND: number;
  105516. /**
  105517. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105518. * They are also discarded below the alpha cutoff threshold to improve performances.
  105519. */
  105520. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105521. /**
  105522. * Defines the default value of how much AO map is occluding the analytical lights
  105523. * (point spot...).
  105524. */
  105525. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105526. /**
  105527. * Intensity of the direct lights e.g. the four lights available in your scene.
  105528. * This impacts both the direct diffuse and specular highlights.
  105529. */
  105530. directIntensity: number;
  105531. /**
  105532. * Intensity of the emissive part of the material.
  105533. * This helps controlling the emissive effect without modifying the emissive color.
  105534. */
  105535. emissiveIntensity: number;
  105536. /**
  105537. * Intensity of the environment e.g. how much the environment will light the object
  105538. * either through harmonics for rough material or through the refelction for shiny ones.
  105539. */
  105540. environmentIntensity: number;
  105541. /**
  105542. * This is a special control allowing the reduction of the specular highlights coming from the
  105543. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105544. */
  105545. specularIntensity: number;
  105546. /**
  105547. * Debug Control allowing disabling the bump map on this material.
  105548. */
  105549. disableBumpMap: boolean;
  105550. /**
  105551. * AKA Diffuse Texture in standard nomenclature.
  105552. */
  105553. albedoTexture: BaseTexture;
  105554. /**
  105555. * AKA Occlusion Texture in other nomenclature.
  105556. */
  105557. ambientTexture: BaseTexture;
  105558. /**
  105559. * AKA Occlusion Texture Intensity in other nomenclature.
  105560. */
  105561. ambientTextureStrength: number;
  105562. /**
  105563. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105564. * 1 means it completely occludes it
  105565. * 0 mean it has no impact
  105566. */
  105567. ambientTextureImpactOnAnalyticalLights: number;
  105568. /**
  105569. * Stores the alpha values in a texture.
  105570. */
  105571. opacityTexture: BaseTexture;
  105572. /**
  105573. * Stores the reflection values in a texture.
  105574. */
  105575. reflectionTexture: Nullable<BaseTexture>;
  105576. /**
  105577. * Stores the emissive values in a texture.
  105578. */
  105579. emissiveTexture: BaseTexture;
  105580. /**
  105581. * AKA Specular texture in other nomenclature.
  105582. */
  105583. reflectivityTexture: BaseTexture;
  105584. /**
  105585. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105586. */
  105587. metallicTexture: BaseTexture;
  105588. /**
  105589. * Specifies the metallic scalar of the metallic/roughness workflow.
  105590. * Can also be used to scale the metalness values of the metallic texture.
  105591. */
  105592. metallic: Nullable<number>;
  105593. /**
  105594. * Specifies the roughness scalar of the metallic/roughness workflow.
  105595. * Can also be used to scale the roughness values of the metallic texture.
  105596. */
  105597. roughness: Nullable<number>;
  105598. /**
  105599. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105600. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105601. */
  105602. microSurfaceTexture: BaseTexture;
  105603. /**
  105604. * Stores surface normal data used to displace a mesh in a texture.
  105605. */
  105606. bumpTexture: BaseTexture;
  105607. /**
  105608. * Stores the pre-calculated light information of a mesh in a texture.
  105609. */
  105610. lightmapTexture: BaseTexture;
  105611. /**
  105612. * Stores the refracted light information in a texture.
  105613. */
  105614. refractionTexture: Nullable<BaseTexture>;
  105615. /**
  105616. * The color of a material in ambient lighting.
  105617. */
  105618. ambientColor: Color3;
  105619. /**
  105620. * AKA Diffuse Color in other nomenclature.
  105621. */
  105622. albedoColor: Color3;
  105623. /**
  105624. * AKA Specular Color in other nomenclature.
  105625. */
  105626. reflectivityColor: Color3;
  105627. /**
  105628. * The color reflected from the material.
  105629. */
  105630. reflectionColor: Color3;
  105631. /**
  105632. * The color emitted from the material.
  105633. */
  105634. emissiveColor: Color3;
  105635. /**
  105636. * AKA Glossiness in other nomenclature.
  105637. */
  105638. microSurface: number;
  105639. /**
  105640. * source material index of refraction (IOR)' / 'destination material IOR.
  105641. */
  105642. indexOfRefraction: number;
  105643. /**
  105644. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105645. */
  105646. invertRefractionY: boolean;
  105647. /**
  105648. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105649. * Materials half opaque for instance using refraction could benefit from this control.
  105650. */
  105651. linkRefractionWithTransparency: boolean;
  105652. /**
  105653. * If true, the light map contains occlusion information instead of lighting info.
  105654. */
  105655. useLightmapAsShadowmap: boolean;
  105656. /**
  105657. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105658. */
  105659. useAlphaFromAlbedoTexture: boolean;
  105660. /**
  105661. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105662. */
  105663. forceAlphaTest: boolean;
  105664. /**
  105665. * Defines the alpha limits in alpha test mode.
  105666. */
  105667. alphaCutOff: number;
  105668. /**
  105669. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105670. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105671. */
  105672. useSpecularOverAlpha: boolean;
  105673. /**
  105674. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105675. */
  105676. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105677. /**
  105678. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105679. */
  105680. useRoughnessFromMetallicTextureAlpha: boolean;
  105681. /**
  105682. * Specifies if the metallic texture contains the roughness information in its green channel.
  105683. */
  105684. useRoughnessFromMetallicTextureGreen: boolean;
  105685. /**
  105686. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105687. */
  105688. useMetallnessFromMetallicTextureBlue: boolean;
  105689. /**
  105690. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105691. */
  105692. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105693. /**
  105694. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105695. */
  105696. useAmbientInGrayScale: boolean;
  105697. /**
  105698. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105699. * The material will try to infer what glossiness each pixel should be.
  105700. */
  105701. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105702. /**
  105703. * BJS is using an harcoded light falloff based on a manually sets up range.
  105704. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105705. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105706. */
  105707. /**
  105708. * BJS is using an harcoded light falloff based on a manually sets up range.
  105709. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105710. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105711. */
  105712. usePhysicalLightFalloff: boolean;
  105713. /**
  105714. * In order to support the falloff compatibility with gltf, a special mode has been added
  105715. * to reproduce the gltf light falloff.
  105716. */
  105717. /**
  105718. * In order to support the falloff compatibility with gltf, a special mode has been added
  105719. * to reproduce the gltf light falloff.
  105720. */
  105721. useGLTFLightFalloff: boolean;
  105722. /**
  105723. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105724. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105725. */
  105726. useRadianceOverAlpha: boolean;
  105727. /**
  105728. * Allows using an object space normal map (instead of tangent space).
  105729. */
  105730. useObjectSpaceNormalMap: boolean;
  105731. /**
  105732. * Allows using the bump map in parallax mode.
  105733. */
  105734. useParallax: boolean;
  105735. /**
  105736. * Allows using the bump map in parallax occlusion mode.
  105737. */
  105738. useParallaxOcclusion: boolean;
  105739. /**
  105740. * Controls the scale bias of the parallax mode.
  105741. */
  105742. parallaxScaleBias: number;
  105743. /**
  105744. * If sets to true, disables all the lights affecting the material.
  105745. */
  105746. disableLighting: boolean;
  105747. /**
  105748. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105749. */
  105750. forceIrradianceInFragment: boolean;
  105751. /**
  105752. * Number of Simultaneous lights allowed on the material.
  105753. */
  105754. maxSimultaneousLights: number;
  105755. /**
  105756. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105757. */
  105758. invertNormalMapX: boolean;
  105759. /**
  105760. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105761. */
  105762. invertNormalMapY: boolean;
  105763. /**
  105764. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105765. */
  105766. twoSidedLighting: boolean;
  105767. /**
  105768. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105769. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105770. */
  105771. useAlphaFresnel: boolean;
  105772. /**
  105773. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105774. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105775. */
  105776. useLinearAlphaFresnel: boolean;
  105777. /**
  105778. * Let user defines the brdf lookup texture used for IBL.
  105779. * A default 8bit version is embedded but you could point at :
  105780. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105781. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105782. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105783. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105784. */
  105785. environmentBRDFTexture: Nullable<BaseTexture>;
  105786. /**
  105787. * Force normal to face away from face.
  105788. */
  105789. forceNormalForward: boolean;
  105790. /**
  105791. * Enables specular anti aliasing in the PBR shader.
  105792. * It will both interacts on the Geometry for analytical and IBL lighting.
  105793. * It also prefilter the roughness map based on the bump values.
  105794. */
  105795. enableSpecularAntiAliasing: boolean;
  105796. /**
  105797. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105798. * makes the reflect vector face the model (under horizon).
  105799. */
  105800. useHorizonOcclusion: boolean;
  105801. /**
  105802. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105803. * too much the area relying on ambient texture to define their ambient occlusion.
  105804. */
  105805. useRadianceOcclusion: boolean;
  105806. /**
  105807. * If set to true, no lighting calculations will be applied.
  105808. */
  105809. unlit: boolean;
  105810. /**
  105811. * Gets the image processing configuration used either in this material.
  105812. */
  105813. /**
  105814. * Sets the Default image processing configuration used either in the this material.
  105815. *
  105816. * If sets to null, the scene one is in use.
  105817. */
  105818. imageProcessingConfiguration: ImageProcessingConfiguration;
  105819. /**
  105820. * Gets wether the color curves effect is enabled.
  105821. */
  105822. /**
  105823. * Sets wether the color curves effect is enabled.
  105824. */
  105825. cameraColorCurvesEnabled: boolean;
  105826. /**
  105827. * Gets wether the color grading effect is enabled.
  105828. */
  105829. /**
  105830. * Gets wether the color grading effect is enabled.
  105831. */
  105832. cameraColorGradingEnabled: boolean;
  105833. /**
  105834. * Gets wether tonemapping is enabled or not.
  105835. */
  105836. /**
  105837. * Sets wether tonemapping is enabled or not
  105838. */
  105839. cameraToneMappingEnabled: boolean;
  105840. /**
  105841. * The camera exposure used on this material.
  105842. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105843. * This corresponds to a photographic exposure.
  105844. */
  105845. /**
  105846. * The camera exposure used on this material.
  105847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105848. * This corresponds to a photographic exposure.
  105849. */
  105850. cameraExposure: number;
  105851. /**
  105852. * Gets The camera contrast used on this material.
  105853. */
  105854. /**
  105855. * Sets The camera contrast used on this material.
  105856. */
  105857. cameraContrast: number;
  105858. /**
  105859. * Gets the Color Grading 2D Lookup Texture.
  105860. */
  105861. /**
  105862. * Sets the Color Grading 2D Lookup Texture.
  105863. */
  105864. cameraColorGradingTexture: Nullable<BaseTexture>;
  105865. /**
  105866. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105868. * 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;
  105869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105870. */
  105871. /**
  105872. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105873. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105874. * 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;
  105875. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105876. */
  105877. cameraColorCurves: Nullable<ColorCurves>;
  105878. /**
  105879. * Instantiates a new PBRMaterial instance.
  105880. *
  105881. * @param name The material name
  105882. * @param scene The scene the material will be use in.
  105883. */
  105884. constructor(name: string, scene: Scene);
  105885. /**
  105886. * Returns the name of this material class.
  105887. */
  105888. getClassName(): string;
  105889. /**
  105890. * Makes a duplicate of the current material.
  105891. * @param name - name to use for the new material.
  105892. */
  105893. clone(name: string): PBRMaterial;
  105894. /**
  105895. * Serializes this PBR Material.
  105896. * @returns - An object with the serialized material.
  105897. */
  105898. serialize(): any;
  105899. /**
  105900. * Parses a PBR Material from a serialized object.
  105901. * @param source - Serialized object.
  105902. * @param scene - BJS scene instance.
  105903. * @param rootUrl - url for the scene object
  105904. * @returns - PBRMaterial
  105905. */
  105906. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105907. }
  105908. }
  105909. declare module BABYLON {
  105910. /**
  105911. * Direct draw surface info
  105912. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105913. */
  105914. export interface DDSInfo {
  105915. /**
  105916. * Width of the texture
  105917. */
  105918. width: number;
  105919. /**
  105920. * Width of the texture
  105921. */
  105922. height: number;
  105923. /**
  105924. * Number of Mipmaps for the texture
  105925. * @see https://en.wikipedia.org/wiki/Mipmap
  105926. */
  105927. mipmapCount: number;
  105928. /**
  105929. * If the textures format is a known fourCC format
  105930. * @see https://www.fourcc.org/
  105931. */
  105932. isFourCC: boolean;
  105933. /**
  105934. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105935. */
  105936. isRGB: boolean;
  105937. /**
  105938. * If the texture is a lumincance format
  105939. */
  105940. isLuminance: boolean;
  105941. /**
  105942. * If this is a cube texture
  105943. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105944. */
  105945. isCube: boolean;
  105946. /**
  105947. * If the texture is a compressed format eg. FOURCC_DXT1
  105948. */
  105949. isCompressed: boolean;
  105950. /**
  105951. * The dxgiFormat of the texture
  105952. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105953. */
  105954. dxgiFormat: number;
  105955. /**
  105956. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105957. */
  105958. textureType: number;
  105959. /**
  105960. * Sphericle polynomial created for the dds texture
  105961. */
  105962. sphericalPolynomial?: SphericalPolynomial;
  105963. }
  105964. /**
  105965. * Class used to provide DDS decompression tools
  105966. */
  105967. export class DDSTools {
  105968. /**
  105969. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105970. */
  105971. static StoreLODInAlphaChannel: boolean;
  105972. /**
  105973. * Gets DDS information from an array buffer
  105974. * @param arrayBuffer defines the array buffer to read data from
  105975. * @returns the DDS information
  105976. */
  105977. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105978. private static _FloatView;
  105979. private static _Int32View;
  105980. private static _ToHalfFloat;
  105981. private static _FromHalfFloat;
  105982. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105983. private static _GetHalfFloatRGBAArrayBuffer;
  105984. private static _GetFloatRGBAArrayBuffer;
  105985. private static _GetFloatAsUIntRGBAArrayBuffer;
  105986. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105987. private static _GetRGBAArrayBuffer;
  105988. private static _ExtractLongWordOrder;
  105989. private static _GetRGBArrayBuffer;
  105990. private static _GetLuminanceArrayBuffer;
  105991. /**
  105992. * Uploads DDS Levels to a Babylon Texture
  105993. * @hidden
  105994. */
  105995. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105996. }
  105997. interface Engine {
  105998. /**
  105999. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  106000. * @param rootUrl defines the url where the file to load is located
  106001. * @param scene defines the current scene
  106002. * @param lodScale defines scale to apply to the mip map selection
  106003. * @param lodOffset defines offset to apply to the mip map selection
  106004. * @param onLoad defines an optional callback raised when the texture is loaded
  106005. * @param onError defines an optional callback raised if there is an issue to load the texture
  106006. * @param format defines the format of the data
  106007. * @param forcedExtension defines the extension to use to pick the right loader
  106008. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  106009. * @returns the cube texture as an InternalTexture
  106010. */
  106011. 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;
  106012. }
  106013. }
  106014. declare module BABYLON {
  106015. /**
  106016. * Implementation of the DDS Texture Loader.
  106017. * @hidden
  106018. */
  106019. export class _DDSTextureLoader implements IInternalTextureLoader {
  106020. /**
  106021. * Defines wether the loader supports cascade loading the different faces.
  106022. */
  106023. readonly supportCascades: boolean;
  106024. /**
  106025. * This returns if the loader support the current file information.
  106026. * @param extension defines the file extension of the file being loaded
  106027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106028. * @param fallback defines the fallback internal texture if any
  106029. * @param isBase64 defines whether the texture is encoded as a base64
  106030. * @param isBuffer defines whether the texture data are stored as a buffer
  106031. * @returns true if the loader can load the specified file
  106032. */
  106033. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106034. /**
  106035. * Transform the url before loading if required.
  106036. * @param rootUrl the url of the texture
  106037. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106038. * @returns the transformed texture
  106039. */
  106040. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106041. /**
  106042. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106043. * @param rootUrl the url of the texture
  106044. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106045. * @returns the fallback texture
  106046. */
  106047. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106048. /**
  106049. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106050. * @param data contains the texture data
  106051. * @param texture defines the BabylonJS internal texture
  106052. * @param createPolynomials will be true if polynomials have been requested
  106053. * @param onLoad defines the callback to trigger once the texture is ready
  106054. * @param onError defines the callback to trigger in case of error
  106055. */
  106056. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106057. /**
  106058. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106059. * @param data contains the texture data
  106060. * @param texture defines the BabylonJS internal texture
  106061. * @param callback defines the method to call once ready to upload
  106062. */
  106063. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106064. }
  106065. }
  106066. declare module BABYLON {
  106067. /** @hidden */
  106068. export var rgbdEncodePixelShader: {
  106069. name: string;
  106070. shader: string;
  106071. };
  106072. }
  106073. declare module BABYLON {
  106074. /**
  106075. * Raw texture data and descriptor sufficient for WebGL texture upload
  106076. */
  106077. export interface EnvironmentTextureInfo {
  106078. /**
  106079. * Version of the environment map
  106080. */
  106081. version: number;
  106082. /**
  106083. * Width of image
  106084. */
  106085. width: number;
  106086. /**
  106087. * Irradiance information stored in the file.
  106088. */
  106089. irradiance: any;
  106090. /**
  106091. * Specular information stored in the file.
  106092. */
  106093. specular: any;
  106094. }
  106095. /**
  106096. * Sets of helpers addressing the serialization and deserialization of environment texture
  106097. * stored in a BabylonJS env file.
  106098. * Those files are usually stored as .env files.
  106099. */
  106100. export class EnvironmentTextureTools {
  106101. /**
  106102. * Magic number identifying the env file.
  106103. */
  106104. private static _MagicBytes;
  106105. /**
  106106. * Gets the environment info from an env file.
  106107. * @param data The array buffer containing the .env bytes.
  106108. * @returns the environment file info (the json header) if successfully parsed.
  106109. */
  106110. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106111. /**
  106112. * Creates an environment texture from a loaded cube texture.
  106113. * @param texture defines the cube texture to convert in env file
  106114. * @return a promise containing the environment data if succesfull.
  106115. */
  106116. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106117. /**
  106118. * Creates a JSON representation of the spherical data.
  106119. * @param texture defines the texture containing the polynomials
  106120. * @return the JSON representation of the spherical info
  106121. */
  106122. private static _CreateEnvTextureIrradiance;
  106123. /**
  106124. * Uploads the texture info contained in the env file to the GPU.
  106125. * @param texture defines the internal texture to upload to
  106126. * @param arrayBuffer defines the buffer cotaining the data to load
  106127. * @param info defines the texture info retrieved through the GetEnvInfo method
  106128. * @returns a promise
  106129. */
  106130. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106131. /**
  106132. * Uploads the levels of image data to the GPU.
  106133. * @param texture defines the internal texture to upload to
  106134. * @param imageData defines the array buffer views of image data [mipmap][face]
  106135. * @returns a promise
  106136. */
  106137. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106138. /**
  106139. * Uploads spherical polynomials information to the texture.
  106140. * @param texture defines the texture we are trying to upload the information to
  106141. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106142. */
  106143. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106144. /** @hidden */
  106145. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106146. }
  106147. }
  106148. declare module BABYLON {
  106149. /**
  106150. * Implementation of the ENV Texture Loader.
  106151. * @hidden
  106152. */
  106153. export class _ENVTextureLoader implements IInternalTextureLoader {
  106154. /**
  106155. * Defines wether the loader supports cascade loading the different faces.
  106156. */
  106157. readonly supportCascades: boolean;
  106158. /**
  106159. * This returns if the loader support the current file information.
  106160. * @param extension defines the file extension of the file being loaded
  106161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106162. * @param fallback defines the fallback internal texture if any
  106163. * @param isBase64 defines whether the texture is encoded as a base64
  106164. * @param isBuffer defines whether the texture data are stored as a buffer
  106165. * @returns true if the loader can load the specified file
  106166. */
  106167. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106168. /**
  106169. * Transform the url before loading if required.
  106170. * @param rootUrl the url of the texture
  106171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106172. * @returns the transformed texture
  106173. */
  106174. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106175. /**
  106176. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106177. * @param rootUrl the url of the texture
  106178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106179. * @returns the fallback texture
  106180. */
  106181. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106182. /**
  106183. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106184. * @param data contains the texture data
  106185. * @param texture defines the BabylonJS internal texture
  106186. * @param createPolynomials will be true if polynomials have been requested
  106187. * @param onLoad defines the callback to trigger once the texture is ready
  106188. * @param onError defines the callback to trigger in case of error
  106189. */
  106190. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106191. /**
  106192. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106193. * @param data contains the texture data
  106194. * @param texture defines the BabylonJS internal texture
  106195. * @param callback defines the method to call once ready to upload
  106196. */
  106197. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106198. }
  106199. }
  106200. declare module BABYLON {
  106201. /**
  106202. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106203. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106204. */
  106205. export class KhronosTextureContainer {
  106206. /** contents of the KTX container file */
  106207. arrayBuffer: any;
  106208. private static HEADER_LEN;
  106209. private static COMPRESSED_2D;
  106210. private static COMPRESSED_3D;
  106211. private static TEX_2D;
  106212. private static TEX_3D;
  106213. /**
  106214. * Gets the openGL type
  106215. */
  106216. glType: number;
  106217. /**
  106218. * Gets the openGL type size
  106219. */
  106220. glTypeSize: number;
  106221. /**
  106222. * Gets the openGL format
  106223. */
  106224. glFormat: number;
  106225. /**
  106226. * Gets the openGL internal format
  106227. */
  106228. glInternalFormat: number;
  106229. /**
  106230. * Gets the base internal format
  106231. */
  106232. glBaseInternalFormat: number;
  106233. /**
  106234. * Gets image width in pixel
  106235. */
  106236. pixelWidth: number;
  106237. /**
  106238. * Gets image height in pixel
  106239. */
  106240. pixelHeight: number;
  106241. /**
  106242. * Gets image depth in pixels
  106243. */
  106244. pixelDepth: number;
  106245. /**
  106246. * Gets the number of array elements
  106247. */
  106248. numberOfArrayElements: number;
  106249. /**
  106250. * Gets the number of faces
  106251. */
  106252. numberOfFaces: number;
  106253. /**
  106254. * Gets the number of mipmap levels
  106255. */
  106256. numberOfMipmapLevels: number;
  106257. /**
  106258. * Gets the bytes of key value data
  106259. */
  106260. bytesOfKeyValueData: number;
  106261. /**
  106262. * Gets the load type
  106263. */
  106264. loadType: number;
  106265. /**
  106266. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106267. */
  106268. isInvalid: boolean;
  106269. /**
  106270. * Creates a new KhronosTextureContainer
  106271. * @param arrayBuffer contents of the KTX container file
  106272. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106273. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106274. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106275. */
  106276. constructor(
  106277. /** contents of the KTX container file */
  106278. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106279. /**
  106280. * Uploads KTX content to a Babylon Texture.
  106281. * It is assumed that the texture has already been created & is currently bound
  106282. * @hidden
  106283. */
  106284. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106285. private _upload2DCompressedLevels;
  106286. }
  106287. }
  106288. declare module BABYLON {
  106289. /**
  106290. * Implementation of the KTX Texture Loader.
  106291. * @hidden
  106292. */
  106293. export class _KTXTextureLoader implements IInternalTextureLoader {
  106294. /**
  106295. * Defines wether the loader supports cascade loading the different faces.
  106296. */
  106297. readonly supportCascades: boolean;
  106298. /**
  106299. * This returns if the loader support the current file information.
  106300. * @param extension defines the file extension of the file being loaded
  106301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106302. * @param fallback defines the fallback internal texture if any
  106303. * @param isBase64 defines whether the texture is encoded as a base64
  106304. * @param isBuffer defines whether the texture data are stored as a buffer
  106305. * @returns true if the loader can load the specified file
  106306. */
  106307. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106308. /**
  106309. * Transform the url before loading if required.
  106310. * @param rootUrl the url of the texture
  106311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106312. * @returns the transformed texture
  106313. */
  106314. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106315. /**
  106316. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106317. * @param rootUrl the url of the texture
  106318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106319. * @returns the fallback texture
  106320. */
  106321. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106322. /**
  106323. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106324. * @param data contains the texture data
  106325. * @param texture defines the BabylonJS internal texture
  106326. * @param createPolynomials will be true if polynomials have been requested
  106327. * @param onLoad defines the callback to trigger once the texture is ready
  106328. * @param onError defines the callback to trigger in case of error
  106329. */
  106330. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106331. /**
  106332. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106333. * @param data contains the texture data
  106334. * @param texture defines the BabylonJS internal texture
  106335. * @param callback defines the method to call once ready to upload
  106336. */
  106337. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106338. }
  106339. }
  106340. declare module BABYLON {
  106341. /** @hidden */
  106342. export var _forceSceneHelpersToBundle: boolean;
  106343. interface Scene {
  106344. /**
  106345. * Creates a default light for the scene.
  106346. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106347. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106348. */
  106349. createDefaultLight(replace?: boolean): void;
  106350. /**
  106351. * Creates a default camera for the scene.
  106352. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106353. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106354. * @param replace has default false, when true replaces the active camera in the scene
  106355. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106356. */
  106357. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106358. /**
  106359. * Creates a default camera and a default light.
  106360. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106361. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106362. * @param replace has the default false, when true replaces the active camera/light in the scene
  106363. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106364. */
  106365. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106366. /**
  106367. * Creates a new sky box
  106368. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106369. * @param environmentTexture defines the texture to use as environment texture
  106370. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106371. * @param scale defines the overall scale of the skybox
  106372. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106373. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106374. * @returns a new mesh holding the sky box
  106375. */
  106376. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106377. /**
  106378. * Creates a new environment
  106379. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106380. * @param options defines the options you can use to configure the environment
  106381. * @returns the new EnvironmentHelper
  106382. */
  106383. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106384. /**
  106385. * Creates a new VREXperienceHelper
  106386. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106387. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106388. * @returns a new VREXperienceHelper
  106389. */
  106390. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106391. /**
  106392. * Creates a new XREXperienceHelper
  106393. * @see http://doc.babylonjs.com/how_to/webxr
  106394. * @returns a promise for a new XREXperienceHelper
  106395. */
  106396. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106397. }
  106398. }
  106399. declare module BABYLON {
  106400. /**
  106401. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106402. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106403. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106404. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106405. */
  106406. export class VideoDome extends TransformNode {
  106407. /**
  106408. * Define the video source as a Monoscopic panoramic 360 video.
  106409. */
  106410. static readonly MODE_MONOSCOPIC: number;
  106411. /**
  106412. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106413. */
  106414. static readonly MODE_TOPBOTTOM: number;
  106415. /**
  106416. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106417. */
  106418. static readonly MODE_SIDEBYSIDE: number;
  106419. private _useDirectMapping;
  106420. /**
  106421. * The video texture being displayed on the sphere
  106422. */
  106423. protected _videoTexture: VideoTexture;
  106424. /**
  106425. * Gets the video texture being displayed on the sphere
  106426. */
  106427. readonly videoTexture: VideoTexture;
  106428. /**
  106429. * The skybox material
  106430. */
  106431. protected _material: BackgroundMaterial;
  106432. /**
  106433. * The surface used for the skybox
  106434. */
  106435. protected _mesh: Mesh;
  106436. /**
  106437. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106438. * Also see the options.resolution property.
  106439. */
  106440. fovMultiplier: number;
  106441. private _videoMode;
  106442. /**
  106443. * Gets or set the current video mode for the video. It can be:
  106444. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106445. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106446. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106447. */
  106448. videoMode: number;
  106449. /**
  106450. * Oberserver used in Stereoscopic VR Mode.
  106451. */
  106452. private _onBeforeCameraRenderObserver;
  106453. /**
  106454. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106455. * @param name Element's name, child elements will append suffixes for their own names.
  106456. * @param urlsOrVideo defines the url(s) or the video element to use
  106457. * @param options An object containing optional or exposed sub element properties
  106458. */
  106459. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106460. resolution?: number;
  106461. clickToPlay?: boolean;
  106462. autoPlay?: boolean;
  106463. loop?: boolean;
  106464. size?: number;
  106465. poster?: string;
  106466. faceForward?: boolean;
  106467. useDirectMapping?: boolean;
  106468. }, scene: Scene);
  106469. private _changeVideoMode;
  106470. /**
  106471. * Releases resources associated with this node.
  106472. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106473. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106474. */
  106475. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106476. }
  106477. }
  106478. declare module BABYLON {
  106479. /**
  106480. * This class can be used to get instrumentation data from a Babylon engine
  106481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106482. */
  106483. export class EngineInstrumentation implements IDisposable {
  106484. /**
  106485. * Define the instrumented engine.
  106486. */
  106487. engine: Engine;
  106488. private _captureGPUFrameTime;
  106489. private _gpuFrameTimeToken;
  106490. private _gpuFrameTime;
  106491. private _captureShaderCompilationTime;
  106492. private _shaderCompilationTime;
  106493. private _onBeginFrameObserver;
  106494. private _onEndFrameObserver;
  106495. private _onBeforeShaderCompilationObserver;
  106496. private _onAfterShaderCompilationObserver;
  106497. /**
  106498. * Gets the perf counter used for GPU frame time
  106499. */
  106500. readonly gpuFrameTimeCounter: PerfCounter;
  106501. /**
  106502. * Gets the GPU frame time capture status
  106503. */
  106504. /**
  106505. * Enable or disable the GPU frame time capture
  106506. */
  106507. captureGPUFrameTime: boolean;
  106508. /**
  106509. * Gets the perf counter used for shader compilation time
  106510. */
  106511. readonly shaderCompilationTimeCounter: PerfCounter;
  106512. /**
  106513. * Gets the shader compilation time capture status
  106514. */
  106515. /**
  106516. * Enable or disable the shader compilation time capture
  106517. */
  106518. captureShaderCompilationTime: boolean;
  106519. /**
  106520. * Instantiates a new engine instrumentation.
  106521. * This class can be used to get instrumentation data from a Babylon engine
  106522. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106523. * @param engine Defines the engine to instrument
  106524. */
  106525. constructor(
  106526. /**
  106527. * Define the instrumented engine.
  106528. */
  106529. engine: Engine);
  106530. /**
  106531. * Dispose and release associated resources.
  106532. */
  106533. dispose(): void;
  106534. }
  106535. }
  106536. declare module BABYLON {
  106537. /**
  106538. * This class can be used to get instrumentation data from a Babylon engine
  106539. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106540. */
  106541. export class SceneInstrumentation implements IDisposable {
  106542. /**
  106543. * Defines the scene to instrument
  106544. */
  106545. scene: Scene;
  106546. private _captureActiveMeshesEvaluationTime;
  106547. private _activeMeshesEvaluationTime;
  106548. private _captureRenderTargetsRenderTime;
  106549. private _renderTargetsRenderTime;
  106550. private _captureFrameTime;
  106551. private _frameTime;
  106552. private _captureRenderTime;
  106553. private _renderTime;
  106554. private _captureInterFrameTime;
  106555. private _interFrameTime;
  106556. private _captureParticlesRenderTime;
  106557. private _particlesRenderTime;
  106558. private _captureSpritesRenderTime;
  106559. private _spritesRenderTime;
  106560. private _capturePhysicsTime;
  106561. private _physicsTime;
  106562. private _captureAnimationsTime;
  106563. private _animationsTime;
  106564. private _captureCameraRenderTime;
  106565. private _cameraRenderTime;
  106566. private _onBeforeActiveMeshesEvaluationObserver;
  106567. private _onAfterActiveMeshesEvaluationObserver;
  106568. private _onBeforeRenderTargetsRenderObserver;
  106569. private _onAfterRenderTargetsRenderObserver;
  106570. private _onAfterRenderObserver;
  106571. private _onBeforeDrawPhaseObserver;
  106572. private _onAfterDrawPhaseObserver;
  106573. private _onBeforeAnimationsObserver;
  106574. private _onBeforeParticlesRenderingObserver;
  106575. private _onAfterParticlesRenderingObserver;
  106576. private _onBeforeSpritesRenderingObserver;
  106577. private _onAfterSpritesRenderingObserver;
  106578. private _onBeforePhysicsObserver;
  106579. private _onAfterPhysicsObserver;
  106580. private _onAfterAnimationsObserver;
  106581. private _onBeforeCameraRenderObserver;
  106582. private _onAfterCameraRenderObserver;
  106583. /**
  106584. * Gets the perf counter used for active meshes evaluation time
  106585. */
  106586. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106587. /**
  106588. * Gets the active meshes evaluation time capture status
  106589. */
  106590. /**
  106591. * Enable or disable the active meshes evaluation time capture
  106592. */
  106593. captureActiveMeshesEvaluationTime: boolean;
  106594. /**
  106595. * Gets the perf counter used for render targets render time
  106596. */
  106597. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106598. /**
  106599. * Gets the render targets render time capture status
  106600. */
  106601. /**
  106602. * Enable or disable the render targets render time capture
  106603. */
  106604. captureRenderTargetsRenderTime: boolean;
  106605. /**
  106606. * Gets the perf counter used for particles render time
  106607. */
  106608. readonly particlesRenderTimeCounter: PerfCounter;
  106609. /**
  106610. * Gets the particles render time capture status
  106611. */
  106612. /**
  106613. * Enable or disable the particles render time capture
  106614. */
  106615. captureParticlesRenderTime: boolean;
  106616. /**
  106617. * Gets the perf counter used for sprites render time
  106618. */
  106619. readonly spritesRenderTimeCounter: PerfCounter;
  106620. /**
  106621. * Gets the sprites render time capture status
  106622. */
  106623. /**
  106624. * Enable or disable the sprites render time capture
  106625. */
  106626. captureSpritesRenderTime: boolean;
  106627. /**
  106628. * Gets the perf counter used for physics time
  106629. */
  106630. readonly physicsTimeCounter: PerfCounter;
  106631. /**
  106632. * Gets the physics time capture status
  106633. */
  106634. /**
  106635. * Enable or disable the physics time capture
  106636. */
  106637. capturePhysicsTime: boolean;
  106638. /**
  106639. * Gets the perf counter used for animations time
  106640. */
  106641. readonly animationsTimeCounter: PerfCounter;
  106642. /**
  106643. * Gets the animations time capture status
  106644. */
  106645. /**
  106646. * Enable or disable the animations time capture
  106647. */
  106648. captureAnimationsTime: boolean;
  106649. /**
  106650. * Gets the perf counter used for frame time capture
  106651. */
  106652. readonly frameTimeCounter: PerfCounter;
  106653. /**
  106654. * Gets the frame time capture status
  106655. */
  106656. /**
  106657. * Enable or disable the frame time capture
  106658. */
  106659. captureFrameTime: boolean;
  106660. /**
  106661. * Gets the perf counter used for inter-frames time capture
  106662. */
  106663. readonly interFrameTimeCounter: PerfCounter;
  106664. /**
  106665. * Gets the inter-frames time capture status
  106666. */
  106667. /**
  106668. * Enable or disable the inter-frames time capture
  106669. */
  106670. captureInterFrameTime: boolean;
  106671. /**
  106672. * Gets the perf counter used for render time capture
  106673. */
  106674. readonly renderTimeCounter: PerfCounter;
  106675. /**
  106676. * Gets the render time capture status
  106677. */
  106678. /**
  106679. * Enable or disable the render time capture
  106680. */
  106681. captureRenderTime: boolean;
  106682. /**
  106683. * Gets the perf counter used for camera render time capture
  106684. */
  106685. readonly cameraRenderTimeCounter: PerfCounter;
  106686. /**
  106687. * Gets the camera render time capture status
  106688. */
  106689. /**
  106690. * Enable or disable the camera render time capture
  106691. */
  106692. captureCameraRenderTime: boolean;
  106693. /**
  106694. * Gets the perf counter used for draw calls
  106695. */
  106696. readonly drawCallsCounter: PerfCounter;
  106697. /**
  106698. * Instantiates a new scene instrumentation.
  106699. * This class can be used to get instrumentation data from a Babylon engine
  106700. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106701. * @param scene Defines the scene to instrument
  106702. */
  106703. constructor(
  106704. /**
  106705. * Defines the scene to instrument
  106706. */
  106707. scene: Scene);
  106708. /**
  106709. * Dispose and release associated resources.
  106710. */
  106711. dispose(): void;
  106712. }
  106713. }
  106714. declare module BABYLON {
  106715. /** @hidden */
  106716. export var glowMapGenerationPixelShader: {
  106717. name: string;
  106718. shader: string;
  106719. };
  106720. }
  106721. declare module BABYLON {
  106722. /** @hidden */
  106723. export var glowMapGenerationVertexShader: {
  106724. name: string;
  106725. shader: string;
  106726. };
  106727. }
  106728. declare module BABYLON {
  106729. /**
  106730. * Effect layer options. This helps customizing the behaviour
  106731. * of the effect layer.
  106732. */
  106733. export interface IEffectLayerOptions {
  106734. /**
  106735. * Multiplication factor apply to the canvas size to compute the render target size
  106736. * used to generated the objects (the smaller the faster).
  106737. */
  106738. mainTextureRatio: number;
  106739. /**
  106740. * Enforces a fixed size texture to ensure effect stability across devices.
  106741. */
  106742. mainTextureFixedSize?: number;
  106743. /**
  106744. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106745. */
  106746. alphaBlendingMode: number;
  106747. /**
  106748. * The camera attached to the layer.
  106749. */
  106750. camera: Nullable<Camera>;
  106751. /**
  106752. * The rendering group to draw the layer in.
  106753. */
  106754. renderingGroupId: number;
  106755. }
  106756. /**
  106757. * The effect layer Helps adding post process effect blended with the main pass.
  106758. *
  106759. * This can be for instance use to generate glow or higlight effects on the scene.
  106760. *
  106761. * The effect layer class can not be used directly and is intented to inherited from to be
  106762. * customized per effects.
  106763. */
  106764. export abstract class EffectLayer {
  106765. private _vertexBuffers;
  106766. private _indexBuffer;
  106767. private _cachedDefines;
  106768. private _effectLayerMapGenerationEffect;
  106769. private _effectLayerOptions;
  106770. private _mergeEffect;
  106771. protected _scene: Scene;
  106772. protected _engine: Engine;
  106773. protected _maxSize: number;
  106774. protected _mainTextureDesiredSize: ISize;
  106775. protected _mainTexture: RenderTargetTexture;
  106776. protected _shouldRender: boolean;
  106777. protected _postProcesses: PostProcess[];
  106778. protected _textures: BaseTexture[];
  106779. protected _emissiveTextureAndColor: {
  106780. texture: Nullable<BaseTexture>;
  106781. color: Color4;
  106782. };
  106783. /**
  106784. * The name of the layer
  106785. */
  106786. name: string;
  106787. /**
  106788. * The clear color of the texture used to generate the glow map.
  106789. */
  106790. neutralColor: Color4;
  106791. /**
  106792. * Specifies wether the highlight layer is enabled or not.
  106793. */
  106794. isEnabled: boolean;
  106795. /**
  106796. * Gets the camera attached to the layer.
  106797. */
  106798. readonly camera: Nullable<Camera>;
  106799. /**
  106800. * Gets the rendering group id the layer should render in.
  106801. */
  106802. readonly renderingGroupId: number;
  106803. /**
  106804. * An event triggered when the effect layer has been disposed.
  106805. */
  106806. onDisposeObservable: Observable<EffectLayer>;
  106807. /**
  106808. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106809. */
  106810. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106811. /**
  106812. * An event triggered when the generated texture is being merged in the scene.
  106813. */
  106814. onBeforeComposeObservable: Observable<EffectLayer>;
  106815. /**
  106816. * An event triggered when the generated texture has been merged in the scene.
  106817. */
  106818. onAfterComposeObservable: Observable<EffectLayer>;
  106819. /**
  106820. * An event triggered when the efffect layer changes its size.
  106821. */
  106822. onSizeChangedObservable: Observable<EffectLayer>;
  106823. /** @hidden */
  106824. static _SceneComponentInitialization: (scene: Scene) => void;
  106825. /**
  106826. * Instantiates a new effect Layer and references it in the scene.
  106827. * @param name The name of the layer
  106828. * @param scene The scene to use the layer in
  106829. */
  106830. constructor(
  106831. /** The Friendly of the effect in the scene */
  106832. name: string, scene: Scene);
  106833. /**
  106834. * Get the effect name of the layer.
  106835. * @return The effect name
  106836. */
  106837. abstract getEffectName(): string;
  106838. /**
  106839. * Checks for the readiness of the element composing the layer.
  106840. * @param subMesh the mesh to check for
  106841. * @param useInstances specify wether or not to use instances to render the mesh
  106842. * @return true if ready otherwise, false
  106843. */
  106844. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106845. /**
  106846. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106847. * @returns true if the effect requires stencil during the main canvas render pass.
  106848. */
  106849. abstract needStencil(): boolean;
  106850. /**
  106851. * Create the merge effect. This is the shader use to blit the information back
  106852. * to the main canvas at the end of the scene rendering.
  106853. * @returns The effect containing the shader used to merge the effect on the main canvas
  106854. */
  106855. protected abstract _createMergeEffect(): Effect;
  106856. /**
  106857. * Creates the render target textures and post processes used in the effect layer.
  106858. */
  106859. protected abstract _createTextureAndPostProcesses(): void;
  106860. /**
  106861. * Implementation specific of rendering the generating effect on the main canvas.
  106862. * @param effect The effect used to render through
  106863. */
  106864. protected abstract _internalRender(effect: Effect): void;
  106865. /**
  106866. * Sets the required values for both the emissive texture and and the main color.
  106867. */
  106868. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106869. /**
  106870. * Free any resources and references associated to a mesh.
  106871. * Internal use
  106872. * @param mesh The mesh to free.
  106873. */
  106874. abstract _disposeMesh(mesh: Mesh): void;
  106875. /**
  106876. * Serializes this layer (Glow or Highlight for example)
  106877. * @returns a serialized layer object
  106878. */
  106879. abstract serialize?(): any;
  106880. /**
  106881. * Initializes the effect layer with the required options.
  106882. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106883. */
  106884. protected _init(options: Partial<IEffectLayerOptions>): void;
  106885. /**
  106886. * Generates the index buffer of the full screen quad blending to the main canvas.
  106887. */
  106888. private _generateIndexBuffer;
  106889. /**
  106890. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106891. */
  106892. private _generateVertexBuffer;
  106893. /**
  106894. * Sets the main texture desired size which is the closest power of two
  106895. * of the engine canvas size.
  106896. */
  106897. private _setMainTextureSize;
  106898. /**
  106899. * Creates the main texture for the effect layer.
  106900. */
  106901. protected _createMainTexture(): void;
  106902. /**
  106903. * Adds specific effects defines.
  106904. * @param defines The defines to add specifics to.
  106905. */
  106906. protected _addCustomEffectDefines(defines: string[]): void;
  106907. /**
  106908. * Checks for the readiness of the element composing the layer.
  106909. * @param subMesh the mesh to check for
  106910. * @param useInstances specify wether or not to use instances to render the mesh
  106911. * @param emissiveTexture the associated emissive texture used to generate the glow
  106912. * @return true if ready otherwise, false
  106913. */
  106914. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106915. /**
  106916. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106917. */
  106918. render(): void;
  106919. /**
  106920. * Determine if a given mesh will be used in the current effect.
  106921. * @param mesh mesh to test
  106922. * @returns true if the mesh will be used
  106923. */
  106924. hasMesh(mesh: AbstractMesh): boolean;
  106925. /**
  106926. * Returns true if the layer contains information to display, otherwise false.
  106927. * @returns true if the glow layer should be rendered
  106928. */
  106929. shouldRender(): boolean;
  106930. /**
  106931. * Returns true if the mesh should render, otherwise false.
  106932. * @param mesh The mesh to render
  106933. * @returns true if it should render otherwise false
  106934. */
  106935. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106936. /**
  106937. * Returns true if the mesh can be rendered, otherwise false.
  106938. * @param mesh The mesh to render
  106939. * @param material The material used on the mesh
  106940. * @returns true if it can be rendered otherwise false
  106941. */
  106942. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106943. /**
  106944. * Returns true if the mesh should render, otherwise false.
  106945. * @param mesh The mesh to render
  106946. * @returns true if it should render otherwise false
  106947. */
  106948. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106949. /**
  106950. * Renders the submesh passed in parameter to the generation map.
  106951. */
  106952. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  106953. /**
  106954. * Rebuild the required buffers.
  106955. * @hidden Internal use only.
  106956. */
  106957. _rebuild(): void;
  106958. /**
  106959. * Dispose only the render target textures and post process.
  106960. */
  106961. private _disposeTextureAndPostProcesses;
  106962. /**
  106963. * Dispose the highlight layer and free resources.
  106964. */
  106965. dispose(): void;
  106966. /**
  106967. * Gets the class name of the effect layer
  106968. * @returns the string with the class name of the effect layer
  106969. */
  106970. getClassName(): string;
  106971. /**
  106972. * Creates an effect layer from parsed effect layer data
  106973. * @param parsedEffectLayer defines effect layer data
  106974. * @param scene defines the current scene
  106975. * @param rootUrl defines the root URL containing the effect layer information
  106976. * @returns a parsed effect Layer
  106977. */
  106978. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106979. }
  106980. }
  106981. declare module BABYLON {
  106982. interface AbstractScene {
  106983. /**
  106984. * The list of effect layers (highlights/glow) added to the scene
  106985. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106986. * @see http://doc.babylonjs.com/how_to/glow_layer
  106987. */
  106988. effectLayers: Array<EffectLayer>;
  106989. /**
  106990. * Removes the given effect layer from this scene.
  106991. * @param toRemove defines the effect layer to remove
  106992. * @returns the index of the removed effect layer
  106993. */
  106994. removeEffectLayer(toRemove: EffectLayer): number;
  106995. /**
  106996. * Adds the given effect layer to this scene
  106997. * @param newEffectLayer defines the effect layer to add
  106998. */
  106999. addEffectLayer(newEffectLayer: EffectLayer): void;
  107000. }
  107001. /**
  107002. * Defines the layer scene component responsible to manage any effect layers
  107003. * in a given scene.
  107004. */
  107005. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  107006. /**
  107007. * The component name helpfull to identify the component in the list of scene components.
  107008. */
  107009. readonly name: string;
  107010. /**
  107011. * The scene the component belongs to.
  107012. */
  107013. scene: Scene;
  107014. private _engine;
  107015. private _renderEffects;
  107016. private _needStencil;
  107017. private _previousStencilState;
  107018. /**
  107019. * Creates a new instance of the component for the given scene
  107020. * @param scene Defines the scene to register the component in
  107021. */
  107022. constructor(scene: Scene);
  107023. /**
  107024. * Registers the component in a given scene
  107025. */
  107026. register(): void;
  107027. /**
  107028. * Rebuilds the elements related to this component in case of
  107029. * context lost for instance.
  107030. */
  107031. rebuild(): void;
  107032. /**
  107033. * Serializes the component data to the specified json object
  107034. * @param serializationObject The object to serialize to
  107035. */
  107036. serialize(serializationObject: any): void;
  107037. /**
  107038. * Adds all the element from the container to the scene
  107039. * @param container the container holding the elements
  107040. */
  107041. addFromContainer(container: AbstractScene): void;
  107042. /**
  107043. * Removes all the elements in the container from the scene
  107044. * @param container contains the elements to remove
  107045. * @param dispose if the removed element should be disposed (default: false)
  107046. */
  107047. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107048. /**
  107049. * Disposes the component and the associated ressources.
  107050. */
  107051. dispose(): void;
  107052. private _isReadyForMesh;
  107053. private _renderMainTexture;
  107054. private _setStencil;
  107055. private _setStencilBack;
  107056. private _draw;
  107057. private _drawCamera;
  107058. private _drawRenderingGroup;
  107059. }
  107060. }
  107061. declare module BABYLON {
  107062. /** @hidden */
  107063. export var glowMapMergePixelShader: {
  107064. name: string;
  107065. shader: string;
  107066. };
  107067. }
  107068. declare module BABYLON {
  107069. /** @hidden */
  107070. export var glowMapMergeVertexShader: {
  107071. name: string;
  107072. shader: string;
  107073. };
  107074. }
  107075. declare module BABYLON {
  107076. interface AbstractScene {
  107077. /**
  107078. * Return a the first highlight layer of the scene with a given name.
  107079. * @param name The name of the highlight layer to look for.
  107080. * @return The highlight layer if found otherwise null.
  107081. */
  107082. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107083. }
  107084. /**
  107085. * Glow layer options. This helps customizing the behaviour
  107086. * of the glow layer.
  107087. */
  107088. export interface IGlowLayerOptions {
  107089. /**
  107090. * Multiplication factor apply to the canvas size to compute the render target size
  107091. * used to generated the glowing objects (the smaller the faster).
  107092. */
  107093. mainTextureRatio: number;
  107094. /**
  107095. * Enforces a fixed size texture to ensure resize independant blur.
  107096. */
  107097. mainTextureFixedSize?: number;
  107098. /**
  107099. * How big is the kernel of the blur texture.
  107100. */
  107101. blurKernelSize: number;
  107102. /**
  107103. * The camera attached to the layer.
  107104. */
  107105. camera: Nullable<Camera>;
  107106. /**
  107107. * Enable MSAA by chosing the number of samples.
  107108. */
  107109. mainTextureSamples?: number;
  107110. /**
  107111. * The rendering group to draw the layer in.
  107112. */
  107113. renderingGroupId: number;
  107114. }
  107115. /**
  107116. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107117. *
  107118. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107119. * glowy meshes to your scene.
  107120. *
  107121. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107122. */
  107123. export class GlowLayer extends EffectLayer {
  107124. /**
  107125. * Effect Name of the layer.
  107126. */
  107127. static readonly EffectName: string;
  107128. /**
  107129. * The default blur kernel size used for the glow.
  107130. */
  107131. static DefaultBlurKernelSize: number;
  107132. /**
  107133. * The default texture size ratio used for the glow.
  107134. */
  107135. static DefaultTextureRatio: number;
  107136. /**
  107137. * Sets the kernel size of the blur.
  107138. */
  107139. /**
  107140. * Gets the kernel size of the blur.
  107141. */
  107142. blurKernelSize: number;
  107143. /**
  107144. * Sets the glow intensity.
  107145. */
  107146. /**
  107147. * Gets the glow intensity.
  107148. */
  107149. intensity: number;
  107150. private _options;
  107151. private _intensity;
  107152. private _horizontalBlurPostprocess1;
  107153. private _verticalBlurPostprocess1;
  107154. private _horizontalBlurPostprocess2;
  107155. private _verticalBlurPostprocess2;
  107156. private _blurTexture1;
  107157. private _blurTexture2;
  107158. private _postProcesses1;
  107159. private _postProcesses2;
  107160. private _includedOnlyMeshes;
  107161. private _excludedMeshes;
  107162. /**
  107163. * Callback used to let the user override the color selection on a per mesh basis
  107164. */
  107165. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107166. /**
  107167. * Callback used to let the user override the texture selection on a per mesh basis
  107168. */
  107169. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107170. /**
  107171. * Instantiates a new glow Layer and references it to the scene.
  107172. * @param name The name of the layer
  107173. * @param scene The scene to use the layer in
  107174. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107175. */
  107176. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107177. /**
  107178. * Get the effect name of the layer.
  107179. * @return The effect name
  107180. */
  107181. getEffectName(): string;
  107182. /**
  107183. * Create the merge effect. This is the shader use to blit the information back
  107184. * to the main canvas at the end of the scene rendering.
  107185. */
  107186. protected _createMergeEffect(): Effect;
  107187. /**
  107188. * Creates the render target textures and post processes used in the glow layer.
  107189. */
  107190. protected _createTextureAndPostProcesses(): void;
  107191. /**
  107192. * Checks for the readiness of the element composing the layer.
  107193. * @param subMesh the mesh to check for
  107194. * @param useInstances specify wether or not to use instances to render the mesh
  107195. * @param emissiveTexture the associated emissive texture used to generate the glow
  107196. * @return true if ready otherwise, false
  107197. */
  107198. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107199. /**
  107200. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107201. */
  107202. needStencil(): boolean;
  107203. /**
  107204. * Returns true if the mesh can be rendered, otherwise false.
  107205. * @param mesh The mesh to render
  107206. * @param material The material used on the mesh
  107207. * @returns true if it can be rendered otherwise false
  107208. */
  107209. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107210. /**
  107211. * Implementation specific of rendering the generating effect on the main canvas.
  107212. * @param effect The effect used to render through
  107213. */
  107214. protected _internalRender(effect: Effect): void;
  107215. /**
  107216. * Sets the required values for both the emissive texture and and the main color.
  107217. */
  107218. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107219. /**
  107220. * Returns true if the mesh should render, otherwise false.
  107221. * @param mesh The mesh to render
  107222. * @returns true if it should render otherwise false
  107223. */
  107224. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107225. /**
  107226. * Adds specific effects defines.
  107227. * @param defines The defines to add specifics to.
  107228. */
  107229. protected _addCustomEffectDefines(defines: string[]): void;
  107230. /**
  107231. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107232. * @param mesh The mesh to exclude from the glow layer
  107233. */
  107234. addExcludedMesh(mesh: Mesh): void;
  107235. /**
  107236. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107237. * @param mesh The mesh to remove
  107238. */
  107239. removeExcludedMesh(mesh: Mesh): void;
  107240. /**
  107241. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107242. * @param mesh The mesh to include in the glow layer
  107243. */
  107244. addIncludedOnlyMesh(mesh: Mesh): void;
  107245. /**
  107246. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107247. * @param mesh The mesh to remove
  107248. */
  107249. removeIncludedOnlyMesh(mesh: Mesh): void;
  107250. /**
  107251. * Determine if a given mesh will be used in the glow layer
  107252. * @param mesh The mesh to test
  107253. * @returns true if the mesh will be highlighted by the current glow layer
  107254. */
  107255. hasMesh(mesh: AbstractMesh): boolean;
  107256. /**
  107257. * Free any resources and references associated to a mesh.
  107258. * Internal use
  107259. * @param mesh The mesh to free.
  107260. * @hidden
  107261. */
  107262. _disposeMesh(mesh: Mesh): void;
  107263. /**
  107264. * Gets the class name of the effect layer
  107265. * @returns the string with the class name of the effect layer
  107266. */
  107267. getClassName(): string;
  107268. /**
  107269. * Serializes this glow layer
  107270. * @returns a serialized glow layer object
  107271. */
  107272. serialize(): any;
  107273. /**
  107274. * Creates a Glow Layer from parsed glow layer data
  107275. * @param parsedGlowLayer defines glow layer data
  107276. * @param scene defines the current scene
  107277. * @param rootUrl defines the root URL containing the glow layer information
  107278. * @returns a parsed Glow Layer
  107279. */
  107280. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107281. }
  107282. }
  107283. declare module BABYLON {
  107284. /** @hidden */
  107285. export var glowBlurPostProcessPixelShader: {
  107286. name: string;
  107287. shader: string;
  107288. };
  107289. }
  107290. declare module BABYLON {
  107291. interface AbstractScene {
  107292. /**
  107293. * Return a the first highlight layer of the scene with a given name.
  107294. * @param name The name of the highlight layer to look for.
  107295. * @return The highlight layer if found otherwise null.
  107296. */
  107297. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107298. }
  107299. /**
  107300. * Highlight layer options. This helps customizing the behaviour
  107301. * of the highlight layer.
  107302. */
  107303. export interface IHighlightLayerOptions {
  107304. /**
  107305. * Multiplication factor apply to the canvas size to compute the render target size
  107306. * used to generated the glowing objects (the smaller the faster).
  107307. */
  107308. mainTextureRatio: number;
  107309. /**
  107310. * Enforces a fixed size texture to ensure resize independant blur.
  107311. */
  107312. mainTextureFixedSize?: number;
  107313. /**
  107314. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107315. * of the picture to blur (the smaller the faster).
  107316. */
  107317. blurTextureSizeRatio: number;
  107318. /**
  107319. * How big in texel of the blur texture is the vertical blur.
  107320. */
  107321. blurVerticalSize: number;
  107322. /**
  107323. * How big in texel of the blur texture is the horizontal blur.
  107324. */
  107325. blurHorizontalSize: number;
  107326. /**
  107327. * Alpha blending mode used to apply the blur. Default is combine.
  107328. */
  107329. alphaBlendingMode: number;
  107330. /**
  107331. * The camera attached to the layer.
  107332. */
  107333. camera: Nullable<Camera>;
  107334. /**
  107335. * Should we display highlight as a solid stroke?
  107336. */
  107337. isStroke?: boolean;
  107338. /**
  107339. * The rendering group to draw the layer in.
  107340. */
  107341. renderingGroupId: number;
  107342. }
  107343. /**
  107344. * The highlight layer Helps adding a glow effect around a mesh.
  107345. *
  107346. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107347. * glowy meshes to your scene.
  107348. *
  107349. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107350. */
  107351. export class HighlightLayer extends EffectLayer {
  107352. name: string;
  107353. /**
  107354. * Effect Name of the highlight layer.
  107355. */
  107356. static readonly EffectName: string;
  107357. /**
  107358. * The neutral color used during the preparation of the glow effect.
  107359. * This is black by default as the blend operation is a blend operation.
  107360. */
  107361. static NeutralColor: Color4;
  107362. /**
  107363. * Stencil value used for glowing meshes.
  107364. */
  107365. static GlowingMeshStencilReference: number;
  107366. /**
  107367. * Stencil value used for the other meshes in the scene.
  107368. */
  107369. static NormalMeshStencilReference: number;
  107370. /**
  107371. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107372. */
  107373. innerGlow: boolean;
  107374. /**
  107375. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107376. */
  107377. outerGlow: boolean;
  107378. /**
  107379. * Specifies the horizontal size of the blur.
  107380. */
  107381. /**
  107382. * Gets the horizontal size of the blur.
  107383. */
  107384. blurHorizontalSize: number;
  107385. /**
  107386. * Specifies the vertical size of the blur.
  107387. */
  107388. /**
  107389. * Gets the vertical size of the blur.
  107390. */
  107391. blurVerticalSize: number;
  107392. /**
  107393. * An event triggered when the highlight layer is being blurred.
  107394. */
  107395. onBeforeBlurObservable: Observable<HighlightLayer>;
  107396. /**
  107397. * An event triggered when the highlight layer has been blurred.
  107398. */
  107399. onAfterBlurObservable: Observable<HighlightLayer>;
  107400. private _instanceGlowingMeshStencilReference;
  107401. private _options;
  107402. private _downSamplePostprocess;
  107403. private _horizontalBlurPostprocess;
  107404. private _verticalBlurPostprocess;
  107405. private _blurTexture;
  107406. private _meshes;
  107407. private _excludedMeshes;
  107408. /**
  107409. * Instantiates a new highlight Layer and references it to the scene..
  107410. * @param name The name of the layer
  107411. * @param scene The scene to use the layer in
  107412. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107413. */
  107414. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107415. /**
  107416. * Get the effect name of the layer.
  107417. * @return The effect name
  107418. */
  107419. getEffectName(): string;
  107420. /**
  107421. * Create the merge effect. This is the shader use to blit the information back
  107422. * to the main canvas at the end of the scene rendering.
  107423. */
  107424. protected _createMergeEffect(): Effect;
  107425. /**
  107426. * Creates the render target textures and post processes used in the highlight layer.
  107427. */
  107428. protected _createTextureAndPostProcesses(): void;
  107429. /**
  107430. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107431. */
  107432. needStencil(): boolean;
  107433. /**
  107434. * Checks for the readiness of the element composing the layer.
  107435. * @param subMesh the mesh to check for
  107436. * @param useInstances specify wether or not to use instances to render the mesh
  107437. * @param emissiveTexture the associated emissive texture used to generate the glow
  107438. * @return true if ready otherwise, false
  107439. */
  107440. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107441. /**
  107442. * Implementation specific of rendering the generating effect on the main canvas.
  107443. * @param effect The effect used to render through
  107444. */
  107445. protected _internalRender(effect: Effect): void;
  107446. /**
  107447. * Returns true if the layer contains information to display, otherwise false.
  107448. */
  107449. shouldRender(): boolean;
  107450. /**
  107451. * Returns true if the mesh should render, otherwise false.
  107452. * @param mesh The mesh to render
  107453. * @returns true if it should render otherwise false
  107454. */
  107455. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107456. /**
  107457. * Sets the required values for both the emissive texture and and the main color.
  107458. */
  107459. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107460. /**
  107461. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107462. * @param mesh The mesh to exclude from the highlight layer
  107463. */
  107464. addExcludedMesh(mesh: Mesh): void;
  107465. /**
  107466. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107467. * @param mesh The mesh to highlight
  107468. */
  107469. removeExcludedMesh(mesh: Mesh): void;
  107470. /**
  107471. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107472. * @param mesh mesh to test
  107473. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107474. */
  107475. hasMesh(mesh: AbstractMesh): boolean;
  107476. /**
  107477. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107478. * @param mesh The mesh to highlight
  107479. * @param color The color of the highlight
  107480. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107481. */
  107482. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107483. /**
  107484. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107485. * @param mesh The mesh to highlight
  107486. */
  107487. removeMesh(mesh: Mesh): void;
  107488. /**
  107489. * Force the stencil to the normal expected value for none glowing parts
  107490. */
  107491. private _defaultStencilReference;
  107492. /**
  107493. * Free any resources and references associated to a mesh.
  107494. * Internal use
  107495. * @param mesh The mesh to free.
  107496. * @hidden
  107497. */
  107498. _disposeMesh(mesh: Mesh): void;
  107499. /**
  107500. * Dispose the highlight layer and free resources.
  107501. */
  107502. dispose(): void;
  107503. /**
  107504. * Gets the class name of the effect layer
  107505. * @returns the string with the class name of the effect layer
  107506. */
  107507. getClassName(): string;
  107508. /**
  107509. * Serializes this Highlight layer
  107510. * @returns a serialized Highlight layer object
  107511. */
  107512. serialize(): any;
  107513. /**
  107514. * Creates a Highlight layer from parsed Highlight layer data
  107515. * @param parsedHightlightLayer defines the Highlight layer data
  107516. * @param scene defines the current scene
  107517. * @param rootUrl defines the root URL containing the Highlight layer information
  107518. * @returns a parsed Highlight layer
  107519. */
  107520. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107521. }
  107522. }
  107523. declare module BABYLON {
  107524. /** @hidden */
  107525. export var lensFlarePixelShader: {
  107526. name: string;
  107527. shader: string;
  107528. };
  107529. }
  107530. declare module BABYLON {
  107531. /** @hidden */
  107532. export var lensFlareVertexShader: {
  107533. name: string;
  107534. shader: string;
  107535. };
  107536. }
  107537. declare module BABYLON {
  107538. /**
  107539. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107540. * It is usually composed of several `lensFlare`.
  107541. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107542. */
  107543. export class LensFlareSystem {
  107544. /**
  107545. * Define the name of the lens flare system
  107546. */
  107547. name: string;
  107548. /**
  107549. * List of lens flares used in this system.
  107550. */
  107551. lensFlares: LensFlare[];
  107552. /**
  107553. * Define a limit from the border the lens flare can be visible.
  107554. */
  107555. borderLimit: number;
  107556. /**
  107557. * Define a viewport border we do not want to see the lens flare in.
  107558. */
  107559. viewportBorder: number;
  107560. /**
  107561. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107562. */
  107563. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107564. /**
  107565. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107566. */
  107567. layerMask: number;
  107568. /**
  107569. * Define the id of the lens flare system in the scene.
  107570. * (equal to name by default)
  107571. */
  107572. id: string;
  107573. private _scene;
  107574. private _emitter;
  107575. private _vertexBuffers;
  107576. private _indexBuffer;
  107577. private _effect;
  107578. private _positionX;
  107579. private _positionY;
  107580. private _isEnabled;
  107581. /** @hidden */
  107582. static _SceneComponentInitialization: (scene: Scene) => void;
  107583. /**
  107584. * Instantiates a lens flare system.
  107585. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107586. * It is usually composed of several `lensFlare`.
  107587. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107588. * @param name Define the name of the lens flare system in the scene
  107589. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107590. * @param scene Define the scene the lens flare system belongs to
  107591. */
  107592. constructor(
  107593. /**
  107594. * Define the name of the lens flare system
  107595. */
  107596. name: string, emitter: any, scene: Scene);
  107597. /**
  107598. * Define if the lens flare system is enabled.
  107599. */
  107600. isEnabled: boolean;
  107601. /**
  107602. * Get the scene the effects belongs to.
  107603. * @returns the scene holding the lens flare system
  107604. */
  107605. getScene(): Scene;
  107606. /**
  107607. * Get the emitter of the lens flare system.
  107608. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107609. * @returns the emitter of the lens flare system
  107610. */
  107611. getEmitter(): any;
  107612. /**
  107613. * Set the emitter of the lens flare system.
  107614. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107615. * @param newEmitter Define the new emitter of the system
  107616. */
  107617. setEmitter(newEmitter: any): void;
  107618. /**
  107619. * Get the lens flare system emitter position.
  107620. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107621. * @returns the position
  107622. */
  107623. getEmitterPosition(): Vector3;
  107624. /**
  107625. * @hidden
  107626. */
  107627. computeEffectivePosition(globalViewport: Viewport): boolean;
  107628. /** @hidden */
  107629. _isVisible(): boolean;
  107630. /**
  107631. * @hidden
  107632. */
  107633. render(): boolean;
  107634. /**
  107635. * Dispose and release the lens flare with its associated resources.
  107636. */
  107637. dispose(): void;
  107638. /**
  107639. * Parse a lens flare system from a JSON repressentation
  107640. * @param parsedLensFlareSystem Define the JSON to parse
  107641. * @param scene Define the scene the parsed system should be instantiated in
  107642. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107643. * @returns the parsed system
  107644. */
  107645. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107646. /**
  107647. * Serialize the current Lens Flare System into a JSON representation.
  107648. * @returns the serialized JSON
  107649. */
  107650. serialize(): any;
  107651. }
  107652. }
  107653. declare module BABYLON {
  107654. /**
  107655. * This represents one of the lens effect in a `lensFlareSystem`.
  107656. * It controls one of the indiviual texture used in the effect.
  107657. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107658. */
  107659. export class LensFlare {
  107660. /**
  107661. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107662. */
  107663. size: number;
  107664. /**
  107665. * 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.
  107666. */
  107667. position: number;
  107668. /**
  107669. * Define the lens color.
  107670. */
  107671. color: Color3;
  107672. /**
  107673. * Define the lens texture.
  107674. */
  107675. texture: Nullable<Texture>;
  107676. /**
  107677. * Define the alpha mode to render this particular lens.
  107678. */
  107679. alphaMode: number;
  107680. private _system;
  107681. /**
  107682. * Creates a new Lens Flare.
  107683. * This represents one of the lens effect in a `lensFlareSystem`.
  107684. * It controls one of the indiviual texture used in the effect.
  107685. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107686. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107687. * @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.
  107688. * @param color Define the lens color
  107689. * @param imgUrl Define the lens texture url
  107690. * @param system Define the `lensFlareSystem` this flare is part of
  107691. * @returns The newly created Lens Flare
  107692. */
  107693. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107694. /**
  107695. * Instantiates a new Lens Flare.
  107696. * This represents one of the lens effect in a `lensFlareSystem`.
  107697. * It controls one of the indiviual texture used in the effect.
  107698. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107699. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107700. * @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.
  107701. * @param color Define the lens color
  107702. * @param imgUrl Define the lens texture url
  107703. * @param system Define the `lensFlareSystem` this flare is part of
  107704. */
  107705. constructor(
  107706. /**
  107707. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107708. */
  107709. size: number,
  107710. /**
  107711. * 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.
  107712. */
  107713. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107714. /**
  107715. * Dispose and release the lens flare with its associated resources.
  107716. */
  107717. dispose(): void;
  107718. }
  107719. }
  107720. declare module BABYLON {
  107721. interface AbstractScene {
  107722. /**
  107723. * The list of lens flare system added to the scene
  107724. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107725. */
  107726. lensFlareSystems: Array<LensFlareSystem>;
  107727. /**
  107728. * Removes the given lens flare system from this scene.
  107729. * @param toRemove The lens flare system to remove
  107730. * @returns The index of the removed lens flare system
  107731. */
  107732. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107733. /**
  107734. * Adds the given lens flare system to this scene
  107735. * @param newLensFlareSystem The lens flare system to add
  107736. */
  107737. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107738. /**
  107739. * Gets a lens flare system using its name
  107740. * @param name defines the name to look for
  107741. * @returns the lens flare system or null if not found
  107742. */
  107743. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107744. /**
  107745. * Gets a lens flare system using its id
  107746. * @param id defines the id to look for
  107747. * @returns the lens flare system or null if not found
  107748. */
  107749. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107750. }
  107751. /**
  107752. * Defines the lens flare scene component responsible to manage any lens flares
  107753. * in a given scene.
  107754. */
  107755. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107756. /**
  107757. * The component name helpfull to identify the component in the list of scene components.
  107758. */
  107759. readonly name: string;
  107760. /**
  107761. * The scene the component belongs to.
  107762. */
  107763. scene: Scene;
  107764. /**
  107765. * Creates a new instance of the component for the given scene
  107766. * @param scene Defines the scene to register the component in
  107767. */
  107768. constructor(scene: Scene);
  107769. /**
  107770. * Registers the component in a given scene
  107771. */
  107772. register(): void;
  107773. /**
  107774. * Rebuilds the elements related to this component in case of
  107775. * context lost for instance.
  107776. */
  107777. rebuild(): void;
  107778. /**
  107779. * Adds all the element from the container to the scene
  107780. * @param container the container holding the elements
  107781. */
  107782. addFromContainer(container: AbstractScene): void;
  107783. /**
  107784. * Removes all the elements in the container from the scene
  107785. * @param container contains the elements to remove
  107786. * @param dispose if the removed element should be disposed (default: false)
  107787. */
  107788. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107789. /**
  107790. * Serializes the component data to the specified json object
  107791. * @param serializationObject The object to serialize to
  107792. */
  107793. serialize(serializationObject: any): void;
  107794. /**
  107795. * Disposes the component and the associated ressources.
  107796. */
  107797. dispose(): void;
  107798. private _draw;
  107799. }
  107800. }
  107801. declare module BABYLON {
  107802. /**
  107803. * Defines the shadow generator component responsible to manage any shadow generators
  107804. * in a given scene.
  107805. */
  107806. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107807. /**
  107808. * The component name helpfull to identify the component in the list of scene components.
  107809. */
  107810. readonly name: string;
  107811. /**
  107812. * The scene the component belongs to.
  107813. */
  107814. scene: Scene;
  107815. /**
  107816. * Creates a new instance of the component for the given scene
  107817. * @param scene Defines the scene to register the component in
  107818. */
  107819. constructor(scene: Scene);
  107820. /**
  107821. * Registers the component in a given scene
  107822. */
  107823. register(): void;
  107824. /**
  107825. * Rebuilds the elements related to this component in case of
  107826. * context lost for instance.
  107827. */
  107828. rebuild(): void;
  107829. /**
  107830. * Serializes the component data to the specified json object
  107831. * @param serializationObject The object to serialize to
  107832. */
  107833. serialize(serializationObject: any): void;
  107834. /**
  107835. * Adds all the element from the container to the scene
  107836. * @param container the container holding the elements
  107837. */
  107838. addFromContainer(container: AbstractScene): void;
  107839. /**
  107840. * Removes all the elements in the container from the scene
  107841. * @param container contains the elements to remove
  107842. * @param dispose if the removed element should be disposed (default: false)
  107843. */
  107844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107845. /**
  107846. * Rebuilds the elements related to this component in case of
  107847. * context lost for instance.
  107848. */
  107849. dispose(): void;
  107850. private _gatherRenderTargets;
  107851. }
  107852. }
  107853. declare module BABYLON {
  107854. /**
  107855. * A point light is a light defined by an unique point in world space.
  107856. * The light is emitted in every direction from this point.
  107857. * A good example of a point light is a standard light bulb.
  107858. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107859. */
  107860. export class PointLight extends ShadowLight {
  107861. private _shadowAngle;
  107862. /**
  107863. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107864. * This specifies what angle the shadow will use to be created.
  107865. *
  107866. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107867. */
  107868. /**
  107869. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107870. * This specifies what angle the shadow will use to be created.
  107871. *
  107872. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107873. */
  107874. shadowAngle: number;
  107875. /**
  107876. * Gets the direction if it has been set.
  107877. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107878. */
  107879. /**
  107880. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107881. */
  107882. direction: Vector3;
  107883. /**
  107884. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107885. * A PointLight emits the light in every direction.
  107886. * It can cast shadows.
  107887. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107888. * ```javascript
  107889. * var pointLight = new PointLight("pl", camera.position, scene);
  107890. * ```
  107891. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107892. * @param name The light friendly name
  107893. * @param position The position of the point light in the scene
  107894. * @param scene The scene the lights belongs to
  107895. */
  107896. constructor(name: string, position: Vector3, scene: Scene);
  107897. /**
  107898. * Returns the string "PointLight"
  107899. * @returns the class name
  107900. */
  107901. getClassName(): string;
  107902. /**
  107903. * Returns the integer 0.
  107904. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107905. */
  107906. getTypeID(): number;
  107907. /**
  107908. * Specifies wether or not the shadowmap should be a cube texture.
  107909. * @returns true if the shadowmap needs to be a cube texture.
  107910. */
  107911. needCube(): boolean;
  107912. /**
  107913. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107914. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107915. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107916. */
  107917. getShadowDirection(faceIndex?: number): Vector3;
  107918. /**
  107919. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107920. * - fov = PI / 2
  107921. * - aspect ratio : 1.0
  107922. * - z-near and far equal to the active camera minZ and maxZ.
  107923. * Returns the PointLight.
  107924. */
  107925. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107926. protected _buildUniformLayout(): void;
  107927. /**
  107928. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107929. * @param effect The effect to update
  107930. * @param lightIndex The index of the light in the effect to update
  107931. * @returns The point light
  107932. */
  107933. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107934. /**
  107935. * Prepares the list of defines specific to the light type.
  107936. * @param defines the list of defines
  107937. * @param lightIndex defines the index of the light for the effect
  107938. */
  107939. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107940. }
  107941. }
  107942. declare module BABYLON {
  107943. /**
  107944. * Header information of HDR texture files.
  107945. */
  107946. export interface HDRInfo {
  107947. /**
  107948. * The height of the texture in pixels.
  107949. */
  107950. height: number;
  107951. /**
  107952. * The width of the texture in pixels.
  107953. */
  107954. width: number;
  107955. /**
  107956. * The index of the beginning of the data in the binary file.
  107957. */
  107958. dataPosition: number;
  107959. }
  107960. /**
  107961. * This groups tools to convert HDR texture to native colors array.
  107962. */
  107963. export class HDRTools {
  107964. private static Ldexp;
  107965. private static Rgbe2float;
  107966. private static readStringLine;
  107967. /**
  107968. * Reads header information from an RGBE texture stored in a native array.
  107969. * More information on this format are available here:
  107970. * https://en.wikipedia.org/wiki/RGBE_image_format
  107971. *
  107972. * @param uint8array The binary file stored in native array.
  107973. * @return The header information.
  107974. */
  107975. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107976. /**
  107977. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107978. * This RGBE texture needs to store the information as a panorama.
  107979. *
  107980. * More information on this format are available here:
  107981. * https://en.wikipedia.org/wiki/RGBE_image_format
  107982. *
  107983. * @param buffer The binary file stored in an array buffer.
  107984. * @param size The expected size of the extracted cubemap.
  107985. * @return The Cube Map information.
  107986. */
  107987. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107988. /**
  107989. * Returns the pixels data extracted from an RGBE texture.
  107990. * This pixels will be stored left to right up to down in the R G B order in one array.
  107991. *
  107992. * More information on this format are available here:
  107993. * https://en.wikipedia.org/wiki/RGBE_image_format
  107994. *
  107995. * @param uint8array The binary file stored in an array buffer.
  107996. * @param hdrInfo The header information of the file.
  107997. * @return The pixels data in RGB right to left up to down order.
  107998. */
  107999. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  108000. private static RGBE_ReadPixels_RLE;
  108001. }
  108002. }
  108003. declare module BABYLON {
  108004. /**
  108005. * This represents a texture coming from an HDR input.
  108006. *
  108007. * The only supported format is currently panorama picture stored in RGBE format.
  108008. * Example of such files can be found on HDRLib: http://hdrlib.com/
  108009. */
  108010. export class HDRCubeTexture extends BaseTexture {
  108011. private static _facesMapping;
  108012. private _generateHarmonics;
  108013. private _noMipmap;
  108014. private _textureMatrix;
  108015. private _size;
  108016. private _onLoad;
  108017. private _onError;
  108018. /**
  108019. * The texture URL.
  108020. */
  108021. url: string;
  108022. /**
  108023. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  108024. */
  108025. coordinatesMode: number;
  108026. protected _isBlocking: boolean;
  108027. /**
  108028. * Sets wether or not the texture is blocking during loading.
  108029. */
  108030. /**
  108031. * Gets wether or not the texture is blocking during loading.
  108032. */
  108033. isBlocking: boolean;
  108034. protected _rotationY: number;
  108035. /**
  108036. * Sets texture matrix rotation angle around Y axis in radians.
  108037. */
  108038. /**
  108039. * Gets texture matrix rotation angle around Y axis radians.
  108040. */
  108041. rotationY: number;
  108042. /**
  108043. * Gets or sets the center of the bounding box associated with the cube texture
  108044. * It must define where the camera used to render the texture was set
  108045. */
  108046. boundingBoxPosition: Vector3;
  108047. private _boundingBoxSize;
  108048. /**
  108049. * Gets or sets the size of the bounding box associated with the cube texture
  108050. * When defined, the cubemap will switch to local mode
  108051. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108052. * @example https://www.babylonjs-playground.com/#RNASML
  108053. */
  108054. boundingBoxSize: Vector3;
  108055. /**
  108056. * Instantiates an HDRTexture from the following parameters.
  108057. *
  108058. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108059. * @param scene The scene the texture will be used in
  108060. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108061. * @param noMipmap Forces to not generate the mipmap if true
  108062. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108063. * @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)
  108064. * @param reserved Reserved flag for internal use.
  108065. */
  108066. 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>);
  108067. /**
  108068. * Get the current class name of the texture useful for serialization or dynamic coding.
  108069. * @returns "HDRCubeTexture"
  108070. */
  108071. getClassName(): string;
  108072. /**
  108073. * Occurs when the file is raw .hdr file.
  108074. */
  108075. private loadTexture;
  108076. clone(): HDRCubeTexture;
  108077. delayLoad(): void;
  108078. /**
  108079. * Get the texture reflection matrix used to rotate/transform the reflection.
  108080. * @returns the reflection matrix
  108081. */
  108082. getReflectionTextureMatrix(): Matrix;
  108083. /**
  108084. * Set the texture reflection matrix used to rotate/transform the reflection.
  108085. * @param value Define the reflection matrix to set
  108086. */
  108087. setReflectionTextureMatrix(value: Matrix): void;
  108088. /**
  108089. * Parses a JSON representation of an HDR Texture in order to create the texture
  108090. * @param parsedTexture Define the JSON representation
  108091. * @param scene Define the scene the texture should be created in
  108092. * @param rootUrl Define the root url in case we need to load relative dependencies
  108093. * @returns the newly created texture after parsing
  108094. */
  108095. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108096. serialize(): any;
  108097. }
  108098. }
  108099. declare module BABYLON {
  108100. /**
  108101. * Class used to control physics engine
  108102. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108103. */
  108104. export class PhysicsEngine implements IPhysicsEngine {
  108105. private _physicsPlugin;
  108106. /**
  108107. * Global value used to control the smallest number supported by the simulation
  108108. */
  108109. static Epsilon: number;
  108110. private _impostors;
  108111. private _joints;
  108112. /**
  108113. * Gets the gravity vector used by the simulation
  108114. */
  108115. gravity: Vector3;
  108116. /**
  108117. * Factory used to create the default physics plugin.
  108118. * @returns The default physics plugin
  108119. */
  108120. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108121. /**
  108122. * Creates a new Physics Engine
  108123. * @param gravity defines the gravity vector used by the simulation
  108124. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108125. */
  108126. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108127. /**
  108128. * Sets the gravity vector used by the simulation
  108129. * @param gravity defines the gravity vector to use
  108130. */
  108131. setGravity(gravity: Vector3): void;
  108132. /**
  108133. * Set the time step of the physics engine.
  108134. * Default is 1/60.
  108135. * To slow it down, enter 1/600 for example.
  108136. * To speed it up, 1/30
  108137. * @param newTimeStep defines the new timestep to apply to this world.
  108138. */
  108139. setTimeStep(newTimeStep?: number): void;
  108140. /**
  108141. * Get the time step of the physics engine.
  108142. * @returns the current time step
  108143. */
  108144. getTimeStep(): number;
  108145. /**
  108146. * Release all resources
  108147. */
  108148. dispose(): void;
  108149. /**
  108150. * Gets the name of the current physics plugin
  108151. * @returns the name of the plugin
  108152. */
  108153. getPhysicsPluginName(): string;
  108154. /**
  108155. * Adding a new impostor for the impostor tracking.
  108156. * This will be done by the impostor itself.
  108157. * @param impostor the impostor to add
  108158. */
  108159. addImpostor(impostor: PhysicsImpostor): void;
  108160. /**
  108161. * Remove an impostor from the engine.
  108162. * This impostor and its mesh will not longer be updated by the physics engine.
  108163. * @param impostor the impostor to remove
  108164. */
  108165. removeImpostor(impostor: PhysicsImpostor): void;
  108166. /**
  108167. * Add a joint to the physics engine
  108168. * @param mainImpostor defines the main impostor to which the joint is added.
  108169. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108170. * @param joint defines the joint that will connect both impostors.
  108171. */
  108172. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108173. /**
  108174. * Removes a joint from the simulation
  108175. * @param mainImpostor defines the impostor used with the joint
  108176. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108177. * @param joint defines the joint to remove
  108178. */
  108179. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108180. /**
  108181. * Called by the scene. No need to call it.
  108182. * @param delta defines the timespam between frames
  108183. */
  108184. _step(delta: number): void;
  108185. /**
  108186. * Gets the current plugin used to run the simulation
  108187. * @returns current plugin
  108188. */
  108189. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108190. /**
  108191. * Gets the list of physic impostors
  108192. * @returns an array of PhysicsImpostor
  108193. */
  108194. getImpostors(): Array<PhysicsImpostor>;
  108195. /**
  108196. * Gets the impostor for a physics enabled object
  108197. * @param object defines the object impersonated by the impostor
  108198. * @returns the PhysicsImpostor or null if not found
  108199. */
  108200. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108201. /**
  108202. * Gets the impostor for a physics body object
  108203. * @param body defines physics body used by the impostor
  108204. * @returns the PhysicsImpostor or null if not found
  108205. */
  108206. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108207. /**
  108208. * Does a raycast in the physics world
  108209. * @param from when should the ray start?
  108210. * @param to when should the ray end?
  108211. * @returns PhysicsRaycastResult
  108212. */
  108213. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108214. }
  108215. }
  108216. declare module BABYLON {
  108217. /** @hidden */
  108218. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108219. private _useDeltaForWorldStep;
  108220. world: any;
  108221. name: string;
  108222. private _physicsMaterials;
  108223. private _fixedTimeStep;
  108224. private _cannonRaycastResult;
  108225. private _raycastResult;
  108226. private _removeAfterStep;
  108227. BJSCANNON: any;
  108228. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108229. setGravity(gravity: Vector3): void;
  108230. setTimeStep(timeStep: number): void;
  108231. getTimeStep(): number;
  108232. executeStep(delta: number): void;
  108233. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108234. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108235. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108236. private _processChildMeshes;
  108237. removePhysicsBody(impostor: PhysicsImpostor): void;
  108238. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108239. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108240. private _addMaterial;
  108241. private _checkWithEpsilon;
  108242. private _createShape;
  108243. private _createHeightmap;
  108244. private _minus90X;
  108245. private _plus90X;
  108246. private _tmpPosition;
  108247. private _tmpDeltaPosition;
  108248. private _tmpUnityRotation;
  108249. private _updatePhysicsBodyTransformation;
  108250. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108251. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108252. isSupported(): boolean;
  108253. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108254. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108255. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108256. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108257. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108258. getBodyMass(impostor: PhysicsImpostor): number;
  108259. getBodyFriction(impostor: PhysicsImpostor): number;
  108260. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108261. getBodyRestitution(impostor: PhysicsImpostor): number;
  108262. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108263. sleepBody(impostor: PhysicsImpostor): void;
  108264. wakeUpBody(impostor: PhysicsImpostor): void;
  108265. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108266. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108267. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108268. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108269. getRadius(impostor: PhysicsImpostor): number;
  108270. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108271. dispose(): void;
  108272. private _extendNamespace;
  108273. /**
  108274. * Does a raycast in the physics world
  108275. * @param from when should the ray start?
  108276. * @param to when should the ray end?
  108277. * @returns PhysicsRaycastResult
  108278. */
  108279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108280. }
  108281. }
  108282. declare module BABYLON {
  108283. /** @hidden */
  108284. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108285. world: any;
  108286. name: string;
  108287. BJSOIMO: any;
  108288. private _raycastResult;
  108289. constructor(iterations?: number, oimoInjection?: any);
  108290. setGravity(gravity: Vector3): void;
  108291. setTimeStep(timeStep: number): void;
  108292. getTimeStep(): number;
  108293. private _tmpImpostorsArray;
  108294. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108295. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108296. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108297. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108298. private _tmpPositionVector;
  108299. removePhysicsBody(impostor: PhysicsImpostor): void;
  108300. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108301. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108302. isSupported(): boolean;
  108303. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108304. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108305. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108306. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108307. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108308. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108309. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108310. getBodyMass(impostor: PhysicsImpostor): number;
  108311. getBodyFriction(impostor: PhysicsImpostor): number;
  108312. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108313. getBodyRestitution(impostor: PhysicsImpostor): number;
  108314. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108315. sleepBody(impostor: PhysicsImpostor): void;
  108316. wakeUpBody(impostor: PhysicsImpostor): void;
  108317. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108318. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108319. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108320. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108321. getRadius(impostor: PhysicsImpostor): number;
  108322. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108323. dispose(): void;
  108324. /**
  108325. * Does a raycast in the physics world
  108326. * @param from when should the ray start?
  108327. * @param to when should the ray end?
  108328. * @returns PhysicsRaycastResult
  108329. */
  108330. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108331. }
  108332. }
  108333. declare module BABYLON {
  108334. /**
  108335. * Class containing static functions to help procedurally build meshes
  108336. */
  108337. export class RibbonBuilder {
  108338. /**
  108339. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108340. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108341. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108342. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108343. * * 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
  108344. * * 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
  108345. * * 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
  108346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108348. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108349. * * 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
  108350. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108351. * * 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
  108352. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108354. * @param name defines the name of the mesh
  108355. * @param options defines the options used to create the mesh
  108356. * @param scene defines the hosting scene
  108357. * @returns the ribbon mesh
  108358. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108359. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108360. */
  108361. static CreateRibbon(name: string, options: {
  108362. pathArray: Vector3[][];
  108363. closeArray?: boolean;
  108364. closePath?: boolean;
  108365. offset?: number;
  108366. updatable?: boolean;
  108367. sideOrientation?: number;
  108368. frontUVs?: Vector4;
  108369. backUVs?: Vector4;
  108370. instance?: Mesh;
  108371. invertUV?: boolean;
  108372. uvs?: Vector2[];
  108373. colors?: Color4[];
  108374. }, scene?: Nullable<Scene>): Mesh;
  108375. }
  108376. }
  108377. declare module BABYLON {
  108378. /**
  108379. * Class containing static functions to help procedurally build meshes
  108380. */
  108381. export class ShapeBuilder {
  108382. /**
  108383. * 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.
  108384. * * 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.
  108385. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108386. * * 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.
  108387. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108388. * * 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
  108389. * * 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
  108390. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108395. * @param name defines the name of the mesh
  108396. * @param options defines the options used to create the mesh
  108397. * @param scene defines the hosting scene
  108398. * @returns the extruded shape mesh
  108399. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108401. */
  108402. static ExtrudeShape(name: string, options: {
  108403. shape: Vector3[];
  108404. path: Vector3[];
  108405. scale?: number;
  108406. rotation?: number;
  108407. cap?: number;
  108408. updatable?: boolean;
  108409. sideOrientation?: number;
  108410. frontUVs?: Vector4;
  108411. backUVs?: Vector4;
  108412. instance?: Mesh;
  108413. invertUV?: boolean;
  108414. }, scene?: Nullable<Scene>): Mesh;
  108415. /**
  108416. * Creates an custom extruded shape mesh.
  108417. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108418. * * 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.
  108419. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108420. * * 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
  108421. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108422. * * 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
  108423. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108424. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108425. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108426. * * 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
  108427. * * 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
  108428. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108431. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108433. * @param name defines the name of the mesh
  108434. * @param options defines the options used to create the mesh
  108435. * @param scene defines the hosting scene
  108436. * @returns the custom extruded shape mesh
  108437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108438. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108440. */
  108441. static ExtrudeShapeCustom(name: string, options: {
  108442. shape: Vector3[];
  108443. path: Vector3[];
  108444. scaleFunction?: any;
  108445. rotationFunction?: any;
  108446. ribbonCloseArray?: boolean;
  108447. ribbonClosePath?: boolean;
  108448. cap?: number;
  108449. updatable?: boolean;
  108450. sideOrientation?: number;
  108451. frontUVs?: Vector4;
  108452. backUVs?: Vector4;
  108453. instance?: Mesh;
  108454. invertUV?: boolean;
  108455. }, scene?: Nullable<Scene>): Mesh;
  108456. private static _ExtrudeShapeGeneric;
  108457. }
  108458. }
  108459. declare module BABYLON {
  108460. /**
  108461. * AmmoJS Physics plugin
  108462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108463. * @see https://github.com/kripken/ammo.js/
  108464. */
  108465. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108466. private _useDeltaForWorldStep;
  108467. /**
  108468. * Reference to the Ammo library
  108469. */
  108470. bjsAMMO: any;
  108471. /**
  108472. * Created ammoJS world which physics bodies are added to
  108473. */
  108474. world: any;
  108475. /**
  108476. * Name of the plugin
  108477. */
  108478. name: string;
  108479. private _timeStep;
  108480. private _fixedTimeStep;
  108481. private _maxSteps;
  108482. private _tmpQuaternion;
  108483. private _tmpAmmoTransform;
  108484. private _tmpAmmoQuaternion;
  108485. private _tmpAmmoConcreteContactResultCallback;
  108486. private _collisionConfiguration;
  108487. private _dispatcher;
  108488. private _overlappingPairCache;
  108489. private _solver;
  108490. private _softBodySolver;
  108491. private _tmpAmmoVectorA;
  108492. private _tmpAmmoVectorB;
  108493. private _tmpAmmoVectorC;
  108494. private _tmpAmmoVectorD;
  108495. private _tmpContactCallbackResult;
  108496. private _tmpAmmoVectorRCA;
  108497. private _tmpAmmoVectorRCB;
  108498. private _raycastResult;
  108499. private static readonly DISABLE_COLLISION_FLAG;
  108500. private static readonly KINEMATIC_FLAG;
  108501. private static readonly DISABLE_DEACTIVATION_FLAG;
  108502. /**
  108503. * Initializes the ammoJS plugin
  108504. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108505. * @param ammoInjection can be used to inject your own ammo reference
  108506. */
  108507. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108508. /**
  108509. * Sets the gravity of the physics world (m/(s^2))
  108510. * @param gravity Gravity to set
  108511. */
  108512. setGravity(gravity: Vector3): void;
  108513. /**
  108514. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108515. * @param timeStep timestep to use in seconds
  108516. */
  108517. setTimeStep(timeStep: number): void;
  108518. /**
  108519. * 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)
  108520. * @param fixedTimeStep fixedTimeStep to use in seconds
  108521. */
  108522. setFixedTimeStep(fixedTimeStep: number): void;
  108523. /**
  108524. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108525. * @param maxSteps the maximum number of steps by the physics engine per frame
  108526. */
  108527. setMaxSteps(maxSteps: number): void;
  108528. /**
  108529. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108530. * @returns the current timestep in seconds
  108531. */
  108532. getTimeStep(): number;
  108533. private _isImpostorInContact;
  108534. private _isImpostorPairInContact;
  108535. private _stepSimulation;
  108536. /**
  108537. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108538. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108539. * After the step the babylon meshes are set to the position of the physics imposters
  108540. * @param delta amount of time to step forward
  108541. * @param impostors array of imposters to update before/after the step
  108542. */
  108543. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108544. /**
  108545. * Update babylon mesh to match physics world object
  108546. * @param impostor imposter to match
  108547. */
  108548. private _afterSoftStep;
  108549. /**
  108550. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108551. * @param impostor imposter to match
  108552. */
  108553. private _ropeStep;
  108554. /**
  108555. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108556. * @param impostor imposter to match
  108557. */
  108558. private _softbodyOrClothStep;
  108559. private _tmpVector;
  108560. private _tmpMatrix;
  108561. /**
  108562. * Applies an impulse on the imposter
  108563. * @param impostor imposter to apply impulse to
  108564. * @param force amount of force to be applied to the imposter
  108565. * @param contactPoint the location to apply the impulse on the imposter
  108566. */
  108567. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108568. /**
  108569. * Applies a force on the imposter
  108570. * @param impostor imposter to apply force
  108571. * @param force amount of force to be applied to the imposter
  108572. * @param contactPoint the location to apply the force on the imposter
  108573. */
  108574. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108575. /**
  108576. * Creates a physics body using the plugin
  108577. * @param impostor the imposter to create the physics body on
  108578. */
  108579. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108580. /**
  108581. * Removes the physics body from the imposter and disposes of the body's memory
  108582. * @param impostor imposter to remove the physics body from
  108583. */
  108584. removePhysicsBody(impostor: PhysicsImpostor): void;
  108585. /**
  108586. * Generates a joint
  108587. * @param impostorJoint the imposter joint to create the joint with
  108588. */
  108589. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108590. /**
  108591. * Removes a joint
  108592. * @param impostorJoint the imposter joint to remove the joint from
  108593. */
  108594. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108595. private _addMeshVerts;
  108596. /**
  108597. * Initialise the soft body vertices to match its object's (mesh) vertices
  108598. * Softbody vertices (nodes) are in world space and to match this
  108599. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108600. * @param impostor to create the softbody for
  108601. */
  108602. private _softVertexData;
  108603. /**
  108604. * Create an impostor's soft body
  108605. * @param impostor to create the softbody for
  108606. */
  108607. private _createSoftbody;
  108608. /**
  108609. * Create cloth for an impostor
  108610. * @param impostor to create the softbody for
  108611. */
  108612. private _createCloth;
  108613. /**
  108614. * Create rope for an impostor
  108615. * @param impostor to create the softbody for
  108616. */
  108617. private _createRope;
  108618. private _addHullVerts;
  108619. private _createShape;
  108620. /**
  108621. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108622. * @param impostor imposter containing the physics body and babylon object
  108623. */
  108624. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108625. /**
  108626. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108627. * @param impostor imposter containing the physics body and babylon object
  108628. * @param newPosition new position
  108629. * @param newRotation new rotation
  108630. */
  108631. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108632. /**
  108633. * If this plugin is supported
  108634. * @returns true if its supported
  108635. */
  108636. isSupported(): boolean;
  108637. /**
  108638. * Sets the linear velocity of the physics body
  108639. * @param impostor imposter to set the velocity on
  108640. * @param velocity velocity to set
  108641. */
  108642. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108643. /**
  108644. * Sets the angular velocity of the physics body
  108645. * @param impostor imposter to set the velocity on
  108646. * @param velocity velocity to set
  108647. */
  108648. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108649. /**
  108650. * gets the linear velocity
  108651. * @param impostor imposter to get linear velocity from
  108652. * @returns linear velocity
  108653. */
  108654. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108655. /**
  108656. * gets the angular velocity
  108657. * @param impostor imposter to get angular velocity from
  108658. * @returns angular velocity
  108659. */
  108660. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108661. /**
  108662. * Sets the mass of physics body
  108663. * @param impostor imposter to set the mass on
  108664. * @param mass mass to set
  108665. */
  108666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108667. /**
  108668. * Gets the mass of the physics body
  108669. * @param impostor imposter to get the mass from
  108670. * @returns mass
  108671. */
  108672. getBodyMass(impostor: PhysicsImpostor): number;
  108673. /**
  108674. * Gets friction of the impostor
  108675. * @param impostor impostor to get friction from
  108676. * @returns friction value
  108677. */
  108678. getBodyFriction(impostor: PhysicsImpostor): number;
  108679. /**
  108680. * Sets friction of the impostor
  108681. * @param impostor impostor to set friction on
  108682. * @param friction friction value
  108683. */
  108684. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108685. /**
  108686. * Gets restitution of the impostor
  108687. * @param impostor impostor to get restitution from
  108688. * @returns restitution value
  108689. */
  108690. getBodyRestitution(impostor: PhysicsImpostor): number;
  108691. /**
  108692. * Sets resitution of the impostor
  108693. * @param impostor impostor to set resitution on
  108694. * @param restitution resitution value
  108695. */
  108696. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108697. /**
  108698. * Gets pressure inside the impostor
  108699. * @param impostor impostor to get pressure from
  108700. * @returns pressure value
  108701. */
  108702. getBodyPressure(impostor: PhysicsImpostor): number;
  108703. /**
  108704. * Sets pressure inside a soft body impostor
  108705. * Cloth and rope must remain 0 pressure
  108706. * @param impostor impostor to set pressure on
  108707. * @param pressure pressure value
  108708. */
  108709. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108710. /**
  108711. * Gets stiffness of the impostor
  108712. * @param impostor impostor to get stiffness from
  108713. * @returns pressure value
  108714. */
  108715. getBodyStiffness(impostor: PhysicsImpostor): number;
  108716. /**
  108717. * Sets stiffness of the impostor
  108718. * @param impostor impostor to set stiffness on
  108719. * @param stiffness stiffness value from 0 to 1
  108720. */
  108721. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108722. /**
  108723. * Gets velocityIterations of the impostor
  108724. * @param impostor impostor to get velocity iterations from
  108725. * @returns velocityIterations value
  108726. */
  108727. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108728. /**
  108729. * Sets velocityIterations of the impostor
  108730. * @param impostor impostor to set velocity iterations on
  108731. * @param velocityIterations velocityIterations value
  108732. */
  108733. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108734. /**
  108735. * Gets positionIterations of the impostor
  108736. * @param impostor impostor to get position iterations from
  108737. * @returns positionIterations value
  108738. */
  108739. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108740. /**
  108741. * Sets positionIterations of the impostor
  108742. * @param impostor impostor to set position on
  108743. * @param positionIterations positionIterations value
  108744. */
  108745. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108746. /**
  108747. * Append an anchor to a cloth object
  108748. * @param impostor is the cloth impostor to add anchor to
  108749. * @param otherImpostor is the rigid impostor to anchor to
  108750. * @param width ratio across width from 0 to 1
  108751. * @param height ratio up height from 0 to 1
  108752. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108753. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108754. */
  108755. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108756. /**
  108757. * Append an hook to a rope object
  108758. * @param impostor is the rope impostor to add hook to
  108759. * @param otherImpostor is the rigid impostor to hook to
  108760. * @param length ratio along the rope from 0 to 1
  108761. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108762. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108763. */
  108764. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108765. /**
  108766. * Sleeps the physics body and stops it from being active
  108767. * @param impostor impostor to sleep
  108768. */
  108769. sleepBody(impostor: PhysicsImpostor): void;
  108770. /**
  108771. * Activates the physics body
  108772. * @param impostor impostor to activate
  108773. */
  108774. wakeUpBody(impostor: PhysicsImpostor): void;
  108775. /**
  108776. * Updates the distance parameters of the joint
  108777. * @param joint joint to update
  108778. * @param maxDistance maximum distance of the joint
  108779. * @param minDistance minimum distance of the joint
  108780. */
  108781. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108782. /**
  108783. * Sets a motor on the joint
  108784. * @param joint joint to set motor on
  108785. * @param speed speed of the motor
  108786. * @param maxForce maximum force of the motor
  108787. * @param motorIndex index of the motor
  108788. */
  108789. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108790. /**
  108791. * Sets the motors limit
  108792. * @param joint joint to set limit on
  108793. * @param upperLimit upper limit
  108794. * @param lowerLimit lower limit
  108795. */
  108796. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108797. /**
  108798. * Syncs the position and rotation of a mesh with the impostor
  108799. * @param mesh mesh to sync
  108800. * @param impostor impostor to update the mesh with
  108801. */
  108802. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108803. /**
  108804. * Gets the radius of the impostor
  108805. * @param impostor impostor to get radius from
  108806. * @returns the radius
  108807. */
  108808. getRadius(impostor: PhysicsImpostor): number;
  108809. /**
  108810. * Gets the box size of the impostor
  108811. * @param impostor impostor to get box size from
  108812. * @param result the resulting box size
  108813. */
  108814. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108815. /**
  108816. * Disposes of the impostor
  108817. */
  108818. dispose(): void;
  108819. /**
  108820. * Does a raycast in the physics world
  108821. * @param from when should the ray start?
  108822. * @param to when should the ray end?
  108823. * @returns PhysicsRaycastResult
  108824. */
  108825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108826. }
  108827. }
  108828. declare module BABYLON {
  108829. interface AbstractScene {
  108830. /**
  108831. * The list of reflection probes added to the scene
  108832. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108833. */
  108834. reflectionProbes: Array<ReflectionProbe>;
  108835. /**
  108836. * Removes the given reflection probe from this scene.
  108837. * @param toRemove The reflection probe to remove
  108838. * @returns The index of the removed reflection probe
  108839. */
  108840. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108841. /**
  108842. * Adds the given reflection probe to this scene.
  108843. * @param newReflectionProbe The reflection probe to add
  108844. */
  108845. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108846. }
  108847. /**
  108848. * Class used to generate realtime reflection / refraction cube textures
  108849. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108850. */
  108851. export class ReflectionProbe {
  108852. /** defines the name of the probe */
  108853. name: string;
  108854. private _scene;
  108855. private _renderTargetTexture;
  108856. private _projectionMatrix;
  108857. private _viewMatrix;
  108858. private _target;
  108859. private _add;
  108860. private _attachedMesh;
  108861. private _invertYAxis;
  108862. /** Gets or sets probe position (center of the cube map) */
  108863. position: Vector3;
  108864. /**
  108865. * Creates a new reflection probe
  108866. * @param name defines the name of the probe
  108867. * @param size defines the texture resolution (for each face)
  108868. * @param scene defines the hosting scene
  108869. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108870. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108871. */
  108872. constructor(
  108873. /** defines the name of the probe */
  108874. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108875. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108876. samples: number;
  108877. /** Gets or sets the refresh rate to use (on every frame by default) */
  108878. refreshRate: number;
  108879. /**
  108880. * Gets the hosting scene
  108881. * @returns a Scene
  108882. */
  108883. getScene(): Scene;
  108884. /** Gets the internal CubeTexture used to render to */
  108885. readonly cubeTexture: RenderTargetTexture;
  108886. /** Gets the list of meshes to render */
  108887. readonly renderList: Nullable<AbstractMesh[]>;
  108888. /**
  108889. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108890. * @param mesh defines the mesh to attach to
  108891. */
  108892. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108893. /**
  108894. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108895. * @param renderingGroupId The rendering group id corresponding to its index
  108896. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108897. */
  108898. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108899. /**
  108900. * Clean all associated resources
  108901. */
  108902. dispose(): void;
  108903. /**
  108904. * Converts the reflection probe information to a readable string for debug purpose.
  108905. * @param fullDetails Supports for multiple levels of logging within scene loading
  108906. * @returns the human readable reflection probe info
  108907. */
  108908. toString(fullDetails?: boolean): string;
  108909. /**
  108910. * Get the class name of the relfection probe.
  108911. * @returns "ReflectionProbe"
  108912. */
  108913. getClassName(): string;
  108914. /**
  108915. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108916. * @returns The JSON representation of the texture
  108917. */
  108918. serialize(): any;
  108919. /**
  108920. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108921. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108922. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108923. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108924. * @returns The parsed reflection probe if successful
  108925. */
  108926. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108927. }
  108928. }
  108929. declare module BABYLON {
  108930. /** @hidden */
  108931. export var _BabylonLoaderRegistered: boolean;
  108932. }
  108933. declare module BABYLON {
  108934. /**
  108935. * The Physically based simple base material of BJS.
  108936. *
  108937. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108938. * It is used as the base class for both the specGloss and metalRough conventions.
  108939. */
  108940. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108941. /**
  108942. * Number of Simultaneous lights allowed on the material.
  108943. */
  108944. maxSimultaneousLights: number;
  108945. /**
  108946. * If sets to true, disables all the lights affecting the material.
  108947. */
  108948. disableLighting: boolean;
  108949. /**
  108950. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108951. */
  108952. environmentTexture: BaseTexture;
  108953. /**
  108954. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108955. */
  108956. invertNormalMapX: boolean;
  108957. /**
  108958. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108959. */
  108960. invertNormalMapY: boolean;
  108961. /**
  108962. * Normal map used in the model.
  108963. */
  108964. normalTexture: BaseTexture;
  108965. /**
  108966. * Emissivie color used to self-illuminate the model.
  108967. */
  108968. emissiveColor: Color3;
  108969. /**
  108970. * Emissivie texture used to self-illuminate the model.
  108971. */
  108972. emissiveTexture: BaseTexture;
  108973. /**
  108974. * Occlusion Channel Strenght.
  108975. */
  108976. occlusionStrength: number;
  108977. /**
  108978. * Occlusion Texture of the material (adding extra occlusion effects).
  108979. */
  108980. occlusionTexture: BaseTexture;
  108981. /**
  108982. * Defines the alpha limits in alpha test mode.
  108983. */
  108984. alphaCutOff: number;
  108985. /**
  108986. * Gets the current double sided mode.
  108987. */
  108988. /**
  108989. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108990. */
  108991. doubleSided: boolean;
  108992. /**
  108993. * Stores the pre-calculated light information of a mesh in a texture.
  108994. */
  108995. lightmapTexture: BaseTexture;
  108996. /**
  108997. * If true, the light map contains occlusion information instead of lighting info.
  108998. */
  108999. useLightmapAsShadowmap: boolean;
  109000. /**
  109001. * Instantiates a new PBRMaterial instance.
  109002. *
  109003. * @param name The material name
  109004. * @param scene The scene the material will be use in.
  109005. */
  109006. constructor(name: string, scene: Scene);
  109007. getClassName(): string;
  109008. }
  109009. }
  109010. declare module BABYLON {
  109011. /**
  109012. * The PBR material of BJS following the metal roughness convention.
  109013. *
  109014. * This fits to the PBR convention in the GLTF definition:
  109015. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  109016. */
  109017. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  109018. /**
  109019. * The base color has two different interpretations depending on the value of metalness.
  109020. * When the material is a metal, the base color is the specific measured reflectance value
  109021. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  109022. * of the material.
  109023. */
  109024. baseColor: Color3;
  109025. /**
  109026. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  109027. * well as opacity information in the alpha channel.
  109028. */
  109029. baseTexture: BaseTexture;
  109030. /**
  109031. * Specifies the metallic scalar value of the material.
  109032. * Can also be used to scale the metalness values of the metallic texture.
  109033. */
  109034. metallic: number;
  109035. /**
  109036. * Specifies the roughness scalar value of the material.
  109037. * Can also be used to scale the roughness values of the metallic texture.
  109038. */
  109039. roughness: number;
  109040. /**
  109041. * Texture containing both the metallic value in the B channel and the
  109042. * roughness value in the G channel to keep better precision.
  109043. */
  109044. metallicRoughnessTexture: BaseTexture;
  109045. /**
  109046. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109047. *
  109048. * @param name The material name
  109049. * @param scene The scene the material will be use in.
  109050. */
  109051. constructor(name: string, scene: Scene);
  109052. /**
  109053. * Return the currrent class name of the material.
  109054. */
  109055. getClassName(): string;
  109056. /**
  109057. * Makes a duplicate of the current material.
  109058. * @param name - name to use for the new material.
  109059. */
  109060. clone(name: string): PBRMetallicRoughnessMaterial;
  109061. /**
  109062. * Serialize the material to a parsable JSON object.
  109063. */
  109064. serialize(): any;
  109065. /**
  109066. * Parses a JSON object correponding to the serialize function.
  109067. */
  109068. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109069. }
  109070. }
  109071. declare module BABYLON {
  109072. /**
  109073. * The PBR material of BJS following the specular glossiness convention.
  109074. *
  109075. * This fits to the PBR convention in the GLTF definition:
  109076. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109077. */
  109078. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109079. /**
  109080. * Specifies the diffuse color of the material.
  109081. */
  109082. diffuseColor: Color3;
  109083. /**
  109084. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109085. * channel.
  109086. */
  109087. diffuseTexture: BaseTexture;
  109088. /**
  109089. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109090. */
  109091. specularColor: Color3;
  109092. /**
  109093. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109094. */
  109095. glossiness: number;
  109096. /**
  109097. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109098. */
  109099. specularGlossinessTexture: BaseTexture;
  109100. /**
  109101. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109102. *
  109103. * @param name The material name
  109104. * @param scene The scene the material will be use in.
  109105. */
  109106. constructor(name: string, scene: Scene);
  109107. /**
  109108. * Return the currrent class name of the material.
  109109. */
  109110. getClassName(): string;
  109111. /**
  109112. * Makes a duplicate of the current material.
  109113. * @param name - name to use for the new material.
  109114. */
  109115. clone(name: string): PBRSpecularGlossinessMaterial;
  109116. /**
  109117. * Serialize the material to a parsable JSON object.
  109118. */
  109119. serialize(): any;
  109120. /**
  109121. * Parses a JSON object correponding to the serialize function.
  109122. */
  109123. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109124. }
  109125. }
  109126. declare module BABYLON {
  109127. /**
  109128. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109129. * It can help converting any input color in a desired output one. This can then be used to create effects
  109130. * from sepia, black and white to sixties or futuristic rendering...
  109131. *
  109132. * The only supported format is currently 3dl.
  109133. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109134. */
  109135. export class ColorGradingTexture extends BaseTexture {
  109136. /**
  109137. * The current texture matrix. (will always be identity in color grading texture)
  109138. */
  109139. private _textureMatrix;
  109140. /**
  109141. * The texture URL.
  109142. */
  109143. url: string;
  109144. /**
  109145. * Empty line regex stored for GC.
  109146. */
  109147. private static _noneEmptyLineRegex;
  109148. private _engine;
  109149. /**
  109150. * Instantiates a ColorGradingTexture from the following parameters.
  109151. *
  109152. * @param url The location of the color gradind data (currently only supporting 3dl)
  109153. * @param scene The scene the texture will be used in
  109154. */
  109155. constructor(url: string, scene: Scene);
  109156. /**
  109157. * Returns the texture matrix used in most of the material.
  109158. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109159. */
  109160. getTextureMatrix(): Matrix;
  109161. /**
  109162. * Occurs when the file being loaded is a .3dl LUT file.
  109163. */
  109164. private load3dlTexture;
  109165. /**
  109166. * Starts the loading process of the texture.
  109167. */
  109168. private loadTexture;
  109169. /**
  109170. * Clones the color gradind texture.
  109171. */
  109172. clone(): ColorGradingTexture;
  109173. /**
  109174. * Called during delayed load for textures.
  109175. */
  109176. delayLoad(): void;
  109177. /**
  109178. * Parses a color grading texture serialized by Babylon.
  109179. * @param parsedTexture The texture information being parsedTexture
  109180. * @param scene The scene to load the texture in
  109181. * @param rootUrl The root url of the data assets to load
  109182. * @return A color gradind texture
  109183. */
  109184. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109185. /**
  109186. * Serializes the LUT texture to json format.
  109187. */
  109188. serialize(): any;
  109189. }
  109190. }
  109191. declare module BABYLON {
  109192. /**
  109193. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109194. */
  109195. export class EquiRectangularCubeTexture extends BaseTexture {
  109196. /** The six faces of the cube. */
  109197. private static _FacesMapping;
  109198. private _noMipmap;
  109199. private _onLoad;
  109200. private _onError;
  109201. /** The size of the cubemap. */
  109202. private _size;
  109203. /** The buffer of the image. */
  109204. private _buffer;
  109205. /** The width of the input image. */
  109206. private _width;
  109207. /** The height of the input image. */
  109208. private _height;
  109209. /** The URL to the image. */
  109210. url: string;
  109211. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109212. coordinatesMode: number;
  109213. /**
  109214. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109215. * @param url The location of the image
  109216. * @param scene The scene the texture will be used in
  109217. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109218. * @param noMipmap Forces to not generate the mipmap if true
  109219. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109220. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109221. * @param onLoad — defines a callback called when texture is loaded
  109222. * @param onError — defines a callback called if there is an error
  109223. */
  109224. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109225. /**
  109226. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109227. */
  109228. private loadImage;
  109229. /**
  109230. * Convert the image buffer into a cubemap and create a CubeTexture.
  109231. */
  109232. private loadTexture;
  109233. /**
  109234. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109235. * @param buffer The ArrayBuffer that should be converted.
  109236. * @returns The buffer as Float32Array.
  109237. */
  109238. private getFloat32ArrayFromArrayBuffer;
  109239. /**
  109240. * Get the current class name of the texture useful for serialization or dynamic coding.
  109241. * @returns "EquiRectangularCubeTexture"
  109242. */
  109243. getClassName(): string;
  109244. /**
  109245. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109246. * @returns A clone of the current EquiRectangularCubeTexture.
  109247. */
  109248. clone(): EquiRectangularCubeTexture;
  109249. }
  109250. }
  109251. declare module BABYLON {
  109252. /**
  109253. * Based on jsTGALoader - Javascript loader for TGA file
  109254. * By Vincent Thibault
  109255. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109256. */
  109257. export class TGATools {
  109258. private static _TYPE_INDEXED;
  109259. private static _TYPE_RGB;
  109260. private static _TYPE_GREY;
  109261. private static _TYPE_RLE_INDEXED;
  109262. private static _TYPE_RLE_RGB;
  109263. private static _TYPE_RLE_GREY;
  109264. private static _ORIGIN_MASK;
  109265. private static _ORIGIN_SHIFT;
  109266. private static _ORIGIN_BL;
  109267. private static _ORIGIN_BR;
  109268. private static _ORIGIN_UL;
  109269. private static _ORIGIN_UR;
  109270. /**
  109271. * Gets the header of a TGA file
  109272. * @param data defines the TGA data
  109273. * @returns the header
  109274. */
  109275. static GetTGAHeader(data: Uint8Array): any;
  109276. /**
  109277. * Uploads TGA content to a Babylon Texture
  109278. * @hidden
  109279. */
  109280. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109281. /** @hidden */
  109282. 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;
  109283. /** @hidden */
  109284. 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;
  109285. /** @hidden */
  109286. 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;
  109287. /** @hidden */
  109288. 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;
  109289. /** @hidden */
  109290. 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;
  109291. /** @hidden */
  109292. 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;
  109293. }
  109294. }
  109295. declare module BABYLON {
  109296. /**
  109297. * Implementation of the TGA Texture Loader.
  109298. * @hidden
  109299. */
  109300. export class _TGATextureLoader implements IInternalTextureLoader {
  109301. /**
  109302. * Defines wether the loader supports cascade loading the different faces.
  109303. */
  109304. readonly supportCascades: boolean;
  109305. /**
  109306. * This returns if the loader support the current file information.
  109307. * @param extension defines the file extension of the file being loaded
  109308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109309. * @param fallback defines the fallback internal texture if any
  109310. * @param isBase64 defines whether the texture is encoded as a base64
  109311. * @param isBuffer defines whether the texture data are stored as a buffer
  109312. * @returns true if the loader can load the specified file
  109313. */
  109314. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109315. /**
  109316. * Transform the url before loading if required.
  109317. * @param rootUrl the url of the texture
  109318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109319. * @returns the transformed texture
  109320. */
  109321. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109322. /**
  109323. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109324. * @param rootUrl the url of the texture
  109325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109326. * @returns the fallback texture
  109327. */
  109328. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109329. /**
  109330. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109331. * @param data contains the texture data
  109332. * @param texture defines the BabylonJS internal texture
  109333. * @param createPolynomials will be true if polynomials have been requested
  109334. * @param onLoad defines the callback to trigger once the texture is ready
  109335. * @param onError defines the callback to trigger in case of error
  109336. */
  109337. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109338. /**
  109339. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109340. * @param data contains the texture data
  109341. * @param texture defines the BabylonJS internal texture
  109342. * @param callback defines the method to call once ready to upload
  109343. */
  109344. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109345. }
  109346. }
  109347. declare module BABYLON {
  109348. /**
  109349. * 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.
  109350. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109351. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109352. */
  109353. export class CustomProceduralTexture extends ProceduralTexture {
  109354. private _animate;
  109355. private _time;
  109356. private _config;
  109357. private _texturePath;
  109358. /**
  109359. * Instantiates a new Custom Procedural Texture.
  109360. * 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.
  109361. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109362. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109363. * @param name Define the name of the texture
  109364. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109365. * @param size Define the size of the texture to create
  109366. * @param scene Define the scene the texture belongs to
  109367. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109368. * @param generateMipMaps Define if the texture should creates mip maps or not
  109369. */
  109370. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109371. private _loadJson;
  109372. /**
  109373. * Is the texture ready to be used ? (rendered at least once)
  109374. * @returns true if ready, otherwise, false.
  109375. */
  109376. isReady(): boolean;
  109377. /**
  109378. * Render the texture to its associated render target.
  109379. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109380. */
  109381. render(useCameraPostProcess?: boolean): void;
  109382. /**
  109383. * Update the list of dependant textures samplers in the shader.
  109384. */
  109385. updateTextures(): void;
  109386. /**
  109387. * Update the uniform values of the procedural texture in the shader.
  109388. */
  109389. updateShaderUniforms(): void;
  109390. /**
  109391. * Define if the texture animates or not.
  109392. */
  109393. animate: boolean;
  109394. }
  109395. }
  109396. declare module BABYLON {
  109397. /** @hidden */
  109398. export var noisePixelShader: {
  109399. name: string;
  109400. shader: string;
  109401. };
  109402. }
  109403. declare module BABYLON {
  109404. /**
  109405. * Class used to generate noise procedural textures
  109406. */
  109407. export class NoiseProceduralTexture extends ProceduralTexture {
  109408. private _time;
  109409. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109410. brightness: number;
  109411. /** Defines the number of octaves to process */
  109412. octaves: number;
  109413. /** Defines the level of persistence (0.8 by default) */
  109414. persistence: number;
  109415. /** Gets or sets animation speed factor (default is 1) */
  109416. animationSpeedFactor: number;
  109417. /**
  109418. * Creates a new NoiseProceduralTexture
  109419. * @param name defines the name fo the texture
  109420. * @param size defines the size of the texture (default is 256)
  109421. * @param scene defines the hosting scene
  109422. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109423. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109424. */
  109425. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109426. private _updateShaderUniforms;
  109427. protected _getDefines(): string;
  109428. /** Generate the current state of the procedural texture */
  109429. render(useCameraPostProcess?: boolean): void;
  109430. /**
  109431. * Serializes this noise procedural texture
  109432. * @returns a serialized noise procedural texture object
  109433. */
  109434. serialize(): any;
  109435. /**
  109436. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109437. * @param parsedTexture defines parsed texture data
  109438. * @param scene defines the current scene
  109439. * @param rootUrl defines the root URL containing noise procedural texture information
  109440. * @returns a parsed NoiseProceduralTexture
  109441. */
  109442. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109443. }
  109444. }
  109445. declare module BABYLON {
  109446. /**
  109447. * Raw cube texture where the raw buffers are passed in
  109448. */
  109449. export class RawCubeTexture extends CubeTexture {
  109450. /**
  109451. * Creates a cube texture where the raw buffers are passed in.
  109452. * @param scene defines the scene the texture is attached to
  109453. * @param data defines the array of data to use to create each face
  109454. * @param size defines the size of the textures
  109455. * @param format defines the format of the data
  109456. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109457. * @param generateMipMaps defines if the engine should generate the mip levels
  109458. * @param invertY defines if data must be stored with Y axis inverted
  109459. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109460. * @param compression defines the compression used (null by default)
  109461. */
  109462. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109463. /**
  109464. * Updates the raw cube texture.
  109465. * @param data defines the data to store
  109466. * @param format defines the data format
  109467. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109468. * @param invertY defines if data must be stored with Y axis inverted
  109469. * @param compression defines the compression used (null by default)
  109470. * @param level defines which level of the texture to update
  109471. */
  109472. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109473. /**
  109474. * Updates a raw cube texture with RGBD encoded data.
  109475. * @param data defines the array of data [mipmap][face] to use to create each face
  109476. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109477. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109478. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109479. * @returns a promsie that resolves when the operation is complete
  109480. */
  109481. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109482. /**
  109483. * Clones the raw cube texture.
  109484. * @return a new cube texture
  109485. */
  109486. clone(): CubeTexture;
  109487. /** @hidden */
  109488. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109489. }
  109490. }
  109491. declare module BABYLON {
  109492. /**
  109493. * Class used to store 3D textures containing user data
  109494. */
  109495. export class RawTexture3D extends Texture {
  109496. /** Gets or sets the texture format to use */
  109497. format: number;
  109498. private _engine;
  109499. /**
  109500. * Create a new RawTexture3D
  109501. * @param data defines the data of the texture
  109502. * @param width defines the width of the texture
  109503. * @param height defines the height of the texture
  109504. * @param depth defines the depth of the texture
  109505. * @param format defines the texture format to use
  109506. * @param scene defines the hosting scene
  109507. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109508. * @param invertY defines if texture must be stored with Y axis inverted
  109509. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109510. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109511. */
  109512. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109513. /** Gets or sets the texture format to use */
  109514. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109515. /**
  109516. * Update the texture with new data
  109517. * @param data defines the data to store in the texture
  109518. */
  109519. update(data: ArrayBufferView): void;
  109520. }
  109521. }
  109522. declare module BABYLON {
  109523. /**
  109524. * Creates a refraction texture used by refraction channel of the standard material.
  109525. * It is like a mirror but to see through a material.
  109526. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109527. */
  109528. export class RefractionTexture extends RenderTargetTexture {
  109529. /**
  109530. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109531. * 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.
  109532. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109533. */
  109534. refractionPlane: Plane;
  109535. /**
  109536. * Define how deep under the surface we should see.
  109537. */
  109538. depth: number;
  109539. /**
  109540. * Creates a refraction texture used by refraction channel of the standard material.
  109541. * It is like a mirror but to see through a material.
  109542. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109543. * @param name Define the texture name
  109544. * @param size Define the size of the underlying texture
  109545. * @param scene Define the scene the refraction belongs to
  109546. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109547. */
  109548. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109549. /**
  109550. * Clone the refraction texture.
  109551. * @returns the cloned texture
  109552. */
  109553. clone(): RefractionTexture;
  109554. /**
  109555. * Serialize the texture to a JSON representation you could use in Parse later on
  109556. * @returns the serialized JSON representation
  109557. */
  109558. serialize(): any;
  109559. }
  109560. }
  109561. declare module BABYLON {
  109562. /**
  109563. * Defines the options related to the creation of an HtmlElementTexture
  109564. */
  109565. export interface IHtmlElementTextureOptions {
  109566. /**
  109567. * Defines wether mip maps should be created or not.
  109568. */
  109569. generateMipMaps?: boolean;
  109570. /**
  109571. * Defines the sampling mode of the texture.
  109572. */
  109573. samplingMode?: number;
  109574. /**
  109575. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109576. */
  109577. engine: Nullable<Engine>;
  109578. /**
  109579. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109580. */
  109581. scene: Nullable<Scene>;
  109582. }
  109583. /**
  109584. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109585. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109586. * is automatically managed.
  109587. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109588. * in your application.
  109589. *
  109590. * As the update is not automatic, you need to call them manually.
  109591. */
  109592. export class HtmlElementTexture extends BaseTexture {
  109593. /**
  109594. * The texture URL.
  109595. */
  109596. element: HTMLVideoElement | HTMLCanvasElement;
  109597. private static readonly DefaultOptions;
  109598. private _textureMatrix;
  109599. private _engine;
  109600. private _isVideo;
  109601. private _generateMipMaps;
  109602. private _samplingMode;
  109603. /**
  109604. * Instantiates a HtmlElementTexture from the following parameters.
  109605. *
  109606. * @param name Defines the name of the texture
  109607. * @param element Defines the video or canvas the texture is filled with
  109608. * @param options Defines the other none mandatory texture creation options
  109609. */
  109610. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109611. private _createInternalTexture;
  109612. /**
  109613. * Returns the texture matrix used in most of the material.
  109614. */
  109615. getTextureMatrix(): Matrix;
  109616. /**
  109617. * Updates the content of the texture.
  109618. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109619. */
  109620. update(invertY?: Nullable<boolean>): void;
  109621. }
  109622. }
  109623. declare module BABYLON {
  109624. /**
  109625. * Helper class to push actions to a pool of workers.
  109626. */
  109627. export class WorkerPool implements IDisposable {
  109628. private _workerInfos;
  109629. private _pendingActions;
  109630. /**
  109631. * Constructor
  109632. * @param workers Array of workers to use for actions
  109633. */
  109634. constructor(workers: Array<Worker>);
  109635. /**
  109636. * Terminates all workers and clears any pending actions.
  109637. */
  109638. dispose(): void;
  109639. /**
  109640. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109641. * pended until a worker has completed its action.
  109642. * @param action The action to perform. Call onComplete when the action is complete.
  109643. */
  109644. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109645. private _execute;
  109646. }
  109647. }
  109648. declare module BABYLON {
  109649. /**
  109650. * Configuration for Draco compression
  109651. */
  109652. export interface IDracoCompressionConfiguration {
  109653. /**
  109654. * Configuration for the decoder.
  109655. */
  109656. decoder: {
  109657. /**
  109658. * The url to the WebAssembly module.
  109659. */
  109660. wasmUrl?: string;
  109661. /**
  109662. * The url to the WebAssembly binary.
  109663. */
  109664. wasmBinaryUrl?: string;
  109665. /**
  109666. * The url to the fallback JavaScript module.
  109667. */
  109668. fallbackUrl?: string;
  109669. };
  109670. }
  109671. /**
  109672. * Draco compression (https://google.github.io/draco/)
  109673. *
  109674. * This class wraps the Draco module.
  109675. *
  109676. * **Encoder**
  109677. *
  109678. * The encoder is not currently implemented.
  109679. *
  109680. * **Decoder**
  109681. *
  109682. * 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.
  109683. *
  109684. * To update the configuration, use the following code:
  109685. * ```javascript
  109686. * DracoCompression.Configuration = {
  109687. * decoder: {
  109688. * wasmUrl: "<url to the WebAssembly library>",
  109689. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109690. * fallbackUrl: "<url to the fallback JavaScript library>",
  109691. * }
  109692. * };
  109693. * ```
  109694. *
  109695. * 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.
  109696. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109697. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  109698. *
  109699. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  109700. * ```javascript
  109701. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  109702. * ```
  109703. *
  109704. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109705. */
  109706. export class DracoCompression implements IDisposable {
  109707. private _workerPoolPromise?;
  109708. private _decoderModulePromise?;
  109709. /**
  109710. * The configuration. Defaults to the following urls:
  109711. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109712. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109713. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109714. */
  109715. static Configuration: IDracoCompressionConfiguration;
  109716. /**
  109717. * Returns true if the decoder configuration is available.
  109718. */
  109719. static readonly DecoderAvailable: boolean;
  109720. /**
  109721. * Default number of workers to create when creating the draco compression object.
  109722. */
  109723. static DefaultNumWorkers: number;
  109724. private static GetDefaultNumWorkers;
  109725. private static _Default;
  109726. /**
  109727. * Default instance for the draco compression object.
  109728. */
  109729. static readonly Default: DracoCompression;
  109730. /**
  109731. * Constructor
  109732. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  109733. */
  109734. constructor(numWorkers?: number);
  109735. /**
  109736. * Stop all async operations and release resources.
  109737. */
  109738. dispose(): void;
  109739. /**
  109740. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109741. * @returns a promise that resolves when ready
  109742. */
  109743. whenReadyAsync(): Promise<void>;
  109744. /**
  109745. * Decode Draco compressed mesh data to vertex data.
  109746. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109747. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109748. * @returns A promise that resolves with the decoded vertex data
  109749. */
  109750. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109751. [kind: string]: number;
  109752. }): Promise<VertexData>;
  109753. }
  109754. }
  109755. declare module BABYLON {
  109756. /**
  109757. * Class for building Constructive Solid Geometry
  109758. */
  109759. export class CSG {
  109760. private polygons;
  109761. /**
  109762. * The world matrix
  109763. */
  109764. matrix: Matrix;
  109765. /**
  109766. * Stores the position
  109767. */
  109768. position: Vector3;
  109769. /**
  109770. * Stores the rotation
  109771. */
  109772. rotation: Vector3;
  109773. /**
  109774. * Stores the rotation quaternion
  109775. */
  109776. rotationQuaternion: Nullable<Quaternion>;
  109777. /**
  109778. * Stores the scaling vector
  109779. */
  109780. scaling: Vector3;
  109781. /**
  109782. * Convert the Mesh to CSG
  109783. * @param mesh The Mesh to convert to CSG
  109784. * @returns A new CSG from the Mesh
  109785. */
  109786. static FromMesh(mesh: Mesh): CSG;
  109787. /**
  109788. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109789. * @param polygons Polygons used to construct a CSG solid
  109790. */
  109791. private static FromPolygons;
  109792. /**
  109793. * Clones, or makes a deep copy, of the CSG
  109794. * @returns A new CSG
  109795. */
  109796. clone(): CSG;
  109797. /**
  109798. * Unions this CSG with another CSG
  109799. * @param csg The CSG to union against this CSG
  109800. * @returns The unioned CSG
  109801. */
  109802. union(csg: CSG): CSG;
  109803. /**
  109804. * Unions this CSG with another CSG in place
  109805. * @param csg The CSG to union against this CSG
  109806. */
  109807. unionInPlace(csg: CSG): void;
  109808. /**
  109809. * Subtracts this CSG with another CSG
  109810. * @param csg The CSG to subtract against this CSG
  109811. * @returns A new CSG
  109812. */
  109813. subtract(csg: CSG): CSG;
  109814. /**
  109815. * Subtracts this CSG with another CSG in place
  109816. * @param csg The CSG to subtact against this CSG
  109817. */
  109818. subtractInPlace(csg: CSG): void;
  109819. /**
  109820. * Intersect this CSG with another CSG
  109821. * @param csg The CSG to intersect against this CSG
  109822. * @returns A new CSG
  109823. */
  109824. intersect(csg: CSG): CSG;
  109825. /**
  109826. * Intersects this CSG with another CSG in place
  109827. * @param csg The CSG to intersect against this CSG
  109828. */
  109829. intersectInPlace(csg: CSG): void;
  109830. /**
  109831. * Return a new CSG solid with solid and empty space switched. This solid is
  109832. * not modified.
  109833. * @returns A new CSG solid with solid and empty space switched
  109834. */
  109835. inverse(): CSG;
  109836. /**
  109837. * Inverses the CSG in place
  109838. */
  109839. inverseInPlace(): void;
  109840. /**
  109841. * This is used to keep meshes transformations so they can be restored
  109842. * when we build back a Babylon Mesh
  109843. * NB : All CSG operations are performed in world coordinates
  109844. * @param csg The CSG to copy the transform attributes from
  109845. * @returns This CSG
  109846. */
  109847. copyTransformAttributes(csg: CSG): CSG;
  109848. /**
  109849. * Build Raw mesh from CSG
  109850. * Coordinates here are in world space
  109851. * @param name The name of the mesh geometry
  109852. * @param scene The Scene
  109853. * @param keepSubMeshes Specifies if the submeshes should be kept
  109854. * @returns A new Mesh
  109855. */
  109856. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109857. /**
  109858. * Build Mesh from CSG taking material and transforms into account
  109859. * @param name The name of the Mesh
  109860. * @param material The material of the Mesh
  109861. * @param scene The Scene
  109862. * @param keepSubMeshes Specifies if submeshes should be kept
  109863. * @returns The new Mesh
  109864. */
  109865. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109866. }
  109867. }
  109868. declare module BABYLON {
  109869. /**
  109870. * Class used to create a trail following a mesh
  109871. */
  109872. export class TrailMesh extends Mesh {
  109873. private _generator;
  109874. private _autoStart;
  109875. private _running;
  109876. private _diameter;
  109877. private _length;
  109878. private _sectionPolygonPointsCount;
  109879. private _sectionVectors;
  109880. private _sectionNormalVectors;
  109881. private _beforeRenderObserver;
  109882. /**
  109883. * @constructor
  109884. * @param name The value used by scene.getMeshByName() to do a lookup.
  109885. * @param generator The mesh to generate a trail.
  109886. * @param scene The scene to add this mesh to.
  109887. * @param diameter Diameter of trailing mesh. Default is 1.
  109888. * @param length Length of trailing mesh. Default is 60.
  109889. * @param autoStart Automatically start trailing mesh. Default true.
  109890. */
  109891. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109892. /**
  109893. * "TrailMesh"
  109894. * @returns "TrailMesh"
  109895. */
  109896. getClassName(): string;
  109897. private _createMesh;
  109898. /**
  109899. * Start trailing mesh.
  109900. */
  109901. start(): void;
  109902. /**
  109903. * Stop trailing mesh.
  109904. */
  109905. stop(): void;
  109906. /**
  109907. * Update trailing mesh geometry.
  109908. */
  109909. update(): void;
  109910. /**
  109911. * Returns a new TrailMesh object.
  109912. * @param name is a string, the name given to the new mesh
  109913. * @param newGenerator use new generator object for cloned trail mesh
  109914. * @returns a new mesh
  109915. */
  109916. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109917. /**
  109918. * Serializes this trail mesh
  109919. * @param serializationObject object to write serialization to
  109920. */
  109921. serialize(serializationObject: any): void;
  109922. /**
  109923. * Parses a serialized trail mesh
  109924. * @param parsedMesh the serialized mesh
  109925. * @param scene the scene to create the trail mesh in
  109926. * @returns the created trail mesh
  109927. */
  109928. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109929. }
  109930. }
  109931. declare module BABYLON {
  109932. /**
  109933. * Class containing static functions to help procedurally build meshes
  109934. */
  109935. export class TorusKnotBuilder {
  109936. /**
  109937. * Creates a torus knot mesh
  109938. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109939. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109940. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109941. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109945. * @param name defines the name of the mesh
  109946. * @param options defines the options used to create the mesh
  109947. * @param scene defines the hosting scene
  109948. * @returns the torus knot mesh
  109949. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109950. */
  109951. static CreateTorusKnot(name: string, options: {
  109952. radius?: number;
  109953. tube?: number;
  109954. radialSegments?: number;
  109955. tubularSegments?: number;
  109956. p?: number;
  109957. q?: number;
  109958. updatable?: boolean;
  109959. sideOrientation?: number;
  109960. frontUVs?: Vector4;
  109961. backUVs?: Vector4;
  109962. }, scene: any): Mesh;
  109963. }
  109964. }
  109965. declare module BABYLON {
  109966. /**
  109967. * Polygon
  109968. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109969. */
  109970. export class Polygon {
  109971. /**
  109972. * Creates a rectangle
  109973. * @param xmin bottom X coord
  109974. * @param ymin bottom Y coord
  109975. * @param xmax top X coord
  109976. * @param ymax top Y coord
  109977. * @returns points that make the resulting rectation
  109978. */
  109979. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109980. /**
  109981. * Creates a circle
  109982. * @param radius radius of circle
  109983. * @param cx scale in x
  109984. * @param cy scale in y
  109985. * @param numberOfSides number of sides that make up the circle
  109986. * @returns points that make the resulting circle
  109987. */
  109988. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109989. /**
  109990. * Creates a polygon from input string
  109991. * @param input Input polygon data
  109992. * @returns the parsed points
  109993. */
  109994. static Parse(input: string): Vector2[];
  109995. /**
  109996. * Starts building a polygon from x and y coordinates
  109997. * @param x x coordinate
  109998. * @param y y coordinate
  109999. * @returns the started path2
  110000. */
  110001. static StartingAt(x: number, y: number): Path2;
  110002. }
  110003. /**
  110004. * Builds a polygon
  110005. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  110006. */
  110007. export class PolygonMeshBuilder {
  110008. private _points;
  110009. private _outlinepoints;
  110010. private _holes;
  110011. private _name;
  110012. private _scene;
  110013. private _epoints;
  110014. private _eholes;
  110015. private _addToepoint;
  110016. /**
  110017. * Babylon reference to the earcut plugin.
  110018. */
  110019. bjsEarcut: any;
  110020. /**
  110021. * Creates a PolygonMeshBuilder
  110022. * @param name name of the builder
  110023. * @param contours Path of the polygon
  110024. * @param scene scene to add to when creating the mesh
  110025. * @param earcutInjection can be used to inject your own earcut reference
  110026. */
  110027. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  110028. /**
  110029. * Adds a whole within the polygon
  110030. * @param hole Array of points defining the hole
  110031. * @returns this
  110032. */
  110033. addHole(hole: Vector2[]): PolygonMeshBuilder;
  110034. /**
  110035. * Creates the polygon
  110036. * @param updatable If the mesh should be updatable
  110037. * @param depth The depth of the mesh created
  110038. * @returns the created mesh
  110039. */
  110040. build(updatable?: boolean, depth?: number): Mesh;
  110041. /**
  110042. * Creates the polygon
  110043. * @param depth The depth of the mesh created
  110044. * @returns the created VertexData
  110045. */
  110046. buildVertexData(depth?: number): VertexData;
  110047. /**
  110048. * Adds a side to the polygon
  110049. * @param positions points that make the polygon
  110050. * @param normals normals of the polygon
  110051. * @param uvs uvs of the polygon
  110052. * @param indices indices of the polygon
  110053. * @param bounds bounds of the polygon
  110054. * @param points points of the polygon
  110055. * @param depth depth of the polygon
  110056. * @param flip flip of the polygon
  110057. */
  110058. private addSide;
  110059. }
  110060. }
  110061. declare module BABYLON {
  110062. /**
  110063. * Class containing static functions to help procedurally build meshes
  110064. */
  110065. export class PolygonBuilder {
  110066. /**
  110067. * Creates a polygon mesh
  110068. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110069. * * 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
  110070. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110073. * * Remember you can only change the shape positions, not their number when updating a polygon
  110074. * @param name defines the name of the mesh
  110075. * @param options defines the options used to create the mesh
  110076. * @param scene defines the hosting scene
  110077. * @param earcutInjection can be used to inject your own earcut reference
  110078. * @returns the polygon mesh
  110079. */
  110080. static CreatePolygon(name: string, options: {
  110081. shape: Vector3[];
  110082. holes?: Vector3[][];
  110083. depth?: number;
  110084. faceUV?: Vector4[];
  110085. faceColors?: Color4[];
  110086. updatable?: boolean;
  110087. sideOrientation?: number;
  110088. frontUVs?: Vector4;
  110089. backUVs?: Vector4;
  110090. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110091. /**
  110092. * Creates an extruded polygon mesh, with depth in the Y direction.
  110093. * * 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)
  110094. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110095. * @param name defines the name of the mesh
  110096. * @param options defines the options used to create the mesh
  110097. * @param scene defines the hosting scene
  110098. * @param earcutInjection can be used to inject your own earcut reference
  110099. * @returns the polygon mesh
  110100. */
  110101. static ExtrudePolygon(name: string, options: {
  110102. shape: Vector3[];
  110103. holes?: Vector3[][];
  110104. depth?: number;
  110105. faceUV?: Vector4[];
  110106. faceColors?: Color4[];
  110107. updatable?: boolean;
  110108. sideOrientation?: number;
  110109. frontUVs?: Vector4;
  110110. backUVs?: Vector4;
  110111. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110112. }
  110113. }
  110114. declare module BABYLON {
  110115. /**
  110116. * Class containing static functions to help procedurally build meshes
  110117. */
  110118. export class LatheBuilder {
  110119. /**
  110120. * Creates lathe mesh.
  110121. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110122. * * 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
  110123. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110124. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110125. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110126. * * 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
  110127. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110128. * * 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
  110129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110133. * @param name defines the name of the mesh
  110134. * @param options defines the options used to create the mesh
  110135. * @param scene defines the hosting scene
  110136. * @returns the lathe mesh
  110137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110138. */
  110139. static CreateLathe(name: string, options: {
  110140. shape: Vector3[];
  110141. radius?: number;
  110142. tessellation?: number;
  110143. clip?: number;
  110144. arc?: number;
  110145. closed?: boolean;
  110146. updatable?: boolean;
  110147. sideOrientation?: number;
  110148. frontUVs?: Vector4;
  110149. backUVs?: Vector4;
  110150. cap?: number;
  110151. invertUV?: boolean;
  110152. }, scene?: Nullable<Scene>): Mesh;
  110153. }
  110154. }
  110155. declare module BABYLON {
  110156. /**
  110157. * Class containing static functions to help procedurally build meshes
  110158. */
  110159. export class TubeBuilder {
  110160. /**
  110161. * Creates a tube mesh.
  110162. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110163. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110164. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110165. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110166. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110167. * * 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)
  110168. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110169. * * 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
  110170. * * 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
  110171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110173. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110175. * @param name defines the name of the mesh
  110176. * @param options defines the options used to create the mesh
  110177. * @param scene defines the hosting scene
  110178. * @returns the tube mesh
  110179. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110180. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110181. */
  110182. static CreateTube(name: string, options: {
  110183. path: Vector3[];
  110184. radius?: number;
  110185. tessellation?: number;
  110186. radiusFunction?: {
  110187. (i: number, distance: number): number;
  110188. };
  110189. cap?: number;
  110190. arc?: number;
  110191. updatable?: boolean;
  110192. sideOrientation?: number;
  110193. frontUVs?: Vector4;
  110194. backUVs?: Vector4;
  110195. instance?: Mesh;
  110196. invertUV?: boolean;
  110197. }, scene?: Nullable<Scene>): Mesh;
  110198. }
  110199. }
  110200. declare module BABYLON {
  110201. /**
  110202. * Class containing static functions to help procedurally build meshes
  110203. */
  110204. export class IcoSphereBuilder {
  110205. /**
  110206. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110207. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110208. * * 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`)
  110209. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110210. * * 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
  110211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110214. * @param name defines the name of the mesh
  110215. * @param options defines the options used to create the mesh
  110216. * @param scene defines the hosting scene
  110217. * @returns the icosahedron mesh
  110218. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110219. */
  110220. static CreateIcoSphere(name: string, options: {
  110221. radius?: number;
  110222. radiusX?: number;
  110223. radiusY?: number;
  110224. radiusZ?: number;
  110225. flat?: boolean;
  110226. subdivisions?: number;
  110227. sideOrientation?: number;
  110228. frontUVs?: Vector4;
  110229. backUVs?: Vector4;
  110230. updatable?: boolean;
  110231. }, scene?: Nullable<Scene>): Mesh;
  110232. }
  110233. }
  110234. declare module BABYLON {
  110235. /**
  110236. * Class containing static functions to help procedurally build meshes
  110237. */
  110238. export class DecalBuilder {
  110239. /**
  110240. * Creates a decal mesh.
  110241. * 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
  110242. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110243. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110244. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110245. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110246. * @param name defines the name of the mesh
  110247. * @param sourceMesh defines the mesh where the decal must be applied
  110248. * @param options defines the options used to create the mesh
  110249. * @param scene defines the hosting scene
  110250. * @returns the decal mesh
  110251. * @see https://doc.babylonjs.com/how_to/decals
  110252. */
  110253. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110254. position?: Vector3;
  110255. normal?: Vector3;
  110256. size?: Vector3;
  110257. angle?: number;
  110258. }): Mesh;
  110259. }
  110260. }
  110261. declare module BABYLON {
  110262. /**
  110263. * Class containing static functions to help procedurally build meshes
  110264. */
  110265. export class MeshBuilder {
  110266. /**
  110267. * Creates a box mesh
  110268. * * The parameter `size` sets the size (float) of each box side (default 1)
  110269. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110270. * * 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)
  110271. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110275. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110276. * @param name defines the name of the mesh
  110277. * @param options defines the options used to create the mesh
  110278. * @param scene defines the hosting scene
  110279. * @returns the box mesh
  110280. */
  110281. static CreateBox(name: string, options: {
  110282. size?: number;
  110283. width?: number;
  110284. height?: number;
  110285. depth?: number;
  110286. faceUV?: Vector4[];
  110287. faceColors?: Color4[];
  110288. sideOrientation?: number;
  110289. frontUVs?: Vector4;
  110290. backUVs?: Vector4;
  110291. updatable?: boolean;
  110292. }, scene?: Nullable<Scene>): Mesh;
  110293. /**
  110294. * Creates a sphere mesh
  110295. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110296. * * 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`)
  110297. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110298. * * 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
  110299. * * 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)
  110300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110303. * @param name defines the name of the mesh
  110304. * @param options defines the options used to create the mesh
  110305. * @param scene defines the hosting scene
  110306. * @returns the sphere mesh
  110307. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110308. */
  110309. static CreateSphere(name: string, options: {
  110310. segments?: number;
  110311. diameter?: number;
  110312. diameterX?: number;
  110313. diameterY?: number;
  110314. diameterZ?: number;
  110315. arc?: number;
  110316. slice?: number;
  110317. sideOrientation?: number;
  110318. frontUVs?: Vector4;
  110319. backUVs?: Vector4;
  110320. updatable?: boolean;
  110321. }, scene?: Nullable<Scene>): Mesh;
  110322. /**
  110323. * Creates a plane polygonal mesh. By default, this is a disc
  110324. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110325. * * 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
  110326. * * 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
  110327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110330. * @param name defines the name of the mesh
  110331. * @param options defines the options used to create the mesh
  110332. * @param scene defines the hosting scene
  110333. * @returns the plane polygonal mesh
  110334. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110335. */
  110336. static CreateDisc(name: string, options: {
  110337. radius?: number;
  110338. tessellation?: number;
  110339. arc?: number;
  110340. updatable?: boolean;
  110341. sideOrientation?: number;
  110342. frontUVs?: Vector4;
  110343. backUVs?: Vector4;
  110344. }, scene?: Nullable<Scene>): Mesh;
  110345. /**
  110346. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110347. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110348. * * 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`)
  110349. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110350. * * 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
  110351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110354. * @param name defines the name of the mesh
  110355. * @param options defines the options used to create the mesh
  110356. * @param scene defines the hosting scene
  110357. * @returns the icosahedron mesh
  110358. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110359. */
  110360. static CreateIcoSphere(name: string, options: {
  110361. radius?: number;
  110362. radiusX?: number;
  110363. radiusY?: number;
  110364. radiusZ?: number;
  110365. flat?: boolean;
  110366. subdivisions?: number;
  110367. sideOrientation?: number;
  110368. frontUVs?: Vector4;
  110369. backUVs?: Vector4;
  110370. updatable?: boolean;
  110371. }, scene?: Nullable<Scene>): Mesh;
  110372. /**
  110373. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110374. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110375. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110376. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110377. * * 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
  110378. * * 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
  110379. * * 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
  110380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110382. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110383. * * 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
  110384. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110385. * * 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
  110386. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110388. * @param name defines the name of the mesh
  110389. * @param options defines the options used to create the mesh
  110390. * @param scene defines the hosting scene
  110391. * @returns the ribbon mesh
  110392. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110393. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110394. */
  110395. static CreateRibbon(name: string, options: {
  110396. pathArray: Vector3[][];
  110397. closeArray?: boolean;
  110398. closePath?: boolean;
  110399. offset?: number;
  110400. updatable?: boolean;
  110401. sideOrientation?: number;
  110402. frontUVs?: Vector4;
  110403. backUVs?: Vector4;
  110404. instance?: Mesh;
  110405. invertUV?: boolean;
  110406. uvs?: Vector2[];
  110407. colors?: Color4[];
  110408. }, scene?: Nullable<Scene>): Mesh;
  110409. /**
  110410. * Creates a cylinder or a cone mesh
  110411. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110412. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110413. * * 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.
  110414. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110415. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110416. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110417. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110418. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110419. * * 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).
  110420. * * 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
  110421. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110422. * * 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
  110423. * * 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.
  110424. * * If `enclose` is false, a ring surface is one element.
  110425. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110426. * * 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
  110427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110430. * @param name defines the name of the mesh
  110431. * @param options defines the options used to create the mesh
  110432. * @param scene defines the hosting scene
  110433. * @returns the cylinder mesh
  110434. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110435. */
  110436. static CreateCylinder(name: string, options: {
  110437. height?: number;
  110438. diameterTop?: number;
  110439. diameterBottom?: number;
  110440. diameter?: number;
  110441. tessellation?: number;
  110442. subdivisions?: number;
  110443. arc?: number;
  110444. faceColors?: Color4[];
  110445. faceUV?: Vector4[];
  110446. updatable?: boolean;
  110447. hasRings?: boolean;
  110448. enclose?: boolean;
  110449. sideOrientation?: number;
  110450. frontUVs?: Vector4;
  110451. backUVs?: Vector4;
  110452. }, scene?: Nullable<Scene>): Mesh;
  110453. /**
  110454. * Creates a torus mesh
  110455. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110456. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110457. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110461. * @param name defines the name of the mesh
  110462. * @param options defines the options used to create the mesh
  110463. * @param scene defines the hosting scene
  110464. * @returns the torus mesh
  110465. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110466. */
  110467. static CreateTorus(name: string, options: {
  110468. diameter?: number;
  110469. thickness?: number;
  110470. tessellation?: number;
  110471. updatable?: boolean;
  110472. sideOrientation?: number;
  110473. frontUVs?: Vector4;
  110474. backUVs?: Vector4;
  110475. }, scene?: Nullable<Scene>): Mesh;
  110476. /**
  110477. * Creates a torus knot mesh
  110478. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110479. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110480. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110481. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110485. * @param name defines the name of the mesh
  110486. * @param options defines the options used to create the mesh
  110487. * @param scene defines the hosting scene
  110488. * @returns the torus knot mesh
  110489. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110490. */
  110491. static CreateTorusKnot(name: string, options: {
  110492. radius?: number;
  110493. tube?: number;
  110494. radialSegments?: number;
  110495. tubularSegments?: number;
  110496. p?: number;
  110497. q?: number;
  110498. updatable?: boolean;
  110499. sideOrientation?: number;
  110500. frontUVs?: Vector4;
  110501. backUVs?: Vector4;
  110502. }, scene?: Nullable<Scene>): Mesh;
  110503. /**
  110504. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110505. * * 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
  110506. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110507. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110508. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110509. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110510. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110511. * * 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
  110512. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110515. * @param name defines the name of the new line system
  110516. * @param options defines the options used to create the line system
  110517. * @param scene defines the hosting scene
  110518. * @returns a new line system mesh
  110519. */
  110520. static CreateLineSystem(name: string, options: {
  110521. lines: Vector3[][];
  110522. updatable?: boolean;
  110523. instance?: Nullable<LinesMesh>;
  110524. colors?: Nullable<Color4[][]>;
  110525. useVertexAlpha?: boolean;
  110526. }, scene: Nullable<Scene>): LinesMesh;
  110527. /**
  110528. * Creates a line mesh
  110529. * 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
  110530. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110531. * * The parameter `points` is an array successive Vector3
  110532. * * 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
  110533. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110534. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110535. * * When updating an instance, remember that only point positions can change, not the number of points
  110536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110538. * @param name defines the name of the new line system
  110539. * @param options defines the options used to create the line system
  110540. * @param scene defines the hosting scene
  110541. * @returns a new line mesh
  110542. */
  110543. static CreateLines(name: string, options: {
  110544. points: Vector3[];
  110545. updatable?: boolean;
  110546. instance?: Nullable<LinesMesh>;
  110547. colors?: Color4[];
  110548. useVertexAlpha?: boolean;
  110549. }, scene?: Nullable<Scene>): LinesMesh;
  110550. /**
  110551. * Creates a dashed line mesh
  110552. * * 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
  110553. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110554. * * The parameter `points` is an array successive Vector3
  110555. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110556. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110557. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110558. * * 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
  110559. * * When updating an instance, remember that only point positions can change, not the number of points
  110560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110561. * @param name defines the name of the mesh
  110562. * @param options defines the options used to create the mesh
  110563. * @param scene defines the hosting scene
  110564. * @returns the dashed line mesh
  110565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110566. */
  110567. static CreateDashedLines(name: string, options: {
  110568. points: Vector3[];
  110569. dashSize?: number;
  110570. gapSize?: number;
  110571. dashNb?: number;
  110572. updatable?: boolean;
  110573. instance?: LinesMesh;
  110574. }, scene?: Nullable<Scene>): LinesMesh;
  110575. /**
  110576. * 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.
  110577. * * 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.
  110578. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110579. * * 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.
  110580. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110581. * * 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
  110582. * * 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
  110583. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110588. * @param name defines the name of the mesh
  110589. * @param options defines the options used to create the mesh
  110590. * @param scene defines the hosting scene
  110591. * @returns the extruded shape mesh
  110592. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110594. */
  110595. static ExtrudeShape(name: string, options: {
  110596. shape: Vector3[];
  110597. path: Vector3[];
  110598. scale?: number;
  110599. rotation?: number;
  110600. cap?: number;
  110601. updatable?: boolean;
  110602. sideOrientation?: number;
  110603. frontUVs?: Vector4;
  110604. backUVs?: Vector4;
  110605. instance?: Mesh;
  110606. invertUV?: boolean;
  110607. }, scene?: Nullable<Scene>): Mesh;
  110608. /**
  110609. * Creates an custom extruded shape mesh.
  110610. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110611. * * 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.
  110612. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110613. * * 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
  110614. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110615. * * 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
  110616. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110617. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110618. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110619. * * 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
  110620. * * 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
  110621. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110624. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110626. * @param name defines the name of the mesh
  110627. * @param options defines the options used to create the mesh
  110628. * @param scene defines the hosting scene
  110629. * @returns the custom extruded shape mesh
  110630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110631. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110633. */
  110634. static ExtrudeShapeCustom(name: string, options: {
  110635. shape: Vector3[];
  110636. path: Vector3[];
  110637. scaleFunction?: any;
  110638. rotationFunction?: any;
  110639. ribbonCloseArray?: boolean;
  110640. ribbonClosePath?: boolean;
  110641. cap?: number;
  110642. updatable?: boolean;
  110643. sideOrientation?: number;
  110644. frontUVs?: Vector4;
  110645. backUVs?: Vector4;
  110646. instance?: Mesh;
  110647. invertUV?: boolean;
  110648. }, scene?: Nullable<Scene>): Mesh;
  110649. /**
  110650. * Creates lathe mesh.
  110651. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110652. * * 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
  110653. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110654. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110655. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110656. * * 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
  110657. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110658. * * 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
  110659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110661. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110663. * @param name defines the name of the mesh
  110664. * @param options defines the options used to create the mesh
  110665. * @param scene defines the hosting scene
  110666. * @returns the lathe mesh
  110667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110668. */
  110669. static CreateLathe(name: string, options: {
  110670. shape: Vector3[];
  110671. radius?: number;
  110672. tessellation?: number;
  110673. clip?: number;
  110674. arc?: number;
  110675. closed?: boolean;
  110676. updatable?: boolean;
  110677. sideOrientation?: number;
  110678. frontUVs?: Vector4;
  110679. backUVs?: Vector4;
  110680. cap?: number;
  110681. invertUV?: boolean;
  110682. }, scene?: Nullable<Scene>): Mesh;
  110683. /**
  110684. * Creates a plane mesh
  110685. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110686. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110687. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110691. * @param name defines the name of the mesh
  110692. * @param options defines the options used to create the mesh
  110693. * @param scene defines the hosting scene
  110694. * @returns the plane mesh
  110695. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110696. */
  110697. static CreatePlane(name: string, options: {
  110698. size?: number;
  110699. width?: number;
  110700. height?: number;
  110701. sideOrientation?: number;
  110702. frontUVs?: Vector4;
  110703. backUVs?: Vector4;
  110704. updatable?: boolean;
  110705. sourcePlane?: Plane;
  110706. }, scene?: Nullable<Scene>): Mesh;
  110707. /**
  110708. * Creates a ground mesh
  110709. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110710. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110712. * @param name defines the name of the mesh
  110713. * @param options defines the options used to create the mesh
  110714. * @param scene defines the hosting scene
  110715. * @returns the ground mesh
  110716. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110717. */
  110718. static CreateGround(name: string, options: {
  110719. width?: number;
  110720. height?: number;
  110721. subdivisions?: number;
  110722. subdivisionsX?: number;
  110723. subdivisionsY?: number;
  110724. updatable?: boolean;
  110725. }, scene?: Nullable<Scene>): Mesh;
  110726. /**
  110727. * Creates a tiled ground mesh
  110728. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110729. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110730. * * 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
  110731. * * 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
  110732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110733. * @param name defines the name of the mesh
  110734. * @param options defines the options used to create the mesh
  110735. * @param scene defines the hosting scene
  110736. * @returns the tiled ground mesh
  110737. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110738. */
  110739. static CreateTiledGround(name: string, options: {
  110740. xmin: number;
  110741. zmin: number;
  110742. xmax: number;
  110743. zmax: number;
  110744. subdivisions?: {
  110745. w: number;
  110746. h: number;
  110747. };
  110748. precision?: {
  110749. w: number;
  110750. h: number;
  110751. };
  110752. updatable?: boolean;
  110753. }, scene?: Nullable<Scene>): Mesh;
  110754. /**
  110755. * Creates a ground mesh from a height map
  110756. * * The parameter `url` sets the URL of the height map image resource.
  110757. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110758. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110759. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110760. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110761. * * 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.
  110762. * * 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).
  110763. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110765. * @param name defines the name of the mesh
  110766. * @param url defines the url to the height map
  110767. * @param options defines the options used to create the mesh
  110768. * @param scene defines the hosting scene
  110769. * @returns the ground mesh
  110770. * @see https://doc.babylonjs.com/babylon101/height_map
  110771. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110772. */
  110773. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110774. width?: number;
  110775. height?: number;
  110776. subdivisions?: number;
  110777. minHeight?: number;
  110778. maxHeight?: number;
  110779. colorFilter?: Color3;
  110780. alphaFilter?: number;
  110781. updatable?: boolean;
  110782. onReady?: (mesh: GroundMesh) => void;
  110783. }, scene?: Nullable<Scene>): GroundMesh;
  110784. /**
  110785. * Creates a polygon mesh
  110786. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110787. * * 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
  110788. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110791. * * Remember you can only change the shape positions, not their number when updating a polygon
  110792. * @param name defines the name of the mesh
  110793. * @param options defines the options used to create the mesh
  110794. * @param scene defines the hosting scene
  110795. * @param earcutInjection can be used to inject your own earcut reference
  110796. * @returns the polygon mesh
  110797. */
  110798. static CreatePolygon(name: string, options: {
  110799. shape: Vector3[];
  110800. holes?: Vector3[][];
  110801. depth?: number;
  110802. faceUV?: Vector4[];
  110803. faceColors?: Color4[];
  110804. updatable?: boolean;
  110805. sideOrientation?: number;
  110806. frontUVs?: Vector4;
  110807. backUVs?: Vector4;
  110808. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110809. /**
  110810. * Creates an extruded polygon mesh, with depth in the Y direction.
  110811. * * 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)
  110812. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110813. * @param name defines the name of the mesh
  110814. * @param options defines the options used to create the mesh
  110815. * @param scene defines the hosting scene
  110816. * @param earcutInjection can be used to inject your own earcut reference
  110817. * @returns the polygon mesh
  110818. */
  110819. static ExtrudePolygon(name: string, options: {
  110820. shape: Vector3[];
  110821. holes?: Vector3[][];
  110822. depth?: number;
  110823. faceUV?: Vector4[];
  110824. faceColors?: Color4[];
  110825. updatable?: boolean;
  110826. sideOrientation?: number;
  110827. frontUVs?: Vector4;
  110828. backUVs?: Vector4;
  110829. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110830. /**
  110831. * Creates a tube mesh.
  110832. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110833. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110834. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110835. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110836. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110837. * * 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)
  110838. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110839. * * 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
  110840. * * 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
  110841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110845. * @param name defines the name of the mesh
  110846. * @param options defines the options used to create the mesh
  110847. * @param scene defines the hosting scene
  110848. * @returns the tube mesh
  110849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110850. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110851. */
  110852. static CreateTube(name: string, options: {
  110853. path: Vector3[];
  110854. radius?: number;
  110855. tessellation?: number;
  110856. radiusFunction?: {
  110857. (i: number, distance: number): number;
  110858. };
  110859. cap?: number;
  110860. arc?: number;
  110861. updatable?: boolean;
  110862. sideOrientation?: number;
  110863. frontUVs?: Vector4;
  110864. backUVs?: Vector4;
  110865. instance?: Mesh;
  110866. invertUV?: boolean;
  110867. }, scene?: Nullable<Scene>): Mesh;
  110868. /**
  110869. * Creates a polyhedron mesh
  110870. * * 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
  110871. * * The parameter `size` (positive float, default 1) sets the polygon size
  110872. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110873. * * 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`
  110874. * * 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
  110875. * * 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)`)
  110876. * * 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
  110877. * * 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
  110878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110881. * @param name defines the name of the mesh
  110882. * @param options defines the options used to create the mesh
  110883. * @param scene defines the hosting scene
  110884. * @returns the polyhedron mesh
  110885. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110886. */
  110887. static CreatePolyhedron(name: string, options: {
  110888. type?: number;
  110889. size?: number;
  110890. sizeX?: number;
  110891. sizeY?: number;
  110892. sizeZ?: number;
  110893. custom?: any;
  110894. faceUV?: Vector4[];
  110895. faceColors?: Color4[];
  110896. flat?: boolean;
  110897. updatable?: boolean;
  110898. sideOrientation?: number;
  110899. frontUVs?: Vector4;
  110900. backUVs?: Vector4;
  110901. }, scene?: Nullable<Scene>): Mesh;
  110902. /**
  110903. * Creates a decal mesh.
  110904. * 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
  110905. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110906. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110907. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110908. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110909. * @param name defines the name of the mesh
  110910. * @param sourceMesh defines the mesh where the decal must be applied
  110911. * @param options defines the options used to create the mesh
  110912. * @param scene defines the hosting scene
  110913. * @returns the decal mesh
  110914. * @see https://doc.babylonjs.com/how_to/decals
  110915. */
  110916. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110917. position?: Vector3;
  110918. normal?: Vector3;
  110919. size?: Vector3;
  110920. angle?: number;
  110921. }): Mesh;
  110922. }
  110923. }
  110924. declare module BABYLON {
  110925. /**
  110926. * A simplifier interface for future simplification implementations
  110927. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110928. */
  110929. export interface ISimplifier {
  110930. /**
  110931. * Simplification of a given mesh according to the given settings.
  110932. * Since this requires computation, it is assumed that the function runs async.
  110933. * @param settings The settings of the simplification, including quality and distance
  110934. * @param successCallback A callback that will be called after the mesh was simplified.
  110935. * @param errorCallback in case of an error, this callback will be called. optional.
  110936. */
  110937. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110938. }
  110939. /**
  110940. * Expected simplification settings.
  110941. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110942. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110943. */
  110944. export interface ISimplificationSettings {
  110945. /**
  110946. * Gets or sets the expected quality
  110947. */
  110948. quality: number;
  110949. /**
  110950. * Gets or sets the distance when this optimized version should be used
  110951. */
  110952. distance: number;
  110953. /**
  110954. * Gets an already optimized mesh
  110955. */
  110956. optimizeMesh?: boolean;
  110957. }
  110958. /**
  110959. * Class used to specify simplification options
  110960. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110961. */
  110962. export class SimplificationSettings implements ISimplificationSettings {
  110963. /** expected quality */
  110964. quality: number;
  110965. /** distance when this optimized version should be used */
  110966. distance: number;
  110967. /** already optimized mesh */
  110968. optimizeMesh?: boolean | undefined;
  110969. /**
  110970. * Creates a SimplificationSettings
  110971. * @param quality expected quality
  110972. * @param distance distance when this optimized version should be used
  110973. * @param optimizeMesh already optimized mesh
  110974. */
  110975. constructor(
  110976. /** expected quality */
  110977. quality: number,
  110978. /** distance when this optimized version should be used */
  110979. distance: number,
  110980. /** already optimized mesh */
  110981. optimizeMesh?: boolean | undefined);
  110982. }
  110983. /**
  110984. * Interface used to define a simplification task
  110985. */
  110986. export interface ISimplificationTask {
  110987. /**
  110988. * Array of settings
  110989. */
  110990. settings: Array<ISimplificationSettings>;
  110991. /**
  110992. * Simplification type
  110993. */
  110994. simplificationType: SimplificationType;
  110995. /**
  110996. * Mesh to simplify
  110997. */
  110998. mesh: Mesh;
  110999. /**
  111000. * Callback called on success
  111001. */
  111002. successCallback?: () => void;
  111003. /**
  111004. * Defines if parallel processing can be used
  111005. */
  111006. parallelProcessing: boolean;
  111007. }
  111008. /**
  111009. * Queue used to order the simplification tasks
  111010. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111011. */
  111012. export class SimplificationQueue {
  111013. private _simplificationArray;
  111014. /**
  111015. * Gets a boolean indicating that the process is still running
  111016. */
  111017. running: boolean;
  111018. /**
  111019. * Creates a new queue
  111020. */
  111021. constructor();
  111022. /**
  111023. * Adds a new simplification task
  111024. * @param task defines a task to add
  111025. */
  111026. addTask(task: ISimplificationTask): void;
  111027. /**
  111028. * Execute next task
  111029. */
  111030. executeNext(): void;
  111031. /**
  111032. * Execute a simplification task
  111033. * @param task defines the task to run
  111034. */
  111035. runSimplification(task: ISimplificationTask): void;
  111036. private getSimplifier;
  111037. }
  111038. /**
  111039. * The implemented types of simplification
  111040. * At the moment only Quadratic Error Decimation is implemented
  111041. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111042. */
  111043. export enum SimplificationType {
  111044. /** Quadratic error decimation */
  111045. QUADRATIC = 0
  111046. }
  111047. }
  111048. declare module BABYLON {
  111049. interface Scene {
  111050. /** @hidden (Backing field) */
  111051. _simplificationQueue: SimplificationQueue;
  111052. /**
  111053. * Gets or sets the simplification queue attached to the scene
  111054. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111055. */
  111056. simplificationQueue: SimplificationQueue;
  111057. }
  111058. interface Mesh {
  111059. /**
  111060. * Simplify the mesh according to the given array of settings.
  111061. * Function will return immediately and will simplify async
  111062. * @param settings a collection of simplification settings
  111063. * @param parallelProcessing should all levels calculate parallel or one after the other
  111064. * @param simplificationType the type of simplification to run
  111065. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111066. * @returns the current mesh
  111067. */
  111068. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111069. }
  111070. /**
  111071. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111072. * created in a scene
  111073. */
  111074. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111075. /**
  111076. * The component name helpfull to identify the component in the list of scene components.
  111077. */
  111078. readonly name: string;
  111079. /**
  111080. * The scene the component belongs to.
  111081. */
  111082. scene: Scene;
  111083. /**
  111084. * Creates a new instance of the component for the given scene
  111085. * @param scene Defines the scene to register the component in
  111086. */
  111087. constructor(scene: Scene);
  111088. /**
  111089. * Registers the component in a given scene
  111090. */
  111091. register(): void;
  111092. /**
  111093. * Rebuilds the elements related to this component in case of
  111094. * context lost for instance.
  111095. */
  111096. rebuild(): void;
  111097. /**
  111098. * Disposes the component and the associated ressources
  111099. */
  111100. dispose(): void;
  111101. private _beforeCameraUpdate;
  111102. }
  111103. }
  111104. declare module BABYLON {
  111105. /**
  111106. * Class used to enable access to IndexedDB
  111107. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111108. */
  111109. export class Database implements IOfflineProvider {
  111110. private _callbackManifestChecked;
  111111. private _currentSceneUrl;
  111112. private _db;
  111113. private _enableSceneOffline;
  111114. private _enableTexturesOffline;
  111115. private _manifestVersionFound;
  111116. private _mustUpdateRessources;
  111117. private _hasReachedQuota;
  111118. private _isSupported;
  111119. private _idbFactory;
  111120. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111121. private static IsUASupportingBlobStorage;
  111122. /**
  111123. * Gets a boolean indicating if Database storate is enabled (off by default)
  111124. */
  111125. static IDBStorageEnabled: boolean;
  111126. /**
  111127. * Gets a boolean indicating if scene must be saved in the database
  111128. */
  111129. readonly enableSceneOffline: boolean;
  111130. /**
  111131. * Gets a boolean indicating if textures must be saved in the database
  111132. */
  111133. readonly enableTexturesOffline: boolean;
  111134. /**
  111135. * Creates a new Database
  111136. * @param urlToScene defines the url to load the scene
  111137. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111138. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111139. */
  111140. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111141. private static _ParseURL;
  111142. private static _ReturnFullUrlLocation;
  111143. private _checkManifestFile;
  111144. /**
  111145. * Open the database and make it available
  111146. * @param successCallback defines the callback to call on success
  111147. * @param errorCallback defines the callback to call on error
  111148. */
  111149. open(successCallback: () => void, errorCallback: () => void): void;
  111150. /**
  111151. * Loads an image from the database
  111152. * @param url defines the url to load from
  111153. * @param image defines the target DOM image
  111154. */
  111155. loadImage(url: string, image: HTMLImageElement): void;
  111156. private _loadImageFromDBAsync;
  111157. private _saveImageIntoDBAsync;
  111158. private _checkVersionFromDB;
  111159. private _loadVersionFromDBAsync;
  111160. private _saveVersionIntoDBAsync;
  111161. /**
  111162. * Loads a file from database
  111163. * @param url defines the URL to load from
  111164. * @param sceneLoaded defines a callback to call on success
  111165. * @param progressCallBack defines a callback to call when progress changed
  111166. * @param errorCallback defines a callback to call on error
  111167. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111168. */
  111169. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111170. private _loadFileAsync;
  111171. private _saveFileAsync;
  111172. /**
  111173. * Validates if xhr data is correct
  111174. * @param xhr defines the request to validate
  111175. * @param dataType defines the expected data type
  111176. * @returns true if data is correct
  111177. */
  111178. private static _ValidateXHRData;
  111179. }
  111180. }
  111181. declare module BABYLON {
  111182. /** @hidden */
  111183. export var gpuUpdateParticlesPixelShader: {
  111184. name: string;
  111185. shader: string;
  111186. };
  111187. }
  111188. declare module BABYLON {
  111189. /** @hidden */
  111190. export var gpuUpdateParticlesVertexShader: {
  111191. name: string;
  111192. shader: string;
  111193. };
  111194. }
  111195. declare module BABYLON {
  111196. /** @hidden */
  111197. export var clipPlaneFragmentDeclaration2: {
  111198. name: string;
  111199. shader: string;
  111200. };
  111201. }
  111202. declare module BABYLON {
  111203. /** @hidden */
  111204. export var gpuRenderParticlesPixelShader: {
  111205. name: string;
  111206. shader: string;
  111207. };
  111208. }
  111209. declare module BABYLON {
  111210. /** @hidden */
  111211. export var clipPlaneVertexDeclaration2: {
  111212. name: string;
  111213. shader: string;
  111214. };
  111215. }
  111216. declare module BABYLON {
  111217. /** @hidden */
  111218. export var gpuRenderParticlesVertexShader: {
  111219. name: string;
  111220. shader: string;
  111221. };
  111222. }
  111223. declare module BABYLON {
  111224. /**
  111225. * This represents a GPU particle system in Babylon
  111226. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111227. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111228. */
  111229. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111230. /**
  111231. * The layer mask we are rendering the particles through.
  111232. */
  111233. layerMask: number;
  111234. private _capacity;
  111235. private _activeCount;
  111236. private _currentActiveCount;
  111237. private _accumulatedCount;
  111238. private _renderEffect;
  111239. private _updateEffect;
  111240. private _buffer0;
  111241. private _buffer1;
  111242. private _spriteBuffer;
  111243. private _updateVAO;
  111244. private _renderVAO;
  111245. private _targetIndex;
  111246. private _sourceBuffer;
  111247. private _targetBuffer;
  111248. private _engine;
  111249. private _currentRenderId;
  111250. private _started;
  111251. private _stopped;
  111252. private _timeDelta;
  111253. private _randomTexture;
  111254. private _randomTexture2;
  111255. private _attributesStrideSize;
  111256. private _updateEffectOptions;
  111257. private _randomTextureSize;
  111258. private _actualFrame;
  111259. private readonly _rawTextureWidth;
  111260. /**
  111261. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111262. */
  111263. static readonly IsSupported: boolean;
  111264. /**
  111265. * An event triggered when the system is disposed.
  111266. */
  111267. onDisposeObservable: Observable<GPUParticleSystem>;
  111268. /**
  111269. * Gets the maximum number of particles active at the same time.
  111270. * @returns The max number of active particles.
  111271. */
  111272. getCapacity(): number;
  111273. /**
  111274. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111275. * to override the particles.
  111276. */
  111277. forceDepthWrite: boolean;
  111278. /**
  111279. * Gets or set the number of active particles
  111280. */
  111281. activeParticleCount: number;
  111282. private _preWarmDone;
  111283. /**
  111284. * Is this system ready to be used/rendered
  111285. * @return true if the system is ready
  111286. */
  111287. isReady(): boolean;
  111288. /**
  111289. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111290. * @returns True if it has been started, otherwise false.
  111291. */
  111292. isStarted(): boolean;
  111293. /**
  111294. * Starts the particle system and begins to emit
  111295. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111296. */
  111297. start(delay?: number): void;
  111298. /**
  111299. * Stops the particle system.
  111300. */
  111301. stop(): void;
  111302. /**
  111303. * Remove all active particles
  111304. */
  111305. reset(): void;
  111306. /**
  111307. * Returns the string "GPUParticleSystem"
  111308. * @returns a string containing the class name
  111309. */
  111310. getClassName(): string;
  111311. private _colorGradientsTexture;
  111312. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111313. /**
  111314. * Adds a new color gradient
  111315. * @param gradient defines the gradient to use (between 0 and 1)
  111316. * @param color1 defines the color to affect to the specified gradient
  111317. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111318. * @returns the current particle system
  111319. */
  111320. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111321. /**
  111322. * Remove a specific color gradient
  111323. * @param gradient defines the gradient to remove
  111324. * @returns the current particle system
  111325. */
  111326. removeColorGradient(gradient: number): GPUParticleSystem;
  111327. private _angularSpeedGradientsTexture;
  111328. private _sizeGradientsTexture;
  111329. private _velocityGradientsTexture;
  111330. private _limitVelocityGradientsTexture;
  111331. private _dragGradientsTexture;
  111332. private _addFactorGradient;
  111333. /**
  111334. * Adds a new size gradient
  111335. * @param gradient defines the gradient to use (between 0 and 1)
  111336. * @param factor defines the size factor to affect to the specified gradient
  111337. * @returns the current particle system
  111338. */
  111339. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111340. /**
  111341. * Remove a specific size gradient
  111342. * @param gradient defines the gradient to remove
  111343. * @returns the current particle system
  111344. */
  111345. removeSizeGradient(gradient: number): GPUParticleSystem;
  111346. /**
  111347. * Adds a new angular speed gradient
  111348. * @param gradient defines the gradient to use (between 0 and 1)
  111349. * @param factor defines the angular speed to affect to the specified gradient
  111350. * @returns the current particle system
  111351. */
  111352. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111353. /**
  111354. * Remove a specific angular speed gradient
  111355. * @param gradient defines the gradient to remove
  111356. * @returns the current particle system
  111357. */
  111358. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111359. /**
  111360. * Adds a new velocity gradient
  111361. * @param gradient defines the gradient to use (between 0 and 1)
  111362. * @param factor defines the velocity to affect to the specified gradient
  111363. * @returns the current particle system
  111364. */
  111365. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111366. /**
  111367. * Remove a specific velocity gradient
  111368. * @param gradient defines the gradient to remove
  111369. * @returns the current particle system
  111370. */
  111371. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111372. /**
  111373. * Adds a new limit velocity gradient
  111374. * @param gradient defines the gradient to use (between 0 and 1)
  111375. * @param factor defines the limit velocity value to affect to the specified gradient
  111376. * @returns the current particle system
  111377. */
  111378. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111379. /**
  111380. * Remove a specific limit velocity gradient
  111381. * @param gradient defines the gradient to remove
  111382. * @returns the current particle system
  111383. */
  111384. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111385. /**
  111386. * Adds a new drag gradient
  111387. * @param gradient defines the gradient to use (between 0 and 1)
  111388. * @param factor defines the drag value to affect to the specified gradient
  111389. * @returns the current particle system
  111390. */
  111391. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111392. /**
  111393. * Remove a specific drag gradient
  111394. * @param gradient defines the gradient to remove
  111395. * @returns the current particle system
  111396. */
  111397. removeDragGradient(gradient: number): GPUParticleSystem;
  111398. /**
  111399. * Not supported by GPUParticleSystem
  111400. * @param gradient defines the gradient to use (between 0 and 1)
  111401. * @param factor defines the emit rate value to affect to the specified gradient
  111402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111403. * @returns the current particle system
  111404. */
  111405. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111406. /**
  111407. * Not supported by GPUParticleSystem
  111408. * @param gradient defines the gradient to remove
  111409. * @returns the current particle system
  111410. */
  111411. removeEmitRateGradient(gradient: number): IParticleSystem;
  111412. /**
  111413. * Not supported by GPUParticleSystem
  111414. * @param gradient defines the gradient to use (between 0 and 1)
  111415. * @param factor defines the start size value to affect to the specified gradient
  111416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111417. * @returns the current particle system
  111418. */
  111419. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111420. /**
  111421. * Not supported by GPUParticleSystem
  111422. * @param gradient defines the gradient to remove
  111423. * @returns the current particle system
  111424. */
  111425. removeStartSizeGradient(gradient: number): IParticleSystem;
  111426. /**
  111427. * Not supported by GPUParticleSystem
  111428. * @param gradient defines the gradient to use (between 0 and 1)
  111429. * @param min defines the color remap minimal range
  111430. * @param max defines the color remap maximal range
  111431. * @returns the current particle system
  111432. */
  111433. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111434. /**
  111435. * Not supported by GPUParticleSystem
  111436. * @param gradient defines the gradient to remove
  111437. * @returns the current particle system
  111438. */
  111439. removeColorRemapGradient(): IParticleSystem;
  111440. /**
  111441. * Not supported by GPUParticleSystem
  111442. * @param gradient defines the gradient to use (between 0 and 1)
  111443. * @param min defines the alpha remap minimal range
  111444. * @param max defines the alpha remap maximal range
  111445. * @returns the current particle system
  111446. */
  111447. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111448. /**
  111449. * Not supported by GPUParticleSystem
  111450. * @param gradient defines the gradient to remove
  111451. * @returns the current particle system
  111452. */
  111453. removeAlphaRemapGradient(): IParticleSystem;
  111454. /**
  111455. * Not supported by GPUParticleSystem
  111456. * @param gradient defines the gradient to use (between 0 and 1)
  111457. * @param color defines the color to affect to the specified gradient
  111458. * @returns the current particle system
  111459. */
  111460. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111461. /**
  111462. * Not supported by GPUParticleSystem
  111463. * @param gradient defines the gradient to remove
  111464. * @returns the current particle system
  111465. */
  111466. removeRampGradient(): IParticleSystem;
  111467. /**
  111468. * Not supported by GPUParticleSystem
  111469. * @returns the list of ramp gradients
  111470. */
  111471. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111472. /**
  111473. * Not supported by GPUParticleSystem
  111474. * Gets or sets a boolean indicating that ramp gradients must be used
  111475. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111476. */
  111477. useRampGradients: boolean;
  111478. /**
  111479. * Not supported by GPUParticleSystem
  111480. * @param gradient defines the gradient to use (between 0 and 1)
  111481. * @param factor defines the life time factor to affect to the specified gradient
  111482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111483. * @returns the current particle system
  111484. */
  111485. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111486. /**
  111487. * Not supported by GPUParticleSystem
  111488. * @param gradient defines the gradient to remove
  111489. * @returns the current particle system
  111490. */
  111491. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111492. /**
  111493. * Instantiates a GPU particle system.
  111494. * 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.
  111495. * @param name The name of the particle system
  111496. * @param options The options used to create the system
  111497. * @param scene The scene the particle system belongs to
  111498. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111499. */
  111500. constructor(name: string, options: Partial<{
  111501. capacity: number;
  111502. randomTextureSize: number;
  111503. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111504. protected _reset(): void;
  111505. private _createUpdateVAO;
  111506. private _createRenderVAO;
  111507. private _initialize;
  111508. /** @hidden */
  111509. _recreateUpdateEffect(): void;
  111510. /** @hidden */
  111511. _recreateRenderEffect(): void;
  111512. /**
  111513. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111514. * @param preWarm defines if we are in the pre-warmimg phase
  111515. */
  111516. animate(preWarm?: boolean): void;
  111517. private _createFactorGradientTexture;
  111518. private _createSizeGradientTexture;
  111519. private _createAngularSpeedGradientTexture;
  111520. private _createVelocityGradientTexture;
  111521. private _createLimitVelocityGradientTexture;
  111522. private _createDragGradientTexture;
  111523. private _createColorGradientTexture;
  111524. /**
  111525. * Renders the particle system in its current state
  111526. * @param preWarm defines if the system should only update the particles but not render them
  111527. * @returns the current number of particles
  111528. */
  111529. render(preWarm?: boolean): number;
  111530. /**
  111531. * Rebuilds the particle system
  111532. */
  111533. rebuild(): void;
  111534. private _releaseBuffers;
  111535. private _releaseVAOs;
  111536. /**
  111537. * Disposes the particle system and free the associated resources
  111538. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111539. */
  111540. dispose(disposeTexture?: boolean): void;
  111541. /**
  111542. * Clones the particle system.
  111543. * @param name The name of the cloned object
  111544. * @param newEmitter The new emitter to use
  111545. * @returns the cloned particle system
  111546. */
  111547. clone(name: string, newEmitter: any): GPUParticleSystem;
  111548. /**
  111549. * Serializes the particle system to a JSON object.
  111550. * @returns the JSON object
  111551. */
  111552. serialize(): any;
  111553. /**
  111554. * Parses a JSON object to create a GPU particle system.
  111555. * @param parsedParticleSystem The JSON object to parse
  111556. * @param scene The scene to create the particle system in
  111557. * @param rootUrl The root url to use to load external dependencies like texture
  111558. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111559. * @returns the parsed GPU particle system
  111560. */
  111561. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111562. }
  111563. }
  111564. declare module BABYLON {
  111565. /**
  111566. * Represents a set of particle systems working together to create a specific effect
  111567. */
  111568. export class ParticleSystemSet implements IDisposable {
  111569. private _emitterCreationOptions;
  111570. private _emitterNode;
  111571. /**
  111572. * Gets the particle system list
  111573. */
  111574. systems: IParticleSystem[];
  111575. /**
  111576. * Gets the emitter node used with this set
  111577. */
  111578. readonly emitterNode: Nullable<TransformNode>;
  111579. /**
  111580. * Creates a new emitter mesh as a sphere
  111581. * @param options defines the options used to create the sphere
  111582. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111583. * @param scene defines the hosting scene
  111584. */
  111585. setEmitterAsSphere(options: {
  111586. diameter: number;
  111587. segments: number;
  111588. color: Color3;
  111589. }, renderingGroupId: number, scene: Scene): void;
  111590. /**
  111591. * Starts all particle systems of the set
  111592. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111593. */
  111594. start(emitter?: AbstractMesh): void;
  111595. /**
  111596. * Release all associated resources
  111597. */
  111598. dispose(): void;
  111599. /**
  111600. * Serialize the set into a JSON compatible object
  111601. * @returns a JSON compatible representation of the set
  111602. */
  111603. serialize(): any;
  111604. /**
  111605. * Parse a new ParticleSystemSet from a serialized source
  111606. * @param data defines a JSON compatible representation of the set
  111607. * @param scene defines the hosting scene
  111608. * @param gpu defines if we want GPU particles or CPU particles
  111609. * @returns a new ParticleSystemSet
  111610. */
  111611. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111612. }
  111613. }
  111614. declare module BABYLON {
  111615. /**
  111616. * This class is made for on one-liner static method to help creating particle system set.
  111617. */
  111618. export class ParticleHelper {
  111619. /**
  111620. * Gets or sets base Assets URL
  111621. */
  111622. static BaseAssetsUrl: string;
  111623. /**
  111624. * Create a default particle system that you can tweak
  111625. * @param emitter defines the emitter to use
  111626. * @param capacity defines the system capacity (default is 500 particles)
  111627. * @param scene defines the hosting scene
  111628. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111629. * @returns the new Particle system
  111630. */
  111631. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111632. /**
  111633. * This is the main static method (one-liner) of this helper to create different particle systems
  111634. * @param type This string represents the type to the particle system to create
  111635. * @param scene The scene where the particle system should live
  111636. * @param gpu If the system will use gpu
  111637. * @returns the ParticleSystemSet created
  111638. */
  111639. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111640. /**
  111641. * Static function used to export a particle system to a ParticleSystemSet variable.
  111642. * Please note that the emitter shape is not exported
  111643. * @param systems defines the particle systems to export
  111644. * @returns the created particle system set
  111645. */
  111646. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111647. }
  111648. }
  111649. declare module BABYLON {
  111650. interface Engine {
  111651. /**
  111652. * Create an effect to use with particle systems.
  111653. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111654. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111655. * @param uniformsNames defines a list of attribute names
  111656. * @param samplers defines an array of string used to represent textures
  111657. * @param defines defines the string containing the defines to use to compile the shaders
  111658. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111659. * @param onCompiled defines a function to call when the effect creation is successful
  111660. * @param onError defines a function to call when the effect creation has failed
  111661. * @returns the new Effect
  111662. */
  111663. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111664. }
  111665. interface Mesh {
  111666. /**
  111667. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111668. * @returns an array of IParticleSystem
  111669. */
  111670. getEmittedParticleSystems(): IParticleSystem[];
  111671. /**
  111672. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111673. * @returns an array of IParticleSystem
  111674. */
  111675. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111676. }
  111677. /**
  111678. * @hidden
  111679. */
  111680. export var _IDoNeedToBeInTheBuild: number;
  111681. }
  111682. declare module BABYLON {
  111683. interface Scene {
  111684. /** @hidden (Backing field) */
  111685. _physicsEngine: Nullable<IPhysicsEngine>;
  111686. /**
  111687. * Gets the current physics engine
  111688. * @returns a IPhysicsEngine or null if none attached
  111689. */
  111690. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111691. /**
  111692. * Enables physics to the current scene
  111693. * @param gravity defines the scene's gravity for the physics engine
  111694. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111695. * @return a boolean indicating if the physics engine was initialized
  111696. */
  111697. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111698. /**
  111699. * Disables and disposes the physics engine associated with the scene
  111700. */
  111701. disablePhysicsEngine(): void;
  111702. /**
  111703. * Gets a boolean indicating if there is an active physics engine
  111704. * @returns a boolean indicating if there is an active physics engine
  111705. */
  111706. isPhysicsEnabled(): boolean;
  111707. /**
  111708. * Deletes a physics compound impostor
  111709. * @param compound defines the compound to delete
  111710. */
  111711. deleteCompoundImpostor(compound: any): void;
  111712. /**
  111713. * An event triggered when physic simulation is about to be run
  111714. */
  111715. onBeforePhysicsObservable: Observable<Scene>;
  111716. /**
  111717. * An event triggered when physic simulation has been done
  111718. */
  111719. onAfterPhysicsObservable: Observable<Scene>;
  111720. }
  111721. interface AbstractMesh {
  111722. /** @hidden */
  111723. _physicsImpostor: Nullable<PhysicsImpostor>;
  111724. /**
  111725. * Gets or sets impostor used for physic simulation
  111726. * @see http://doc.babylonjs.com/features/physics_engine
  111727. */
  111728. physicsImpostor: Nullable<PhysicsImpostor>;
  111729. /**
  111730. * Gets the current physics impostor
  111731. * @see http://doc.babylonjs.com/features/physics_engine
  111732. * @returns a physics impostor or null
  111733. */
  111734. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111735. /** Apply a physic impulse to the mesh
  111736. * @param force defines the force to apply
  111737. * @param contactPoint defines where to apply the force
  111738. * @returns the current mesh
  111739. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111740. */
  111741. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111742. /**
  111743. * Creates a physic joint between two meshes
  111744. * @param otherMesh defines the other mesh to use
  111745. * @param pivot1 defines the pivot to use on this mesh
  111746. * @param pivot2 defines the pivot to use on the other mesh
  111747. * @param options defines additional options (can be plugin dependent)
  111748. * @returns the current mesh
  111749. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111750. */
  111751. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111752. /** @hidden */
  111753. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111754. }
  111755. /**
  111756. * Defines the physics engine scene component responsible to manage a physics engine
  111757. */
  111758. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111759. /**
  111760. * The component name helpful to identify the component in the list of scene components.
  111761. */
  111762. readonly name: string;
  111763. /**
  111764. * The scene the component belongs to.
  111765. */
  111766. scene: Scene;
  111767. /**
  111768. * Creates a new instance of the component for the given scene
  111769. * @param scene Defines the scene to register the component in
  111770. */
  111771. constructor(scene: Scene);
  111772. /**
  111773. * Registers the component in a given scene
  111774. */
  111775. register(): void;
  111776. /**
  111777. * Rebuilds the elements related to this component in case of
  111778. * context lost for instance.
  111779. */
  111780. rebuild(): void;
  111781. /**
  111782. * Disposes the component and the associated ressources
  111783. */
  111784. dispose(): void;
  111785. }
  111786. }
  111787. declare module BABYLON {
  111788. /**
  111789. * A helper for physics simulations
  111790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111791. */
  111792. export class PhysicsHelper {
  111793. private _scene;
  111794. private _physicsEngine;
  111795. /**
  111796. * Initializes the Physics helper
  111797. * @param scene Babylon.js scene
  111798. */
  111799. constructor(scene: Scene);
  111800. /**
  111801. * Applies a radial explosion impulse
  111802. * @param origin the origin of the explosion
  111803. * @param radiusOrEventOptions the radius or the options of radial explosion
  111804. * @param strength the explosion strength
  111805. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111806. * @returns A physics radial explosion event, or null
  111807. */
  111808. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111809. /**
  111810. * Applies a radial explosion force
  111811. * @param origin the origin of the explosion
  111812. * @param radiusOrEventOptions the radius or the options of radial explosion
  111813. * @param strength the explosion strength
  111814. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111815. * @returns A physics radial explosion event, or null
  111816. */
  111817. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111818. /**
  111819. * Creates a gravitational field
  111820. * @param origin the origin of the explosion
  111821. * @param radiusOrEventOptions the radius or the options of radial explosion
  111822. * @param strength the explosion strength
  111823. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111824. * @returns A physics gravitational field event, or null
  111825. */
  111826. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111827. /**
  111828. * Creates a physics updraft event
  111829. * @param origin the origin of the updraft
  111830. * @param radiusOrEventOptions the radius or the options of the updraft
  111831. * @param strength the strength of the updraft
  111832. * @param height the height of the updraft
  111833. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111834. * @returns A physics updraft event, or null
  111835. */
  111836. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111837. /**
  111838. * Creates a physics vortex event
  111839. * @param origin the of the vortex
  111840. * @param radiusOrEventOptions the radius or the options of the vortex
  111841. * @param strength the strength of the vortex
  111842. * @param height the height of the vortex
  111843. * @returns a Physics vortex event, or null
  111844. * A physics vortex event or null
  111845. */
  111846. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111847. }
  111848. /**
  111849. * Represents a physics radial explosion event
  111850. */
  111851. class PhysicsRadialExplosionEvent {
  111852. private _scene;
  111853. private _options;
  111854. private _sphere;
  111855. private _dataFetched;
  111856. /**
  111857. * Initializes a radial explosioin event
  111858. * @param _scene BabylonJS scene
  111859. * @param _options The options for the vortex event
  111860. */
  111861. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111862. /**
  111863. * Returns the data related to the radial explosion event (sphere).
  111864. * @returns The radial explosion event data
  111865. */
  111866. getData(): PhysicsRadialExplosionEventData;
  111867. /**
  111868. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111869. * @param impostor A physics imposter
  111870. * @param origin the origin of the explosion
  111871. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111872. */
  111873. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111874. /**
  111875. * Triggers affecterd impostors callbacks
  111876. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111877. */
  111878. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111879. /**
  111880. * Disposes the sphere.
  111881. * @param force Specifies if the sphere should be disposed by force
  111882. */
  111883. dispose(force?: boolean): void;
  111884. /*** Helpers ***/
  111885. private _prepareSphere;
  111886. private _intersectsWithSphere;
  111887. }
  111888. /**
  111889. * Represents a gravitational field event
  111890. */
  111891. class PhysicsGravitationalFieldEvent {
  111892. private _physicsHelper;
  111893. private _scene;
  111894. private _origin;
  111895. private _options;
  111896. private _tickCallback;
  111897. private _sphere;
  111898. private _dataFetched;
  111899. /**
  111900. * Initializes the physics gravitational field event
  111901. * @param _physicsHelper A physics helper
  111902. * @param _scene BabylonJS scene
  111903. * @param _origin The origin position of the gravitational field event
  111904. * @param _options The options for the vortex event
  111905. */
  111906. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111907. /**
  111908. * Returns the data related to the gravitational field event (sphere).
  111909. * @returns A gravitational field event
  111910. */
  111911. getData(): PhysicsGravitationalFieldEventData;
  111912. /**
  111913. * Enables the gravitational field.
  111914. */
  111915. enable(): void;
  111916. /**
  111917. * Disables the gravitational field.
  111918. */
  111919. disable(): void;
  111920. /**
  111921. * Disposes the sphere.
  111922. * @param force The force to dispose from the gravitational field event
  111923. */
  111924. dispose(force?: boolean): void;
  111925. private _tick;
  111926. }
  111927. /**
  111928. * Represents a physics updraft event
  111929. */
  111930. class PhysicsUpdraftEvent {
  111931. private _scene;
  111932. private _origin;
  111933. private _options;
  111934. private _physicsEngine;
  111935. private _originTop;
  111936. private _originDirection;
  111937. private _tickCallback;
  111938. private _cylinder;
  111939. private _cylinderPosition;
  111940. private _dataFetched;
  111941. /**
  111942. * Initializes the physics updraft event
  111943. * @param _scene BabylonJS scene
  111944. * @param _origin The origin position of the updraft
  111945. * @param _options The options for the updraft event
  111946. */
  111947. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111948. /**
  111949. * Returns the data related to the updraft event (cylinder).
  111950. * @returns A physics updraft event
  111951. */
  111952. getData(): PhysicsUpdraftEventData;
  111953. /**
  111954. * Enables the updraft.
  111955. */
  111956. enable(): void;
  111957. /**
  111958. * Disables the updraft.
  111959. */
  111960. disable(): void;
  111961. /**
  111962. * Disposes the cylinder.
  111963. * @param force Specifies if the updraft should be disposed by force
  111964. */
  111965. dispose(force?: boolean): void;
  111966. private getImpostorHitData;
  111967. private _tick;
  111968. /*** Helpers ***/
  111969. private _prepareCylinder;
  111970. private _intersectsWithCylinder;
  111971. }
  111972. /**
  111973. * Represents a physics vortex event
  111974. */
  111975. class PhysicsVortexEvent {
  111976. private _scene;
  111977. private _origin;
  111978. private _options;
  111979. private _physicsEngine;
  111980. private _originTop;
  111981. private _tickCallback;
  111982. private _cylinder;
  111983. private _cylinderPosition;
  111984. private _dataFetched;
  111985. /**
  111986. * Initializes the physics vortex event
  111987. * @param _scene The BabylonJS scene
  111988. * @param _origin The origin position of the vortex
  111989. * @param _options The options for the vortex event
  111990. */
  111991. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111992. /**
  111993. * Returns the data related to the vortex event (cylinder).
  111994. * @returns The physics vortex event data
  111995. */
  111996. getData(): PhysicsVortexEventData;
  111997. /**
  111998. * Enables the vortex.
  111999. */
  112000. enable(): void;
  112001. /**
  112002. * Disables the cortex.
  112003. */
  112004. disable(): void;
  112005. /**
  112006. * Disposes the sphere.
  112007. * @param force
  112008. */
  112009. dispose(force?: boolean): void;
  112010. private getImpostorHitData;
  112011. private _tick;
  112012. /*** Helpers ***/
  112013. private _prepareCylinder;
  112014. private _intersectsWithCylinder;
  112015. }
  112016. /**
  112017. * Options fot the radial explosion event
  112018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112019. */
  112020. export class PhysicsRadialExplosionEventOptions {
  112021. /**
  112022. * The radius of the sphere for the radial explosion.
  112023. */
  112024. radius: number;
  112025. /**
  112026. * The strenth of the explosion.
  112027. */
  112028. strength: number;
  112029. /**
  112030. * The strenght of the force in correspondence to the distance of the affected object
  112031. */
  112032. falloff: PhysicsRadialImpulseFalloff;
  112033. /**
  112034. * Sphere options for the radial explosion.
  112035. */
  112036. sphere: {
  112037. segments: number;
  112038. diameter: number;
  112039. };
  112040. /**
  112041. * Sphere options for the radial explosion.
  112042. */
  112043. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112044. }
  112045. /**
  112046. * Options fot the updraft event
  112047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112048. */
  112049. export class PhysicsUpdraftEventOptions {
  112050. /**
  112051. * The radius of the cylinder for the vortex
  112052. */
  112053. radius: number;
  112054. /**
  112055. * The strenth of the updraft.
  112056. */
  112057. strength: number;
  112058. /**
  112059. * The height of the cylinder for the updraft.
  112060. */
  112061. height: number;
  112062. /**
  112063. * The mode for the the updraft.
  112064. */
  112065. updraftMode: PhysicsUpdraftMode;
  112066. }
  112067. /**
  112068. * Options fot the vortex event
  112069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112070. */
  112071. export class PhysicsVortexEventOptions {
  112072. /**
  112073. * The radius of the cylinder for the vortex
  112074. */
  112075. radius: number;
  112076. /**
  112077. * The strenth of the vortex.
  112078. */
  112079. strength: number;
  112080. /**
  112081. * The height of the cylinder for the vortex.
  112082. */
  112083. height: number;
  112084. /**
  112085. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112086. */
  112087. centripetalForceThreshold: number;
  112088. /**
  112089. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112090. */
  112091. centripetalForceMultiplier: number;
  112092. /**
  112093. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112094. */
  112095. centrifugalForceMultiplier: number;
  112096. /**
  112097. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112098. */
  112099. updraftForceMultiplier: number;
  112100. }
  112101. /**
  112102. * The strenght of the force in correspondence to the distance of the affected object
  112103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112104. */
  112105. export enum PhysicsRadialImpulseFalloff {
  112106. /** Defines that impulse is constant in strength across it's whole radius */
  112107. Constant = 0,
  112108. /** Defines that impulse gets weaker if it's further from the origin */
  112109. Linear = 1
  112110. }
  112111. /**
  112112. * The strength of the force in correspondence to the distance of the affected object
  112113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112114. */
  112115. export enum PhysicsUpdraftMode {
  112116. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112117. Center = 0,
  112118. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112119. Perpendicular = 1
  112120. }
  112121. /**
  112122. * Interface for a physics hit data
  112123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112124. */
  112125. export interface PhysicsHitData {
  112126. /**
  112127. * The force applied at the contact point
  112128. */
  112129. force: Vector3;
  112130. /**
  112131. * The contact point
  112132. */
  112133. contactPoint: Vector3;
  112134. /**
  112135. * The distance from the origin to the contact point
  112136. */
  112137. distanceFromOrigin: number;
  112138. }
  112139. /**
  112140. * Interface for radial explosion event data
  112141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112142. */
  112143. export interface PhysicsRadialExplosionEventData {
  112144. /**
  112145. * A sphere used for the radial explosion event
  112146. */
  112147. sphere: Mesh;
  112148. }
  112149. /**
  112150. * Interface for gravitational field event data
  112151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112152. */
  112153. export interface PhysicsGravitationalFieldEventData {
  112154. /**
  112155. * A sphere mesh used for the gravitational field event
  112156. */
  112157. sphere: Mesh;
  112158. }
  112159. /**
  112160. * Interface for updraft event data
  112161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112162. */
  112163. export interface PhysicsUpdraftEventData {
  112164. /**
  112165. * A cylinder used for the updraft event
  112166. */
  112167. cylinder: Mesh;
  112168. }
  112169. /**
  112170. * Interface for vortex event data
  112171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112172. */
  112173. export interface PhysicsVortexEventData {
  112174. /**
  112175. * A cylinder used for the vortex event
  112176. */
  112177. cylinder: Mesh;
  112178. }
  112179. /**
  112180. * Interface for an affected physics impostor
  112181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112182. */
  112183. export interface PhysicsAffectedImpostorWithData {
  112184. /**
  112185. * The impostor affected by the effect
  112186. */
  112187. impostor: PhysicsImpostor;
  112188. /**
  112189. * The data about the hit/horce from the explosion
  112190. */
  112191. hitData: PhysicsHitData;
  112192. }
  112193. }
  112194. declare module BABYLON {
  112195. /** @hidden */
  112196. export var blackAndWhitePixelShader: {
  112197. name: string;
  112198. shader: string;
  112199. };
  112200. }
  112201. declare module BABYLON {
  112202. /**
  112203. * Post process used to render in black and white
  112204. */
  112205. export class BlackAndWhitePostProcess extends PostProcess {
  112206. /**
  112207. * Linear about to convert he result to black and white (default: 1)
  112208. */
  112209. degree: number;
  112210. /**
  112211. * Creates a black and white post process
  112212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112213. * @param name The name of the effect.
  112214. * @param options The required width/height ratio to downsize to before computing the render pass.
  112215. * @param camera The camera to apply the render pass to.
  112216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112217. * @param engine The engine which the post process will be applied. (default: current engine)
  112218. * @param reusable If the post process can be reused on the same frame. (default: false)
  112219. */
  112220. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112221. }
  112222. }
  112223. declare module BABYLON {
  112224. /**
  112225. * This represents a set of one or more post processes in Babylon.
  112226. * A post process can be used to apply a shader to a texture after it is rendered.
  112227. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112228. */
  112229. export class PostProcessRenderEffect {
  112230. private _postProcesses;
  112231. private _getPostProcesses;
  112232. private _singleInstance;
  112233. private _cameras;
  112234. private _indicesForCamera;
  112235. /**
  112236. * Name of the effect
  112237. * @hidden
  112238. */
  112239. _name: string;
  112240. /**
  112241. * Instantiates a post process render effect.
  112242. * A post process can be used to apply a shader to a texture after it is rendered.
  112243. * @param engine The engine the effect is tied to
  112244. * @param name The name of the effect
  112245. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112246. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112247. */
  112248. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112249. /**
  112250. * Checks if all the post processes in the effect are supported.
  112251. */
  112252. readonly isSupported: boolean;
  112253. /**
  112254. * Updates the current state of the effect
  112255. * @hidden
  112256. */
  112257. _update(): void;
  112258. /**
  112259. * Attaches the effect on cameras
  112260. * @param cameras The camera to attach to.
  112261. * @hidden
  112262. */
  112263. _attachCameras(cameras: Camera): void;
  112264. /**
  112265. * Attaches the effect on cameras
  112266. * @param cameras The camera to attach to.
  112267. * @hidden
  112268. */
  112269. _attachCameras(cameras: Camera[]): void;
  112270. /**
  112271. * Detaches the effect on cameras
  112272. * @param cameras The camera to detatch from.
  112273. * @hidden
  112274. */
  112275. _detachCameras(cameras: Camera): void;
  112276. /**
  112277. * Detatches the effect on cameras
  112278. * @param cameras The camera to detatch from.
  112279. * @hidden
  112280. */
  112281. _detachCameras(cameras: Camera[]): void;
  112282. /**
  112283. * Enables the effect on given cameras
  112284. * @param cameras The camera to enable.
  112285. * @hidden
  112286. */
  112287. _enable(cameras: Camera): void;
  112288. /**
  112289. * Enables the effect on given cameras
  112290. * @param cameras The camera to enable.
  112291. * @hidden
  112292. */
  112293. _enable(cameras: Nullable<Camera[]>): void;
  112294. /**
  112295. * Disables the effect on the given cameras
  112296. * @param cameras The camera to disable.
  112297. * @hidden
  112298. */
  112299. _disable(cameras: Camera): void;
  112300. /**
  112301. * Disables the effect on the given cameras
  112302. * @param cameras The camera to disable.
  112303. * @hidden
  112304. */
  112305. _disable(cameras: Nullable<Camera[]>): void;
  112306. /**
  112307. * Gets a list of the post processes contained in the effect.
  112308. * @param camera The camera to get the post processes on.
  112309. * @returns The list of the post processes in the effect.
  112310. */
  112311. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112312. }
  112313. }
  112314. declare module BABYLON {
  112315. /** @hidden */
  112316. export var extractHighlightsPixelShader: {
  112317. name: string;
  112318. shader: string;
  112319. };
  112320. }
  112321. declare module BABYLON {
  112322. /**
  112323. * 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.
  112324. */
  112325. export class ExtractHighlightsPostProcess extends PostProcess {
  112326. /**
  112327. * The luminance threshold, pixels below this value will be set to black.
  112328. */
  112329. threshold: number;
  112330. /** @hidden */
  112331. _exposure: number;
  112332. /**
  112333. * Post process which has the input texture to be used when performing highlight extraction
  112334. * @hidden
  112335. */
  112336. _inputPostProcess: Nullable<PostProcess>;
  112337. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112338. }
  112339. }
  112340. declare module BABYLON {
  112341. /** @hidden */
  112342. export var bloomMergePixelShader: {
  112343. name: string;
  112344. shader: string;
  112345. };
  112346. }
  112347. declare module BABYLON {
  112348. /**
  112349. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112350. */
  112351. export class BloomMergePostProcess extends PostProcess {
  112352. /** Weight of the bloom to be added to the original input. */
  112353. weight: number;
  112354. /**
  112355. * Creates a new instance of @see BloomMergePostProcess
  112356. * @param name The name of the effect.
  112357. * @param originalFromInput Post process which's input will be used for the merge.
  112358. * @param blurred Blurred highlights post process which's output will be used.
  112359. * @param weight Weight of the bloom to be added to the original input.
  112360. * @param options The required width/height ratio to downsize to before computing the render pass.
  112361. * @param camera The camera to apply the render pass to.
  112362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112363. * @param engine The engine which the post process will be applied. (default: current engine)
  112364. * @param reusable If the post process can be reused on the same frame. (default: false)
  112365. * @param textureType Type of textures used when performing the post process. (default: 0)
  112366. * @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)
  112367. */
  112368. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112369. /** Weight of the bloom to be added to the original input. */
  112370. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112371. }
  112372. }
  112373. declare module BABYLON {
  112374. /**
  112375. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112376. */
  112377. export class BloomEffect extends PostProcessRenderEffect {
  112378. private bloomScale;
  112379. /**
  112380. * @hidden Internal
  112381. */
  112382. _effects: Array<PostProcess>;
  112383. /**
  112384. * @hidden Internal
  112385. */
  112386. _downscale: ExtractHighlightsPostProcess;
  112387. private _blurX;
  112388. private _blurY;
  112389. private _merge;
  112390. /**
  112391. * The luminance threshold to find bright areas of the image to bloom.
  112392. */
  112393. threshold: number;
  112394. /**
  112395. * The strength of the bloom.
  112396. */
  112397. weight: number;
  112398. /**
  112399. * Specifies the size of the bloom blur kernel, relative to the final output size
  112400. */
  112401. kernel: number;
  112402. /**
  112403. * Creates a new instance of @see BloomEffect
  112404. * @param scene The scene the effect belongs to.
  112405. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112406. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112407. * @param bloomWeight The the strength of bloom.
  112408. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112409. * @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)
  112410. */
  112411. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112412. /**
  112413. * Disposes each of the internal effects for a given camera.
  112414. * @param camera The camera to dispose the effect on.
  112415. */
  112416. disposeEffects(camera: Camera): void;
  112417. /**
  112418. * @hidden Internal
  112419. */
  112420. _updateEffects(): void;
  112421. /**
  112422. * Internal
  112423. * @returns if all the contained post processes are ready.
  112424. * @hidden
  112425. */
  112426. _isReady(): boolean;
  112427. }
  112428. }
  112429. declare module BABYLON {
  112430. /** @hidden */
  112431. export var chromaticAberrationPixelShader: {
  112432. name: string;
  112433. shader: string;
  112434. };
  112435. }
  112436. declare module BABYLON {
  112437. /**
  112438. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112439. */
  112440. export class ChromaticAberrationPostProcess extends PostProcess {
  112441. /**
  112442. * The amount of seperation of rgb channels (default: 30)
  112443. */
  112444. aberrationAmount: number;
  112445. /**
  112446. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112447. */
  112448. radialIntensity: number;
  112449. /**
  112450. * 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))
  112451. */
  112452. direction: Vector2;
  112453. /**
  112454. * 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))
  112455. */
  112456. centerPosition: Vector2;
  112457. /**
  112458. * Creates a new instance ChromaticAberrationPostProcess
  112459. * @param name The name of the effect.
  112460. * @param screenWidth The width of the screen to apply the effect on.
  112461. * @param screenHeight The height of the screen to apply the effect on.
  112462. * @param options The required width/height ratio to downsize to before computing the render pass.
  112463. * @param camera The camera to apply the render pass to.
  112464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112465. * @param engine The engine which the post process will be applied. (default: current engine)
  112466. * @param reusable If the post process can be reused on the same frame. (default: false)
  112467. * @param textureType Type of textures used when performing the post process. (default: 0)
  112468. * @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)
  112469. */
  112470. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112471. }
  112472. }
  112473. declare module BABYLON {
  112474. /** @hidden */
  112475. export var circleOfConfusionPixelShader: {
  112476. name: string;
  112477. shader: string;
  112478. };
  112479. }
  112480. declare module BABYLON {
  112481. /**
  112482. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112483. */
  112484. export class CircleOfConfusionPostProcess extends PostProcess {
  112485. /**
  112486. * 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.
  112487. */
  112488. lensSize: number;
  112489. /**
  112490. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112491. */
  112492. fStop: number;
  112493. /**
  112494. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112495. */
  112496. focusDistance: number;
  112497. /**
  112498. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112499. */
  112500. focalLength: number;
  112501. private _depthTexture;
  112502. /**
  112503. * Creates a new instance CircleOfConfusionPostProcess
  112504. * @param name The name of the effect.
  112505. * @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.
  112506. * @param options The required width/height ratio to downsize to before computing the render pass.
  112507. * @param camera The camera to apply the render pass to.
  112508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112509. * @param engine The engine which the post process will be applied. (default: current engine)
  112510. * @param reusable If the post process can be reused on the same frame. (default: false)
  112511. * @param textureType Type of textures used when performing the post process. (default: 0)
  112512. * @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)
  112513. */
  112514. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112515. /**
  112516. * 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.
  112517. */
  112518. depthTexture: RenderTargetTexture;
  112519. }
  112520. }
  112521. declare module BABYLON {
  112522. /** @hidden */
  112523. export var colorCorrectionPixelShader: {
  112524. name: string;
  112525. shader: string;
  112526. };
  112527. }
  112528. declare module BABYLON {
  112529. /**
  112530. *
  112531. * This post-process allows the modification of rendered colors by using
  112532. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112533. *
  112534. * The object needs to be provided an url to a texture containing the color
  112535. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112536. * Use an image editing software to tweak the LUT to match your needs.
  112537. *
  112538. * For an example of a color LUT, see here:
  112539. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112540. * For explanations on color grading, see here:
  112541. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112542. *
  112543. */
  112544. export class ColorCorrectionPostProcess extends PostProcess {
  112545. private _colorTableTexture;
  112546. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112547. }
  112548. }
  112549. declare module BABYLON {
  112550. /** @hidden */
  112551. export var convolutionPixelShader: {
  112552. name: string;
  112553. shader: string;
  112554. };
  112555. }
  112556. declare module BABYLON {
  112557. /**
  112558. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112559. * input texture to perform effects such as edge detection or sharpening
  112560. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112561. */
  112562. export class ConvolutionPostProcess extends PostProcess {
  112563. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112564. kernel: number[];
  112565. /**
  112566. * Creates a new instance ConvolutionPostProcess
  112567. * @param name The name of the effect.
  112568. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112569. * @param options The required width/height ratio to downsize to before computing the render pass.
  112570. * @param camera The camera to apply the render pass to.
  112571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112572. * @param engine The engine which the post process will be applied. (default: current engine)
  112573. * @param reusable If the post process can be reused on the same frame. (default: false)
  112574. * @param textureType Type of textures used when performing the post process. (default: 0)
  112575. */
  112576. constructor(name: string,
  112577. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112578. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112579. /**
  112580. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112581. */
  112582. static EdgeDetect0Kernel: number[];
  112583. /**
  112584. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112585. */
  112586. static EdgeDetect1Kernel: number[];
  112587. /**
  112588. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112589. */
  112590. static EdgeDetect2Kernel: number[];
  112591. /**
  112592. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112593. */
  112594. static SharpenKernel: number[];
  112595. /**
  112596. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112597. */
  112598. static EmbossKernel: number[];
  112599. /**
  112600. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112601. */
  112602. static GaussianKernel: number[];
  112603. }
  112604. }
  112605. declare module BABYLON {
  112606. /**
  112607. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112608. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112609. * based on samples that have a large difference in distance than the center pixel.
  112610. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112611. */
  112612. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112613. direction: Vector2;
  112614. /**
  112615. * Creates a new instance CircleOfConfusionPostProcess
  112616. * @param name The name of the effect.
  112617. * @param scene The scene the effect belongs to.
  112618. * @param direction The direction the blur should be applied.
  112619. * @param kernel The size of the kernel used to blur.
  112620. * @param options The required width/height ratio to downsize to before computing the render pass.
  112621. * @param camera The camera to apply the render pass to.
  112622. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112623. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112625. * @param engine The engine which the post process will be applied. (default: current engine)
  112626. * @param reusable If the post process can be reused on the same frame. (default: false)
  112627. * @param textureType Type of textures used when performing the post process. (default: 0)
  112628. * @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)
  112629. */
  112630. 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);
  112631. }
  112632. }
  112633. declare module BABYLON {
  112634. /** @hidden */
  112635. export var depthOfFieldMergePixelShader: {
  112636. name: string;
  112637. shader: string;
  112638. };
  112639. }
  112640. declare module BABYLON {
  112641. /**
  112642. * Options to be set when merging outputs from the default pipeline.
  112643. */
  112644. export class DepthOfFieldMergePostProcessOptions {
  112645. /**
  112646. * The original image to merge on top of
  112647. */
  112648. originalFromInput: PostProcess;
  112649. /**
  112650. * Parameters to perform the merge of the depth of field effect
  112651. */
  112652. depthOfField?: {
  112653. circleOfConfusion: PostProcess;
  112654. blurSteps: Array<PostProcess>;
  112655. };
  112656. /**
  112657. * Parameters to perform the merge of bloom effect
  112658. */
  112659. bloom?: {
  112660. blurred: PostProcess;
  112661. weight: number;
  112662. };
  112663. }
  112664. /**
  112665. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112666. */
  112667. export class DepthOfFieldMergePostProcess extends PostProcess {
  112668. private blurSteps;
  112669. /**
  112670. * Creates a new instance of DepthOfFieldMergePostProcess
  112671. * @param name The name of the effect.
  112672. * @param originalFromInput Post process which's input will be used for the merge.
  112673. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112674. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112675. * @param options The required width/height ratio to downsize to before computing the render pass.
  112676. * @param camera The camera to apply the render pass to.
  112677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112678. * @param engine The engine which the post process will be applied. (default: current engine)
  112679. * @param reusable If the post process can be reused on the same frame. (default: false)
  112680. * @param textureType Type of textures used when performing the post process. (default: 0)
  112681. * @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)
  112682. */
  112683. 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);
  112684. /**
  112685. * Updates the effect with the current post process compile time values and recompiles the shader.
  112686. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112687. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112688. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112689. * @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
  112690. * @param onCompiled Called when the shader has been compiled.
  112691. * @param onError Called if there is an error when compiling a shader.
  112692. */
  112693. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112694. }
  112695. }
  112696. declare module BABYLON {
  112697. /**
  112698. * Specifies the level of max blur that should be applied when using the depth of field effect
  112699. */
  112700. export enum DepthOfFieldEffectBlurLevel {
  112701. /**
  112702. * Subtle blur
  112703. */
  112704. Low = 0,
  112705. /**
  112706. * Medium blur
  112707. */
  112708. Medium = 1,
  112709. /**
  112710. * Large blur
  112711. */
  112712. High = 2
  112713. }
  112714. /**
  112715. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112716. */
  112717. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112718. private _circleOfConfusion;
  112719. /**
  112720. * @hidden Internal, blurs from high to low
  112721. */
  112722. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112723. private _depthOfFieldBlurY;
  112724. private _dofMerge;
  112725. /**
  112726. * @hidden Internal post processes in depth of field effect
  112727. */
  112728. _effects: Array<PostProcess>;
  112729. /**
  112730. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112731. */
  112732. focalLength: number;
  112733. /**
  112734. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112735. */
  112736. fStop: number;
  112737. /**
  112738. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112739. */
  112740. focusDistance: number;
  112741. /**
  112742. * 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.
  112743. */
  112744. lensSize: number;
  112745. /**
  112746. * Creates a new instance DepthOfFieldEffect
  112747. * @param scene The scene the effect belongs to.
  112748. * @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.
  112749. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112750. * @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)
  112751. */
  112752. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112753. /**
  112754. * Get the current class name of the current effet
  112755. * @returns "DepthOfFieldEffect"
  112756. */
  112757. getClassName(): string;
  112758. /**
  112759. * 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.
  112760. */
  112761. depthTexture: RenderTargetTexture;
  112762. /**
  112763. * Disposes each of the internal effects for a given camera.
  112764. * @param camera The camera to dispose the effect on.
  112765. */
  112766. disposeEffects(camera: Camera): void;
  112767. /**
  112768. * @hidden Internal
  112769. */
  112770. _updateEffects(): void;
  112771. /**
  112772. * Internal
  112773. * @returns if all the contained post processes are ready.
  112774. * @hidden
  112775. */
  112776. _isReady(): boolean;
  112777. }
  112778. }
  112779. declare module BABYLON {
  112780. /** @hidden */
  112781. export var displayPassPixelShader: {
  112782. name: string;
  112783. shader: string;
  112784. };
  112785. }
  112786. declare module BABYLON {
  112787. /**
  112788. * DisplayPassPostProcess which produces an output the same as it's input
  112789. */
  112790. export class DisplayPassPostProcess extends PostProcess {
  112791. /**
  112792. * Creates the DisplayPassPostProcess
  112793. * @param name The name of the effect.
  112794. * @param options The required width/height ratio to downsize to before computing the render pass.
  112795. * @param camera The camera to apply the render pass to.
  112796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112797. * @param engine The engine which the post process will be applied. (default: current engine)
  112798. * @param reusable If the post process can be reused on the same frame. (default: false)
  112799. */
  112800. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112801. }
  112802. }
  112803. declare module BABYLON {
  112804. /** @hidden */
  112805. export var filterPixelShader: {
  112806. name: string;
  112807. shader: string;
  112808. };
  112809. }
  112810. declare module BABYLON {
  112811. /**
  112812. * Applies a kernel filter to the image
  112813. */
  112814. export class FilterPostProcess extends PostProcess {
  112815. /** The matrix to be applied to the image */
  112816. kernelMatrix: Matrix;
  112817. /**
  112818. *
  112819. * @param name The name of the effect.
  112820. * @param kernelMatrix The matrix to be applied to the image
  112821. * @param options The required width/height ratio to downsize to before computing the render pass.
  112822. * @param camera The camera to apply the render pass to.
  112823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112824. * @param engine The engine which the post process will be applied. (default: current engine)
  112825. * @param reusable If the post process can be reused on the same frame. (default: false)
  112826. */
  112827. constructor(name: string,
  112828. /** The matrix to be applied to the image */
  112829. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112830. }
  112831. }
  112832. declare module BABYLON {
  112833. /** @hidden */
  112834. export var fxaaPixelShader: {
  112835. name: string;
  112836. shader: string;
  112837. };
  112838. }
  112839. declare module BABYLON {
  112840. /** @hidden */
  112841. export var fxaaVertexShader: {
  112842. name: string;
  112843. shader: string;
  112844. };
  112845. }
  112846. declare module BABYLON {
  112847. /**
  112848. * Fxaa post process
  112849. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112850. */
  112851. export class FxaaPostProcess extends PostProcess {
  112852. /** @hidden */
  112853. texelWidth: number;
  112854. /** @hidden */
  112855. texelHeight: number;
  112856. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112857. private _getDefines;
  112858. }
  112859. }
  112860. declare module BABYLON {
  112861. /** @hidden */
  112862. export var grainPixelShader: {
  112863. name: string;
  112864. shader: string;
  112865. };
  112866. }
  112867. declare module BABYLON {
  112868. /**
  112869. * The GrainPostProcess adds noise to the image at mid luminance levels
  112870. */
  112871. export class GrainPostProcess extends PostProcess {
  112872. /**
  112873. * The intensity of the grain added (default: 30)
  112874. */
  112875. intensity: number;
  112876. /**
  112877. * If the grain should be randomized on every frame
  112878. */
  112879. animated: boolean;
  112880. /**
  112881. * Creates a new instance of @see GrainPostProcess
  112882. * @param name The name of the effect.
  112883. * @param options The required width/height ratio to downsize to before computing the render pass.
  112884. * @param camera The camera to apply the render pass to.
  112885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112886. * @param engine The engine which the post process will be applied. (default: current engine)
  112887. * @param reusable If the post process can be reused on the same frame. (default: false)
  112888. * @param textureType Type of textures used when performing the post process. (default: 0)
  112889. * @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)
  112890. */
  112891. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112892. }
  112893. }
  112894. declare module BABYLON {
  112895. /** @hidden */
  112896. export var highlightsPixelShader: {
  112897. name: string;
  112898. shader: string;
  112899. };
  112900. }
  112901. declare module BABYLON {
  112902. /**
  112903. * Extracts highlights from the image
  112904. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112905. */
  112906. export class HighlightsPostProcess extends PostProcess {
  112907. /**
  112908. * Extracts highlights from the image
  112909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112910. * @param name The name of the effect.
  112911. * @param options The required width/height ratio to downsize to before computing the render pass.
  112912. * @param camera The camera to apply the render pass to.
  112913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112914. * @param engine The engine which the post process will be applied. (default: current engine)
  112915. * @param reusable If the post process can be reused on the same frame. (default: false)
  112916. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112917. */
  112918. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112919. }
  112920. }
  112921. declare module BABYLON {
  112922. /** @hidden */
  112923. export var mrtFragmentDeclaration: {
  112924. name: string;
  112925. shader: string;
  112926. };
  112927. }
  112928. declare module BABYLON {
  112929. /** @hidden */
  112930. export var geometryPixelShader: {
  112931. name: string;
  112932. shader: string;
  112933. };
  112934. }
  112935. declare module BABYLON {
  112936. /** @hidden */
  112937. export var geometryVertexShader: {
  112938. name: string;
  112939. shader: string;
  112940. };
  112941. }
  112942. declare module BABYLON {
  112943. /**
  112944. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112945. */
  112946. export class GeometryBufferRenderer {
  112947. /**
  112948. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112949. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112950. */
  112951. static readonly POSITION_TEXTURE_TYPE: number;
  112952. /**
  112953. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112954. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112955. */
  112956. static readonly VELOCITY_TEXTURE_TYPE: number;
  112957. /**
  112958. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112959. * in order to compute objects velocities when enableVelocity is set to "true"
  112960. * @hidden
  112961. */
  112962. _previousTransformationMatrices: {
  112963. [index: number]: Matrix;
  112964. };
  112965. private _scene;
  112966. private _multiRenderTarget;
  112967. private _ratio;
  112968. private _enablePosition;
  112969. private _enableVelocity;
  112970. private _positionIndex;
  112971. private _velocityIndex;
  112972. protected _effect: Effect;
  112973. protected _cachedDefines: string;
  112974. /**
  112975. * Set the render list (meshes to be rendered) used in the G buffer.
  112976. */
  112977. renderList: Mesh[];
  112978. /**
  112979. * Gets wether or not G buffer are supported by the running hardware.
  112980. * This requires draw buffer supports
  112981. */
  112982. readonly isSupported: boolean;
  112983. /**
  112984. * Returns the index of the given texture type in the G-Buffer textures array
  112985. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112986. * @returns the index of the given texture type in the G-Buffer textures array
  112987. */
  112988. getTextureIndex(textureType: number): number;
  112989. /**
  112990. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112991. */
  112992. /**
  112993. * Sets whether or not objects positions are enabled for the G buffer.
  112994. */
  112995. enablePosition: boolean;
  112996. /**
  112997. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112998. */
  112999. /**
  113000. * Sets wether or not objects velocities are enabled for the G buffer.
  113001. */
  113002. enableVelocity: boolean;
  113003. /**
  113004. * Gets the scene associated with the buffer.
  113005. */
  113006. readonly scene: Scene;
  113007. /**
  113008. * Gets the ratio used by the buffer during its creation.
  113009. * How big is the buffer related to the main canvas.
  113010. */
  113011. readonly ratio: number;
  113012. /** @hidden */
  113013. static _SceneComponentInitialization: (scene: Scene) => void;
  113014. /**
  113015. * Creates a new G Buffer for the scene
  113016. * @param scene The scene the buffer belongs to
  113017. * @param ratio How big is the buffer related to the main canvas.
  113018. */
  113019. constructor(scene: Scene, ratio?: number);
  113020. /**
  113021. * Checks wether everything is ready to render a submesh to the G buffer.
  113022. * @param subMesh the submesh to check readiness for
  113023. * @param useInstances is the mesh drawn using instance or not
  113024. * @returns true if ready otherwise false
  113025. */
  113026. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113027. /**
  113028. * Gets the current underlying G Buffer.
  113029. * @returns the buffer
  113030. */
  113031. getGBuffer(): MultiRenderTarget;
  113032. /**
  113033. * Gets the number of samples used to render the buffer (anti aliasing).
  113034. */
  113035. /**
  113036. * Sets the number of samples used to render the buffer (anti aliasing).
  113037. */
  113038. samples: number;
  113039. /**
  113040. * Disposes the renderer and frees up associated resources.
  113041. */
  113042. dispose(): void;
  113043. protected _createRenderTargets(): void;
  113044. }
  113045. }
  113046. declare module BABYLON {
  113047. interface Scene {
  113048. /** @hidden (Backing field) */
  113049. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113050. /**
  113051. * Gets or Sets the current geometry buffer associated to the scene.
  113052. */
  113053. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113054. /**
  113055. * Enables a GeometryBufferRender and associates it with the scene
  113056. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113057. * @returns the GeometryBufferRenderer
  113058. */
  113059. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113060. /**
  113061. * Disables the GeometryBufferRender associated with the scene
  113062. */
  113063. disableGeometryBufferRenderer(): void;
  113064. }
  113065. /**
  113066. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113067. * in several rendering techniques.
  113068. */
  113069. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113070. /**
  113071. * The component name helpful to identify the component in the list of scene components.
  113072. */
  113073. readonly name: string;
  113074. /**
  113075. * The scene the component belongs to.
  113076. */
  113077. scene: Scene;
  113078. /**
  113079. * Creates a new instance of the component for the given scene
  113080. * @param scene Defines the scene to register the component in
  113081. */
  113082. constructor(scene: Scene);
  113083. /**
  113084. * Registers the component in a given scene
  113085. */
  113086. register(): void;
  113087. /**
  113088. * Rebuilds the elements related to this component in case of
  113089. * context lost for instance.
  113090. */
  113091. rebuild(): void;
  113092. /**
  113093. * Disposes the component and the associated ressources
  113094. */
  113095. dispose(): void;
  113096. private _gatherRenderTargets;
  113097. }
  113098. }
  113099. declare module BABYLON {
  113100. /** @hidden */
  113101. export var motionBlurPixelShader: {
  113102. name: string;
  113103. shader: string;
  113104. };
  113105. }
  113106. declare module BABYLON {
  113107. /**
  113108. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113109. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113110. * As an example, all you have to do is to create the post-process:
  113111. * var mb = new BABYLON.MotionBlurPostProcess(
  113112. * 'mb', // The name of the effect.
  113113. * scene, // The scene containing the objects to blur according to their velocity.
  113114. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113115. * camera // The camera to apply the render pass to.
  113116. * );
  113117. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113118. */
  113119. export class MotionBlurPostProcess extends PostProcess {
  113120. /**
  113121. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113122. */
  113123. motionStrength: number;
  113124. /**
  113125. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113126. */
  113127. /**
  113128. * Sets the number of iterations to be used for motion blur quality
  113129. */
  113130. motionBlurSamples: number;
  113131. private _motionBlurSamples;
  113132. private _geometryBufferRenderer;
  113133. /**
  113134. * Creates a new instance MotionBlurPostProcess
  113135. * @param name The name of the effect.
  113136. * @param scene The scene containing the objects to blur according to their velocity.
  113137. * @param options The required width/height ratio to downsize to before computing the render pass.
  113138. * @param camera The camera to apply the render pass to.
  113139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113140. * @param engine The engine which the post process will be applied. (default: current engine)
  113141. * @param reusable If the post process can be reused on the same frame. (default: false)
  113142. * @param textureType Type of textures used when performing the post process. (default: 0)
  113143. * @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)
  113144. */
  113145. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113146. /**
  113147. * Disposes the post process.
  113148. * @param camera The camera to dispose the post process on.
  113149. */
  113150. dispose(camera?: Camera): void;
  113151. }
  113152. }
  113153. declare module BABYLON {
  113154. /** @hidden */
  113155. export var refractionPixelShader: {
  113156. name: string;
  113157. shader: string;
  113158. };
  113159. }
  113160. declare module BABYLON {
  113161. /**
  113162. * Post process which applies a refractin texture
  113163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113164. */
  113165. export class RefractionPostProcess extends PostProcess {
  113166. /** the base color of the refraction (used to taint the rendering) */
  113167. color: Color3;
  113168. /** simulated refraction depth */
  113169. depth: number;
  113170. /** the coefficient of the base color (0 to remove base color tainting) */
  113171. colorLevel: number;
  113172. private _refTexture;
  113173. private _ownRefractionTexture;
  113174. /**
  113175. * Gets or sets the refraction texture
  113176. * Please note that you are responsible for disposing the texture if you set it manually
  113177. */
  113178. refractionTexture: Texture;
  113179. /**
  113180. * Initializes the RefractionPostProcess
  113181. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113182. * @param name The name of the effect.
  113183. * @param refractionTextureUrl Url of the refraction texture to use
  113184. * @param color the base color of the refraction (used to taint the rendering)
  113185. * @param depth simulated refraction depth
  113186. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113187. * @param camera The camera to apply the render pass to.
  113188. * @param options The required width/height ratio to downsize to before computing the render pass.
  113189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113190. * @param engine The engine which the post process will be applied. (default: current engine)
  113191. * @param reusable If the post process can be reused on the same frame. (default: false)
  113192. */
  113193. constructor(name: string, refractionTextureUrl: string,
  113194. /** the base color of the refraction (used to taint the rendering) */
  113195. color: Color3,
  113196. /** simulated refraction depth */
  113197. depth: number,
  113198. /** the coefficient of the base color (0 to remove base color tainting) */
  113199. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113200. /**
  113201. * Disposes of the post process
  113202. * @param camera Camera to dispose post process on
  113203. */
  113204. dispose(camera: Camera): void;
  113205. }
  113206. }
  113207. declare module BABYLON {
  113208. /** @hidden */
  113209. export var sharpenPixelShader: {
  113210. name: string;
  113211. shader: string;
  113212. };
  113213. }
  113214. declare module BABYLON {
  113215. /**
  113216. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113217. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113218. */
  113219. export class SharpenPostProcess extends PostProcess {
  113220. /**
  113221. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113222. */
  113223. colorAmount: number;
  113224. /**
  113225. * How much sharpness should be applied (default: 0.3)
  113226. */
  113227. edgeAmount: number;
  113228. /**
  113229. * Creates a new instance ConvolutionPostProcess
  113230. * @param name The name of the effect.
  113231. * @param options The required width/height ratio to downsize to before computing the render pass.
  113232. * @param camera The camera to apply the render pass to.
  113233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113234. * @param engine The engine which the post process will be applied. (default: current engine)
  113235. * @param reusable If the post process can be reused on the same frame. (default: false)
  113236. * @param textureType Type of textures used when performing the post process. (default: 0)
  113237. * @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)
  113238. */
  113239. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113240. }
  113241. }
  113242. declare module BABYLON {
  113243. /**
  113244. * PostProcessRenderPipeline
  113245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113246. */
  113247. export class PostProcessRenderPipeline {
  113248. private engine;
  113249. private _renderEffects;
  113250. private _renderEffectsForIsolatedPass;
  113251. /**
  113252. * List of inspectable custom properties (used by the Inspector)
  113253. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113254. */
  113255. inspectableCustomProperties: IInspectable[];
  113256. /**
  113257. * @hidden
  113258. */
  113259. protected _cameras: Camera[];
  113260. /** @hidden */
  113261. _name: string;
  113262. /**
  113263. * Gets pipeline name
  113264. */
  113265. readonly name: string;
  113266. /**
  113267. * Initializes a PostProcessRenderPipeline
  113268. * @param engine engine to add the pipeline to
  113269. * @param name name of the pipeline
  113270. */
  113271. constructor(engine: Engine, name: string);
  113272. /**
  113273. * Gets the class name
  113274. * @returns "PostProcessRenderPipeline"
  113275. */
  113276. getClassName(): string;
  113277. /**
  113278. * If all the render effects in the pipeline are supported
  113279. */
  113280. readonly isSupported: boolean;
  113281. /**
  113282. * Adds an effect to the pipeline
  113283. * @param renderEffect the effect to add
  113284. */
  113285. addEffect(renderEffect: PostProcessRenderEffect): void;
  113286. /** @hidden */
  113287. _rebuild(): void;
  113288. /** @hidden */
  113289. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113290. /** @hidden */
  113291. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113292. /** @hidden */
  113293. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113294. /** @hidden */
  113295. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113296. /** @hidden */
  113297. _attachCameras(cameras: Camera, unique: boolean): void;
  113298. /** @hidden */
  113299. _attachCameras(cameras: Camera[], unique: boolean): void;
  113300. /** @hidden */
  113301. _detachCameras(cameras: Camera): void;
  113302. /** @hidden */
  113303. _detachCameras(cameras: Nullable<Camera[]>): void;
  113304. /** @hidden */
  113305. _update(): void;
  113306. /** @hidden */
  113307. _reset(): void;
  113308. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113309. /**
  113310. * Disposes of the pipeline
  113311. */
  113312. dispose(): void;
  113313. }
  113314. }
  113315. declare module BABYLON {
  113316. /**
  113317. * PostProcessRenderPipelineManager class
  113318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113319. */
  113320. export class PostProcessRenderPipelineManager {
  113321. private _renderPipelines;
  113322. /**
  113323. * Initializes a PostProcessRenderPipelineManager
  113324. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113325. */
  113326. constructor();
  113327. /**
  113328. * Gets the list of supported render pipelines
  113329. */
  113330. readonly supportedPipelines: PostProcessRenderPipeline[];
  113331. /**
  113332. * Adds a pipeline to the manager
  113333. * @param renderPipeline The pipeline to add
  113334. */
  113335. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113336. /**
  113337. * Attaches a camera to the pipeline
  113338. * @param renderPipelineName The name of the pipeline to attach to
  113339. * @param cameras the camera to attach
  113340. * @param unique if the camera can be attached multiple times to the pipeline
  113341. */
  113342. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113343. /**
  113344. * Detaches a camera from the pipeline
  113345. * @param renderPipelineName The name of the pipeline to detach from
  113346. * @param cameras the camera to detach
  113347. */
  113348. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113349. /**
  113350. * Enables an effect by name on a pipeline
  113351. * @param renderPipelineName the name of the pipeline to enable the effect in
  113352. * @param renderEffectName the name of the effect to enable
  113353. * @param cameras the cameras that the effect should be enabled on
  113354. */
  113355. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113356. /**
  113357. * Disables an effect by name on a pipeline
  113358. * @param renderPipelineName the name of the pipeline to disable the effect in
  113359. * @param renderEffectName the name of the effect to disable
  113360. * @param cameras the cameras that the effect should be disabled on
  113361. */
  113362. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113363. /**
  113364. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113365. */
  113366. update(): void;
  113367. /** @hidden */
  113368. _rebuild(): void;
  113369. /**
  113370. * Disposes of the manager and pipelines
  113371. */
  113372. dispose(): void;
  113373. }
  113374. }
  113375. declare module BABYLON {
  113376. interface Scene {
  113377. /** @hidden (Backing field) */
  113378. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113379. /**
  113380. * Gets the postprocess render pipeline manager
  113381. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113382. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113383. */
  113384. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113385. }
  113386. /**
  113387. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113388. */
  113389. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113390. /**
  113391. * The component name helpfull to identify the component in the list of scene components.
  113392. */
  113393. readonly name: string;
  113394. /**
  113395. * The scene the component belongs to.
  113396. */
  113397. scene: Scene;
  113398. /**
  113399. * Creates a new instance of the component for the given scene
  113400. * @param scene Defines the scene to register the component in
  113401. */
  113402. constructor(scene: Scene);
  113403. /**
  113404. * Registers the component in a given scene
  113405. */
  113406. register(): void;
  113407. /**
  113408. * Rebuilds the elements related to this component in case of
  113409. * context lost for instance.
  113410. */
  113411. rebuild(): void;
  113412. /**
  113413. * Disposes the component and the associated ressources
  113414. */
  113415. dispose(): void;
  113416. private _gatherRenderTargets;
  113417. }
  113418. }
  113419. declare module BABYLON {
  113420. /**
  113421. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113422. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113423. */
  113424. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113425. private _scene;
  113426. private _camerasToBeAttached;
  113427. /**
  113428. * ID of the sharpen post process,
  113429. */
  113430. private readonly SharpenPostProcessId;
  113431. /**
  113432. * @ignore
  113433. * ID of the image processing post process;
  113434. */
  113435. readonly ImageProcessingPostProcessId: string;
  113436. /**
  113437. * @ignore
  113438. * ID of the Fast Approximate Anti-Aliasing post process;
  113439. */
  113440. readonly FxaaPostProcessId: string;
  113441. /**
  113442. * ID of the chromatic aberration post process,
  113443. */
  113444. private readonly ChromaticAberrationPostProcessId;
  113445. /**
  113446. * ID of the grain post process
  113447. */
  113448. private readonly GrainPostProcessId;
  113449. /**
  113450. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113451. */
  113452. sharpen: SharpenPostProcess;
  113453. private _sharpenEffect;
  113454. private bloom;
  113455. /**
  113456. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113457. */
  113458. depthOfField: DepthOfFieldEffect;
  113459. /**
  113460. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113461. */
  113462. fxaa: FxaaPostProcess;
  113463. /**
  113464. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113465. */
  113466. imageProcessing: ImageProcessingPostProcess;
  113467. /**
  113468. * Chromatic aberration post process which will shift rgb colors in the image
  113469. */
  113470. chromaticAberration: ChromaticAberrationPostProcess;
  113471. private _chromaticAberrationEffect;
  113472. /**
  113473. * Grain post process which add noise to the image
  113474. */
  113475. grain: GrainPostProcess;
  113476. private _grainEffect;
  113477. /**
  113478. * Glow post process which adds a glow to emissive areas of the image
  113479. */
  113480. private _glowLayer;
  113481. /**
  113482. * Animations which can be used to tweak settings over a period of time
  113483. */
  113484. animations: Animation[];
  113485. private _imageProcessingConfigurationObserver;
  113486. private _sharpenEnabled;
  113487. private _bloomEnabled;
  113488. private _depthOfFieldEnabled;
  113489. private _depthOfFieldBlurLevel;
  113490. private _fxaaEnabled;
  113491. private _imageProcessingEnabled;
  113492. private _defaultPipelineTextureType;
  113493. private _bloomScale;
  113494. private _chromaticAberrationEnabled;
  113495. private _grainEnabled;
  113496. private _buildAllowed;
  113497. /**
  113498. * Gets active scene
  113499. */
  113500. readonly scene: Scene;
  113501. /**
  113502. * Enable or disable the sharpen process from the pipeline
  113503. */
  113504. sharpenEnabled: boolean;
  113505. private _resizeObserver;
  113506. private _hardwareScaleLevel;
  113507. private _bloomKernel;
  113508. /**
  113509. * Specifies the size of the bloom blur kernel, relative to the final output size
  113510. */
  113511. bloomKernel: number;
  113512. /**
  113513. * Specifies the weight of the bloom in the final rendering
  113514. */
  113515. private _bloomWeight;
  113516. /**
  113517. * Specifies the luma threshold for the area that will be blurred by the bloom
  113518. */
  113519. private _bloomThreshold;
  113520. private _hdr;
  113521. /**
  113522. * The strength of the bloom.
  113523. */
  113524. bloomWeight: number;
  113525. /**
  113526. * The strength of the bloom.
  113527. */
  113528. bloomThreshold: number;
  113529. /**
  113530. * The scale of the bloom, lower value will provide better performance.
  113531. */
  113532. bloomScale: number;
  113533. /**
  113534. * Enable or disable the bloom from the pipeline
  113535. */
  113536. bloomEnabled: boolean;
  113537. private _rebuildBloom;
  113538. /**
  113539. * If the depth of field is enabled.
  113540. */
  113541. depthOfFieldEnabled: boolean;
  113542. /**
  113543. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113544. */
  113545. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113546. /**
  113547. * If the anti aliasing is enabled.
  113548. */
  113549. fxaaEnabled: boolean;
  113550. private _samples;
  113551. /**
  113552. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113553. */
  113554. samples: number;
  113555. /**
  113556. * If image processing is enabled.
  113557. */
  113558. imageProcessingEnabled: boolean;
  113559. /**
  113560. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113561. */
  113562. glowLayerEnabled: boolean;
  113563. /**
  113564. * Gets the glow layer (or null if not defined)
  113565. */
  113566. readonly glowLayer: Nullable<GlowLayer>;
  113567. /**
  113568. * Enable or disable the chromaticAberration process from the pipeline
  113569. */
  113570. chromaticAberrationEnabled: boolean;
  113571. /**
  113572. * Enable or disable the grain process from the pipeline
  113573. */
  113574. grainEnabled: boolean;
  113575. /**
  113576. * @constructor
  113577. * @param name - The rendering pipeline name (default: "")
  113578. * @param hdr - If high dynamic range textures should be used (default: true)
  113579. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113580. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113581. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113582. */
  113583. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113584. /**
  113585. * Get the class name
  113586. * @returns "DefaultRenderingPipeline"
  113587. */
  113588. getClassName(): string;
  113589. /**
  113590. * Force the compilation of the entire pipeline.
  113591. */
  113592. prepare(): void;
  113593. private _hasCleared;
  113594. private _prevPostProcess;
  113595. private _prevPrevPostProcess;
  113596. private _setAutoClearAndTextureSharing;
  113597. private _depthOfFieldSceneObserver;
  113598. private _buildPipeline;
  113599. private _disposePostProcesses;
  113600. /**
  113601. * Adds a camera to the pipeline
  113602. * @param camera the camera to be added
  113603. */
  113604. addCamera(camera: Camera): void;
  113605. /**
  113606. * Removes a camera from the pipeline
  113607. * @param camera the camera to remove
  113608. */
  113609. removeCamera(camera: Camera): void;
  113610. /**
  113611. * Dispose of the pipeline and stop all post processes
  113612. */
  113613. dispose(): void;
  113614. /**
  113615. * Serialize the rendering pipeline (Used when exporting)
  113616. * @returns the serialized object
  113617. */
  113618. serialize(): any;
  113619. /**
  113620. * Parse the serialized pipeline
  113621. * @param source Source pipeline.
  113622. * @param scene The scene to load the pipeline to.
  113623. * @param rootUrl The URL of the serialized pipeline.
  113624. * @returns An instantiated pipeline from the serialized object.
  113625. */
  113626. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113627. }
  113628. }
  113629. declare module BABYLON {
  113630. /** @hidden */
  113631. export var lensHighlightsPixelShader: {
  113632. name: string;
  113633. shader: string;
  113634. };
  113635. }
  113636. declare module BABYLON {
  113637. /** @hidden */
  113638. export var depthOfFieldPixelShader: {
  113639. name: string;
  113640. shader: string;
  113641. };
  113642. }
  113643. declare module BABYLON {
  113644. /**
  113645. * BABYLON.JS Chromatic Aberration GLSL Shader
  113646. * Author: Olivier Guyot
  113647. * Separates very slightly R, G and B colors on the edges of the screen
  113648. * Inspired by Francois Tarlier & Martins Upitis
  113649. */
  113650. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113651. /**
  113652. * @ignore
  113653. * The chromatic aberration PostProcess id in the pipeline
  113654. */
  113655. LensChromaticAberrationEffect: string;
  113656. /**
  113657. * @ignore
  113658. * The highlights enhancing PostProcess id in the pipeline
  113659. */
  113660. HighlightsEnhancingEffect: string;
  113661. /**
  113662. * @ignore
  113663. * The depth-of-field PostProcess id in the pipeline
  113664. */
  113665. LensDepthOfFieldEffect: string;
  113666. private _scene;
  113667. private _depthTexture;
  113668. private _grainTexture;
  113669. private _chromaticAberrationPostProcess;
  113670. private _highlightsPostProcess;
  113671. private _depthOfFieldPostProcess;
  113672. private _edgeBlur;
  113673. private _grainAmount;
  113674. private _chromaticAberration;
  113675. private _distortion;
  113676. private _highlightsGain;
  113677. private _highlightsThreshold;
  113678. private _dofDistance;
  113679. private _dofAperture;
  113680. private _dofDarken;
  113681. private _dofPentagon;
  113682. private _blurNoise;
  113683. /**
  113684. * @constructor
  113685. *
  113686. * Effect parameters are as follow:
  113687. * {
  113688. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113689. * edge_blur: number; // from 0 to x (1 for realism)
  113690. * distortion: number; // from 0 to x (1 for realism)
  113691. * grain_amount: number; // from 0 to 1
  113692. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113693. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113694. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113695. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113696. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113697. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113698. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113699. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113700. * }
  113701. * Note: if an effect parameter is unset, effect is disabled
  113702. *
  113703. * @param name The rendering pipeline name
  113704. * @param parameters - An object containing all parameters (see above)
  113705. * @param scene The scene linked to this pipeline
  113706. * @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)
  113707. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113708. */
  113709. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113710. /**
  113711. * Get the class name
  113712. * @returns "LensRenderingPipeline"
  113713. */
  113714. getClassName(): string;
  113715. /**
  113716. * Gets associated scene
  113717. */
  113718. readonly scene: Scene;
  113719. /**
  113720. * Gets or sets the edge blur
  113721. */
  113722. edgeBlur: number;
  113723. /**
  113724. * Gets or sets the grain amount
  113725. */
  113726. grainAmount: number;
  113727. /**
  113728. * Gets or sets the chromatic aberration amount
  113729. */
  113730. chromaticAberration: number;
  113731. /**
  113732. * Gets or sets the depth of field aperture
  113733. */
  113734. dofAperture: number;
  113735. /**
  113736. * Gets or sets the edge distortion
  113737. */
  113738. edgeDistortion: number;
  113739. /**
  113740. * Gets or sets the depth of field distortion
  113741. */
  113742. dofDistortion: number;
  113743. /**
  113744. * Gets or sets the darken out of focus amount
  113745. */
  113746. darkenOutOfFocus: number;
  113747. /**
  113748. * Gets or sets a boolean indicating if blur noise is enabled
  113749. */
  113750. blurNoise: boolean;
  113751. /**
  113752. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113753. */
  113754. pentagonBokeh: boolean;
  113755. /**
  113756. * Gets or sets the highlight grain amount
  113757. */
  113758. highlightsGain: number;
  113759. /**
  113760. * Gets or sets the highlight threshold
  113761. */
  113762. highlightsThreshold: number;
  113763. /**
  113764. * Sets the amount of blur at the edges
  113765. * @param amount blur amount
  113766. */
  113767. setEdgeBlur(amount: number): void;
  113768. /**
  113769. * Sets edge blur to 0
  113770. */
  113771. disableEdgeBlur(): void;
  113772. /**
  113773. * Sets the amout of grain
  113774. * @param amount Amount of grain
  113775. */
  113776. setGrainAmount(amount: number): void;
  113777. /**
  113778. * Set grain amount to 0
  113779. */
  113780. disableGrain(): void;
  113781. /**
  113782. * Sets the chromatic aberration amount
  113783. * @param amount amount of chromatic aberration
  113784. */
  113785. setChromaticAberration(amount: number): void;
  113786. /**
  113787. * Sets chromatic aberration amount to 0
  113788. */
  113789. disableChromaticAberration(): void;
  113790. /**
  113791. * Sets the EdgeDistortion amount
  113792. * @param amount amount of EdgeDistortion
  113793. */
  113794. setEdgeDistortion(amount: number): void;
  113795. /**
  113796. * Sets edge distortion to 0
  113797. */
  113798. disableEdgeDistortion(): void;
  113799. /**
  113800. * Sets the FocusDistance amount
  113801. * @param amount amount of FocusDistance
  113802. */
  113803. setFocusDistance(amount: number): void;
  113804. /**
  113805. * Disables depth of field
  113806. */
  113807. disableDepthOfField(): void;
  113808. /**
  113809. * Sets the Aperture amount
  113810. * @param amount amount of Aperture
  113811. */
  113812. setAperture(amount: number): void;
  113813. /**
  113814. * Sets the DarkenOutOfFocus amount
  113815. * @param amount amount of DarkenOutOfFocus
  113816. */
  113817. setDarkenOutOfFocus(amount: number): void;
  113818. private _pentagonBokehIsEnabled;
  113819. /**
  113820. * Creates a pentagon bokeh effect
  113821. */
  113822. enablePentagonBokeh(): void;
  113823. /**
  113824. * Disables the pentagon bokeh effect
  113825. */
  113826. disablePentagonBokeh(): void;
  113827. /**
  113828. * Enables noise blur
  113829. */
  113830. enableNoiseBlur(): void;
  113831. /**
  113832. * Disables noise blur
  113833. */
  113834. disableNoiseBlur(): void;
  113835. /**
  113836. * Sets the HighlightsGain amount
  113837. * @param amount amount of HighlightsGain
  113838. */
  113839. setHighlightsGain(amount: number): void;
  113840. /**
  113841. * Sets the HighlightsThreshold amount
  113842. * @param amount amount of HighlightsThreshold
  113843. */
  113844. setHighlightsThreshold(amount: number): void;
  113845. /**
  113846. * Disables highlights
  113847. */
  113848. disableHighlights(): void;
  113849. /**
  113850. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113851. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113852. */
  113853. dispose(disableDepthRender?: boolean): void;
  113854. private _createChromaticAberrationPostProcess;
  113855. private _createHighlightsPostProcess;
  113856. private _createDepthOfFieldPostProcess;
  113857. private _createGrainTexture;
  113858. }
  113859. }
  113860. declare module BABYLON {
  113861. /** @hidden */
  113862. export var ssao2PixelShader: {
  113863. name: string;
  113864. shader: string;
  113865. };
  113866. }
  113867. declare module BABYLON {
  113868. /** @hidden */
  113869. export var ssaoCombinePixelShader: {
  113870. name: string;
  113871. shader: string;
  113872. };
  113873. }
  113874. declare module BABYLON {
  113875. /**
  113876. * Render pipeline to produce ssao effect
  113877. */
  113878. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113879. /**
  113880. * @ignore
  113881. * The PassPostProcess id in the pipeline that contains the original scene color
  113882. */
  113883. SSAOOriginalSceneColorEffect: string;
  113884. /**
  113885. * @ignore
  113886. * The SSAO PostProcess id in the pipeline
  113887. */
  113888. SSAORenderEffect: string;
  113889. /**
  113890. * @ignore
  113891. * The horizontal blur PostProcess id in the pipeline
  113892. */
  113893. SSAOBlurHRenderEffect: string;
  113894. /**
  113895. * @ignore
  113896. * The vertical blur PostProcess id in the pipeline
  113897. */
  113898. SSAOBlurVRenderEffect: string;
  113899. /**
  113900. * @ignore
  113901. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113902. */
  113903. SSAOCombineRenderEffect: string;
  113904. /**
  113905. * The output strength of the SSAO post-process. Default value is 1.0.
  113906. */
  113907. totalStrength: number;
  113908. /**
  113909. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113910. */
  113911. maxZ: number;
  113912. /**
  113913. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113914. */
  113915. minZAspect: number;
  113916. private _samples;
  113917. /**
  113918. * Number of samples used for the SSAO calculations. Default value is 8
  113919. */
  113920. samples: number;
  113921. private _textureSamples;
  113922. /**
  113923. * Number of samples to use for antialiasing
  113924. */
  113925. textureSamples: number;
  113926. /**
  113927. * Ratio object used for SSAO ratio and blur ratio
  113928. */
  113929. private _ratio;
  113930. /**
  113931. * Dynamically generated sphere sampler.
  113932. */
  113933. private _sampleSphere;
  113934. /**
  113935. * Blur filter offsets
  113936. */
  113937. private _samplerOffsets;
  113938. private _expensiveBlur;
  113939. /**
  113940. * If bilateral blur should be used
  113941. */
  113942. expensiveBlur: boolean;
  113943. /**
  113944. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113945. */
  113946. radius: number;
  113947. /**
  113948. * The base color of the SSAO post-process
  113949. * The final result is "base + ssao" between [0, 1]
  113950. */
  113951. base: number;
  113952. /**
  113953. * Support test.
  113954. */
  113955. static readonly IsSupported: boolean;
  113956. private _scene;
  113957. private _depthTexture;
  113958. private _normalTexture;
  113959. private _randomTexture;
  113960. private _originalColorPostProcess;
  113961. private _ssaoPostProcess;
  113962. private _blurHPostProcess;
  113963. private _blurVPostProcess;
  113964. private _ssaoCombinePostProcess;
  113965. private _firstUpdate;
  113966. /**
  113967. * Gets active scene
  113968. */
  113969. readonly scene: Scene;
  113970. /**
  113971. * @constructor
  113972. * @param name The rendering pipeline name
  113973. * @param scene The scene linked to this pipeline
  113974. * @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 }
  113975. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113976. */
  113977. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113978. /**
  113979. * Get the class name
  113980. * @returns "SSAO2RenderingPipeline"
  113981. */
  113982. getClassName(): string;
  113983. /**
  113984. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113985. */
  113986. dispose(disableGeometryBufferRenderer?: boolean): void;
  113987. private _createBlurPostProcess;
  113988. /** @hidden */
  113989. _rebuild(): void;
  113990. private _bits;
  113991. private _radicalInverse_VdC;
  113992. private _hammersley;
  113993. private _hemisphereSample_uniform;
  113994. private _generateHemisphere;
  113995. private _createSSAOPostProcess;
  113996. private _createSSAOCombinePostProcess;
  113997. private _createRandomTexture;
  113998. /**
  113999. * Serialize the rendering pipeline (Used when exporting)
  114000. * @returns the serialized object
  114001. */
  114002. serialize(): any;
  114003. /**
  114004. * Parse the serialized pipeline
  114005. * @param source Source pipeline.
  114006. * @param scene The scene to load the pipeline to.
  114007. * @param rootUrl The URL of the serialized pipeline.
  114008. * @returns An instantiated pipeline from the serialized object.
  114009. */
  114010. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  114011. }
  114012. }
  114013. declare module BABYLON {
  114014. /** @hidden */
  114015. export var ssaoPixelShader: {
  114016. name: string;
  114017. shader: string;
  114018. };
  114019. }
  114020. declare module BABYLON {
  114021. /**
  114022. * Render pipeline to produce ssao effect
  114023. */
  114024. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  114025. /**
  114026. * @ignore
  114027. * The PassPostProcess id in the pipeline that contains the original scene color
  114028. */
  114029. SSAOOriginalSceneColorEffect: string;
  114030. /**
  114031. * @ignore
  114032. * The SSAO PostProcess id in the pipeline
  114033. */
  114034. SSAORenderEffect: string;
  114035. /**
  114036. * @ignore
  114037. * The horizontal blur PostProcess id in the pipeline
  114038. */
  114039. SSAOBlurHRenderEffect: string;
  114040. /**
  114041. * @ignore
  114042. * The vertical blur PostProcess id in the pipeline
  114043. */
  114044. SSAOBlurVRenderEffect: string;
  114045. /**
  114046. * @ignore
  114047. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114048. */
  114049. SSAOCombineRenderEffect: string;
  114050. /**
  114051. * The output strength of the SSAO post-process. Default value is 1.0.
  114052. */
  114053. totalStrength: number;
  114054. /**
  114055. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114056. */
  114057. radius: number;
  114058. /**
  114059. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114060. * Must not be equal to fallOff and superior to fallOff.
  114061. * Default value is 0.0075
  114062. */
  114063. area: number;
  114064. /**
  114065. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114066. * Must not be equal to area and inferior to area.
  114067. * Default value is 0.000001
  114068. */
  114069. fallOff: number;
  114070. /**
  114071. * The base color of the SSAO post-process
  114072. * The final result is "base + ssao" between [0, 1]
  114073. */
  114074. base: number;
  114075. private _scene;
  114076. private _depthTexture;
  114077. private _randomTexture;
  114078. private _originalColorPostProcess;
  114079. private _ssaoPostProcess;
  114080. private _blurHPostProcess;
  114081. private _blurVPostProcess;
  114082. private _ssaoCombinePostProcess;
  114083. private _firstUpdate;
  114084. /**
  114085. * Gets active scene
  114086. */
  114087. readonly scene: Scene;
  114088. /**
  114089. * @constructor
  114090. * @param name - The rendering pipeline name
  114091. * @param scene - The scene linked to this pipeline
  114092. * @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 }
  114093. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114094. */
  114095. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114096. /**
  114097. * Get the class name
  114098. * @returns "SSAORenderingPipeline"
  114099. */
  114100. getClassName(): string;
  114101. /**
  114102. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114103. */
  114104. dispose(disableDepthRender?: boolean): void;
  114105. private _createBlurPostProcess;
  114106. /** @hidden */
  114107. _rebuild(): void;
  114108. private _createSSAOPostProcess;
  114109. private _createSSAOCombinePostProcess;
  114110. private _createRandomTexture;
  114111. }
  114112. }
  114113. declare module BABYLON {
  114114. /** @hidden */
  114115. export var standardPixelShader: {
  114116. name: string;
  114117. shader: string;
  114118. };
  114119. }
  114120. declare module BABYLON {
  114121. /**
  114122. * Standard rendering pipeline
  114123. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114124. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114125. */
  114126. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114127. /**
  114128. * Public members
  114129. */
  114130. /**
  114131. * Post-process which contains the original scene color before the pipeline applies all the effects
  114132. */
  114133. originalPostProcess: Nullable<PostProcess>;
  114134. /**
  114135. * Post-process used to down scale an image x4
  114136. */
  114137. downSampleX4PostProcess: Nullable<PostProcess>;
  114138. /**
  114139. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114140. */
  114141. brightPassPostProcess: Nullable<PostProcess>;
  114142. /**
  114143. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114144. */
  114145. blurHPostProcesses: PostProcess[];
  114146. /**
  114147. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114148. */
  114149. blurVPostProcesses: PostProcess[];
  114150. /**
  114151. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114152. */
  114153. textureAdderPostProcess: Nullable<PostProcess>;
  114154. /**
  114155. * Post-process used to create volumetric lighting effect
  114156. */
  114157. volumetricLightPostProcess: Nullable<PostProcess>;
  114158. /**
  114159. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114160. */
  114161. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114162. /**
  114163. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114164. */
  114165. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114166. /**
  114167. * Post-process used to merge the volumetric light effect and the real scene color
  114168. */
  114169. volumetricLightMergePostProces: Nullable<PostProcess>;
  114170. /**
  114171. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114172. */
  114173. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114174. /**
  114175. * Base post-process used to calculate the average luminance of the final image for HDR
  114176. */
  114177. luminancePostProcess: Nullable<PostProcess>;
  114178. /**
  114179. * Post-processes used to create down sample post-processes in order to get
  114180. * the average luminance of the final image for HDR
  114181. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114182. */
  114183. luminanceDownSamplePostProcesses: PostProcess[];
  114184. /**
  114185. * Post-process used to create a HDR effect (light adaptation)
  114186. */
  114187. hdrPostProcess: Nullable<PostProcess>;
  114188. /**
  114189. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114190. */
  114191. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114192. /**
  114193. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114194. */
  114195. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114196. /**
  114197. * Post-process used to merge the final HDR post-process and the real scene color
  114198. */
  114199. hdrFinalPostProcess: Nullable<PostProcess>;
  114200. /**
  114201. * Post-process used to create a lens flare effect
  114202. */
  114203. lensFlarePostProcess: Nullable<PostProcess>;
  114204. /**
  114205. * Post-process that merges the result of the lens flare post-process and the real scene color
  114206. */
  114207. lensFlareComposePostProcess: Nullable<PostProcess>;
  114208. /**
  114209. * Post-process used to create a motion blur effect
  114210. */
  114211. motionBlurPostProcess: Nullable<PostProcess>;
  114212. /**
  114213. * Post-process used to create a depth of field effect
  114214. */
  114215. depthOfFieldPostProcess: Nullable<PostProcess>;
  114216. /**
  114217. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114218. */
  114219. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114220. /**
  114221. * Represents the brightness threshold in order to configure the illuminated surfaces
  114222. */
  114223. brightThreshold: number;
  114224. /**
  114225. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114226. */
  114227. blurWidth: number;
  114228. /**
  114229. * Sets if the blur for highlighted surfaces must be only horizontal
  114230. */
  114231. horizontalBlur: boolean;
  114232. /**
  114233. * Gets the overall exposure used by the pipeline
  114234. */
  114235. /**
  114236. * Sets the overall exposure used by the pipeline
  114237. */
  114238. exposure: number;
  114239. /**
  114240. * Texture used typically to simulate "dirty" on camera lens
  114241. */
  114242. lensTexture: Nullable<Texture>;
  114243. /**
  114244. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114245. */
  114246. volumetricLightCoefficient: number;
  114247. /**
  114248. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114249. */
  114250. volumetricLightPower: number;
  114251. /**
  114252. * Used the set the blur intensity to smooth the volumetric lights
  114253. */
  114254. volumetricLightBlurScale: number;
  114255. /**
  114256. * Light (spot or directional) used to generate the volumetric lights rays
  114257. * The source light must have a shadow generate so the pipeline can get its
  114258. * depth map
  114259. */
  114260. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114261. /**
  114262. * For eye adaptation, represents the minimum luminance the eye can see
  114263. */
  114264. hdrMinimumLuminance: number;
  114265. /**
  114266. * For eye adaptation, represents the decrease luminance speed
  114267. */
  114268. hdrDecreaseRate: number;
  114269. /**
  114270. * For eye adaptation, represents the increase luminance speed
  114271. */
  114272. hdrIncreaseRate: number;
  114273. /**
  114274. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114275. */
  114276. /**
  114277. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114278. */
  114279. hdrAutoExposure: boolean;
  114280. /**
  114281. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114282. */
  114283. lensColorTexture: Nullable<Texture>;
  114284. /**
  114285. * The overall strengh for the lens flare effect
  114286. */
  114287. lensFlareStrength: number;
  114288. /**
  114289. * Dispersion coefficient for lens flare ghosts
  114290. */
  114291. lensFlareGhostDispersal: number;
  114292. /**
  114293. * Main lens flare halo width
  114294. */
  114295. lensFlareHaloWidth: number;
  114296. /**
  114297. * Based on the lens distortion effect, defines how much the lens flare result
  114298. * is distorted
  114299. */
  114300. lensFlareDistortionStrength: number;
  114301. /**
  114302. * Lens star texture must be used to simulate rays on the flares and is available
  114303. * in the documentation
  114304. */
  114305. lensStarTexture: Nullable<Texture>;
  114306. /**
  114307. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114308. * flare effect by taking account of the dirt texture
  114309. */
  114310. lensFlareDirtTexture: Nullable<Texture>;
  114311. /**
  114312. * Represents the focal length for the depth of field effect
  114313. */
  114314. depthOfFieldDistance: number;
  114315. /**
  114316. * Represents the blur intensity for the blurred part of the depth of field effect
  114317. */
  114318. depthOfFieldBlurWidth: number;
  114319. /**
  114320. * For motion blur, defines how much the image is blurred by the movement
  114321. */
  114322. motionStrength: number;
  114323. /**
  114324. * List of animations for the pipeline (IAnimatable implementation)
  114325. */
  114326. animations: Animation[];
  114327. /**
  114328. * Private members
  114329. */
  114330. private _scene;
  114331. private _currentDepthOfFieldSource;
  114332. private _basePostProcess;
  114333. private _fixedExposure;
  114334. private _currentExposure;
  114335. private _hdrAutoExposure;
  114336. private _hdrCurrentLuminance;
  114337. private _floatTextureType;
  114338. private _ratio;
  114339. private _bloomEnabled;
  114340. private _depthOfFieldEnabled;
  114341. private _vlsEnabled;
  114342. private _lensFlareEnabled;
  114343. private _hdrEnabled;
  114344. private _motionBlurEnabled;
  114345. private _fxaaEnabled;
  114346. private _motionBlurSamples;
  114347. private _volumetricLightStepsCount;
  114348. private _samples;
  114349. /**
  114350. * @ignore
  114351. * Specifies if the bloom pipeline is enabled
  114352. */
  114353. BloomEnabled: boolean;
  114354. /**
  114355. * @ignore
  114356. * Specifies if the depth of field pipeline is enabed
  114357. */
  114358. DepthOfFieldEnabled: boolean;
  114359. /**
  114360. * @ignore
  114361. * Specifies if the lens flare pipeline is enabed
  114362. */
  114363. LensFlareEnabled: boolean;
  114364. /**
  114365. * @ignore
  114366. * Specifies if the HDR pipeline is enabled
  114367. */
  114368. HDREnabled: boolean;
  114369. /**
  114370. * @ignore
  114371. * Specifies if the volumetric lights scattering effect is enabled
  114372. */
  114373. VLSEnabled: boolean;
  114374. /**
  114375. * @ignore
  114376. * Specifies if the motion blur effect is enabled
  114377. */
  114378. MotionBlurEnabled: boolean;
  114379. /**
  114380. * Specifies if anti-aliasing is enabled
  114381. */
  114382. fxaaEnabled: boolean;
  114383. /**
  114384. * Specifies the number of steps used to calculate the volumetric lights
  114385. * Typically in interval [50, 200]
  114386. */
  114387. volumetricLightStepsCount: number;
  114388. /**
  114389. * Specifies the number of samples used for the motion blur effect
  114390. * Typically in interval [16, 64]
  114391. */
  114392. motionBlurSamples: number;
  114393. /**
  114394. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114395. */
  114396. samples: number;
  114397. /**
  114398. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114399. * @constructor
  114400. * @param name The rendering pipeline name
  114401. * @param scene The scene linked to this pipeline
  114402. * @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)
  114403. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114404. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114405. */
  114406. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114407. private _buildPipeline;
  114408. private _createDownSampleX4PostProcess;
  114409. private _createBrightPassPostProcess;
  114410. private _createBlurPostProcesses;
  114411. private _createTextureAdderPostProcess;
  114412. private _createVolumetricLightPostProcess;
  114413. private _createLuminancePostProcesses;
  114414. private _createHdrPostProcess;
  114415. private _createLensFlarePostProcess;
  114416. private _createDepthOfFieldPostProcess;
  114417. private _createMotionBlurPostProcess;
  114418. private _getDepthTexture;
  114419. private _disposePostProcesses;
  114420. /**
  114421. * Dispose of the pipeline and stop all post processes
  114422. */
  114423. dispose(): void;
  114424. /**
  114425. * Serialize the rendering pipeline (Used when exporting)
  114426. * @returns the serialized object
  114427. */
  114428. serialize(): any;
  114429. /**
  114430. * Parse the serialized pipeline
  114431. * @param source Source pipeline.
  114432. * @param scene The scene to load the pipeline to.
  114433. * @param rootUrl The URL of the serialized pipeline.
  114434. * @returns An instantiated pipeline from the serialized object.
  114435. */
  114436. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114437. /**
  114438. * Luminance steps
  114439. */
  114440. static LuminanceSteps: number;
  114441. }
  114442. }
  114443. declare module BABYLON {
  114444. /** @hidden */
  114445. export var tonemapPixelShader: {
  114446. name: string;
  114447. shader: string;
  114448. };
  114449. }
  114450. declare module BABYLON {
  114451. /** Defines operator used for tonemapping */
  114452. export enum TonemappingOperator {
  114453. /** Hable */
  114454. Hable = 0,
  114455. /** Reinhard */
  114456. Reinhard = 1,
  114457. /** HejiDawson */
  114458. HejiDawson = 2,
  114459. /** Photographic */
  114460. Photographic = 3
  114461. }
  114462. /**
  114463. * Defines a post process to apply tone mapping
  114464. */
  114465. export class TonemapPostProcess extends PostProcess {
  114466. private _operator;
  114467. /** Defines the required exposure adjustement */
  114468. exposureAdjustment: number;
  114469. /**
  114470. * Creates a new TonemapPostProcess
  114471. * @param name defines the name of the postprocess
  114472. * @param _operator defines the operator to use
  114473. * @param exposureAdjustment defines the required exposure adjustement
  114474. * @param camera defines the camera to use (can be null)
  114475. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114476. * @param engine defines the hosting engine (can be ignore if camera is set)
  114477. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114478. */
  114479. constructor(name: string, _operator: TonemappingOperator,
  114480. /** Defines the required exposure adjustement */
  114481. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114482. }
  114483. }
  114484. declare module BABYLON {
  114485. /** @hidden */
  114486. export var depthVertexShader: {
  114487. name: string;
  114488. shader: string;
  114489. };
  114490. }
  114491. declare module BABYLON {
  114492. /** @hidden */
  114493. export var volumetricLightScatteringPixelShader: {
  114494. name: string;
  114495. shader: string;
  114496. };
  114497. }
  114498. declare module BABYLON {
  114499. /** @hidden */
  114500. export var volumetricLightScatteringPassPixelShader: {
  114501. name: string;
  114502. shader: string;
  114503. };
  114504. }
  114505. declare module BABYLON {
  114506. /**
  114507. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114508. */
  114509. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114510. private _volumetricLightScatteringPass;
  114511. private _volumetricLightScatteringRTT;
  114512. private _viewPort;
  114513. private _screenCoordinates;
  114514. private _cachedDefines;
  114515. /**
  114516. * If not undefined, the mesh position is computed from the attached node position
  114517. */
  114518. attachedNode: {
  114519. position: Vector3;
  114520. };
  114521. /**
  114522. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114523. */
  114524. customMeshPosition: Vector3;
  114525. /**
  114526. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114527. */
  114528. useCustomMeshPosition: boolean;
  114529. /**
  114530. * If the post-process should inverse the light scattering direction
  114531. */
  114532. invert: boolean;
  114533. /**
  114534. * The internal mesh used by the post-process
  114535. */
  114536. mesh: Mesh;
  114537. /**
  114538. * @hidden
  114539. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114540. */
  114541. useDiffuseColor: boolean;
  114542. /**
  114543. * Array containing the excluded meshes not rendered in the internal pass
  114544. */
  114545. excludedMeshes: AbstractMesh[];
  114546. /**
  114547. * Controls the overall intensity of the post-process
  114548. */
  114549. exposure: number;
  114550. /**
  114551. * Dissipates each sample's contribution in range [0, 1]
  114552. */
  114553. decay: number;
  114554. /**
  114555. * Controls the overall intensity of each sample
  114556. */
  114557. weight: number;
  114558. /**
  114559. * Controls the density of each sample
  114560. */
  114561. density: number;
  114562. /**
  114563. * @constructor
  114564. * @param name The post-process name
  114565. * @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)
  114566. * @param camera The camera that the post-process will be attached to
  114567. * @param mesh The mesh used to create the light scattering
  114568. * @param samples The post-process quality, default 100
  114569. * @param samplingModeThe post-process filtering mode
  114570. * @param engine The babylon engine
  114571. * @param reusable If the post-process is reusable
  114572. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114573. */
  114574. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114575. /**
  114576. * Returns the string "VolumetricLightScatteringPostProcess"
  114577. * @returns "VolumetricLightScatteringPostProcess"
  114578. */
  114579. getClassName(): string;
  114580. private _isReady;
  114581. /**
  114582. * Sets the new light position for light scattering effect
  114583. * @param position The new custom light position
  114584. */
  114585. setCustomMeshPosition(position: Vector3): void;
  114586. /**
  114587. * Returns the light position for light scattering effect
  114588. * @return Vector3 The custom light position
  114589. */
  114590. getCustomMeshPosition(): Vector3;
  114591. /**
  114592. * Disposes the internal assets and detaches the post-process from the camera
  114593. */
  114594. dispose(camera: Camera): void;
  114595. /**
  114596. * Returns the render target texture used by the post-process
  114597. * @return the render target texture used by the post-process
  114598. */
  114599. getPass(): RenderTargetTexture;
  114600. private _meshExcluded;
  114601. private _createPass;
  114602. private _updateMeshScreenCoordinates;
  114603. /**
  114604. * Creates a default mesh for the Volumeric Light Scattering post-process
  114605. * @param name The mesh name
  114606. * @param scene The scene where to create the mesh
  114607. * @return the default mesh
  114608. */
  114609. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114610. }
  114611. }
  114612. declare module BABYLON {
  114613. interface Scene {
  114614. /** @hidden (Backing field) */
  114615. _boundingBoxRenderer: BoundingBoxRenderer;
  114616. /** @hidden (Backing field) */
  114617. _forceShowBoundingBoxes: boolean;
  114618. /**
  114619. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114620. */
  114621. forceShowBoundingBoxes: boolean;
  114622. /**
  114623. * Gets the bounding box renderer associated with the scene
  114624. * @returns a BoundingBoxRenderer
  114625. */
  114626. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114627. }
  114628. interface AbstractMesh {
  114629. /** @hidden (Backing field) */
  114630. _showBoundingBox: boolean;
  114631. /**
  114632. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114633. */
  114634. showBoundingBox: boolean;
  114635. }
  114636. /**
  114637. * Component responsible of rendering the bounding box of the meshes in a scene.
  114638. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114639. */
  114640. export class BoundingBoxRenderer implements ISceneComponent {
  114641. /**
  114642. * The component name helpfull to identify the component in the list of scene components.
  114643. */
  114644. readonly name: string;
  114645. /**
  114646. * The scene the component belongs to.
  114647. */
  114648. scene: Scene;
  114649. /**
  114650. * Color of the bounding box lines placed in front of an object
  114651. */
  114652. frontColor: Color3;
  114653. /**
  114654. * Color of the bounding box lines placed behind an object
  114655. */
  114656. backColor: Color3;
  114657. /**
  114658. * Defines if the renderer should show the back lines or not
  114659. */
  114660. showBackLines: boolean;
  114661. /**
  114662. * @hidden
  114663. */
  114664. renderList: SmartArray<BoundingBox>;
  114665. private _colorShader;
  114666. private _vertexBuffers;
  114667. private _indexBuffer;
  114668. /**
  114669. * Instantiates a new bounding box renderer in a scene.
  114670. * @param scene the scene the renderer renders in
  114671. */
  114672. constructor(scene: Scene);
  114673. /**
  114674. * Registers the component in a given scene
  114675. */
  114676. register(): void;
  114677. private _evaluateSubMesh;
  114678. private _activeMesh;
  114679. private _prepareRessources;
  114680. private _createIndexBuffer;
  114681. /**
  114682. * Rebuilds the elements related to this component in case of
  114683. * context lost for instance.
  114684. */
  114685. rebuild(): void;
  114686. /**
  114687. * @hidden
  114688. */
  114689. reset(): void;
  114690. /**
  114691. * Render the bounding boxes of a specific rendering group
  114692. * @param renderingGroupId defines the rendering group to render
  114693. */
  114694. render(renderingGroupId: number): void;
  114695. /**
  114696. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114697. * @param mesh Define the mesh to render the occlusion bounding box for
  114698. */
  114699. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114700. /**
  114701. * Dispose and release the resources attached to this renderer.
  114702. */
  114703. dispose(): void;
  114704. }
  114705. }
  114706. declare module BABYLON {
  114707. /** @hidden */
  114708. export var depthPixelShader: {
  114709. name: string;
  114710. shader: string;
  114711. };
  114712. }
  114713. declare module BABYLON {
  114714. /**
  114715. * This represents a depth renderer in Babylon.
  114716. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114717. */
  114718. export class DepthRenderer {
  114719. private _scene;
  114720. private _depthMap;
  114721. private _effect;
  114722. private _cachedDefines;
  114723. private _camera;
  114724. /**
  114725. * Specifiess that the depth renderer will only be used within
  114726. * the camera it is created for.
  114727. * This can help forcing its rendering during the camera processing.
  114728. */
  114729. useOnlyInActiveCamera: boolean;
  114730. /** @hidden */
  114731. static _SceneComponentInitialization: (scene: Scene) => void;
  114732. /**
  114733. * Instantiates a depth renderer
  114734. * @param scene The scene the renderer belongs to
  114735. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114736. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114737. */
  114738. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114739. /**
  114740. * Creates the depth rendering effect and checks if the effect is ready.
  114741. * @param subMesh The submesh to be used to render the depth map of
  114742. * @param useInstances If multiple world instances should be used
  114743. * @returns if the depth renderer is ready to render the depth map
  114744. */
  114745. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114746. /**
  114747. * Gets the texture which the depth map will be written to.
  114748. * @returns The depth map texture
  114749. */
  114750. getDepthMap(): RenderTargetTexture;
  114751. /**
  114752. * Disposes of the depth renderer.
  114753. */
  114754. dispose(): void;
  114755. }
  114756. }
  114757. declare module BABYLON {
  114758. interface Scene {
  114759. /** @hidden (Backing field) */
  114760. _depthRenderer: {
  114761. [id: string]: DepthRenderer;
  114762. };
  114763. /**
  114764. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114765. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114766. * @returns the created depth renderer
  114767. */
  114768. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114769. /**
  114770. * Disables a depth renderer for a given camera
  114771. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114772. */
  114773. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114774. }
  114775. /**
  114776. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114777. * in several rendering techniques.
  114778. */
  114779. export class DepthRendererSceneComponent implements ISceneComponent {
  114780. /**
  114781. * The component name helpfull to identify the component in the list of scene components.
  114782. */
  114783. readonly name: string;
  114784. /**
  114785. * The scene the component belongs to.
  114786. */
  114787. scene: Scene;
  114788. /**
  114789. * Creates a new instance of the component for the given scene
  114790. * @param scene Defines the scene to register the component in
  114791. */
  114792. constructor(scene: Scene);
  114793. /**
  114794. * Registers the component in a given scene
  114795. */
  114796. register(): void;
  114797. /**
  114798. * Rebuilds the elements related to this component in case of
  114799. * context lost for instance.
  114800. */
  114801. rebuild(): void;
  114802. /**
  114803. * Disposes the component and the associated ressources
  114804. */
  114805. dispose(): void;
  114806. private _gatherRenderTargets;
  114807. private _gatherActiveCameraRenderTargets;
  114808. }
  114809. }
  114810. declare module BABYLON {
  114811. /** @hidden */
  114812. export var outlinePixelShader: {
  114813. name: string;
  114814. shader: string;
  114815. };
  114816. }
  114817. declare module BABYLON {
  114818. /** @hidden */
  114819. export var outlineVertexShader: {
  114820. name: string;
  114821. shader: string;
  114822. };
  114823. }
  114824. declare module BABYLON {
  114825. interface Scene {
  114826. /** @hidden */
  114827. _outlineRenderer: OutlineRenderer;
  114828. /**
  114829. * Gets the outline renderer associated with the scene
  114830. * @returns a OutlineRenderer
  114831. */
  114832. getOutlineRenderer(): OutlineRenderer;
  114833. }
  114834. interface AbstractMesh {
  114835. /** @hidden (Backing field) */
  114836. _renderOutline: boolean;
  114837. /**
  114838. * Gets or sets a boolean indicating if the outline must be rendered as well
  114839. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114840. */
  114841. renderOutline: boolean;
  114842. /** @hidden (Backing field) */
  114843. _renderOverlay: boolean;
  114844. /**
  114845. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114846. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114847. */
  114848. renderOverlay: boolean;
  114849. }
  114850. /**
  114851. * This class is responsible to draw bothe outline/overlay of meshes.
  114852. * It should not be used directly but through the available method on mesh.
  114853. */
  114854. export class OutlineRenderer implements ISceneComponent {
  114855. /**
  114856. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114857. */
  114858. private static _StencilReference;
  114859. /**
  114860. * The name of the component. Each component must have a unique name.
  114861. */
  114862. name: string;
  114863. /**
  114864. * The scene the component belongs to.
  114865. */
  114866. scene: Scene;
  114867. /**
  114868. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114869. */
  114870. zOffset: number;
  114871. private _engine;
  114872. private _effect;
  114873. private _cachedDefines;
  114874. private _savedDepthWrite;
  114875. /**
  114876. * Instantiates a new outline renderer. (There could be only one per scene).
  114877. * @param scene Defines the scene it belongs to
  114878. */
  114879. constructor(scene: Scene);
  114880. /**
  114881. * Register the component to one instance of a scene.
  114882. */
  114883. register(): void;
  114884. /**
  114885. * Rebuilds the elements related to this component in case of
  114886. * context lost for instance.
  114887. */
  114888. rebuild(): void;
  114889. /**
  114890. * Disposes the component and the associated ressources.
  114891. */
  114892. dispose(): void;
  114893. /**
  114894. * Renders the outline in the canvas.
  114895. * @param subMesh Defines the sumesh to render
  114896. * @param batch Defines the batch of meshes in case of instances
  114897. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114898. */
  114899. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114900. /**
  114901. * Returns whether or not the outline renderer is ready for a given submesh.
  114902. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114903. * @param subMesh Defines the submesh to check readyness for
  114904. * @param useInstances Defines wheter wee are trying to render instances or not
  114905. * @returns true if ready otherwise false
  114906. */
  114907. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114908. private _beforeRenderingMesh;
  114909. private _afterRenderingMesh;
  114910. }
  114911. }
  114912. declare module BABYLON {
  114913. /**
  114914. * Defines the list of states available for a task inside a AssetsManager
  114915. */
  114916. export enum AssetTaskState {
  114917. /**
  114918. * Initialization
  114919. */
  114920. INIT = 0,
  114921. /**
  114922. * Running
  114923. */
  114924. RUNNING = 1,
  114925. /**
  114926. * Done
  114927. */
  114928. DONE = 2,
  114929. /**
  114930. * Error
  114931. */
  114932. ERROR = 3
  114933. }
  114934. /**
  114935. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114936. */
  114937. export abstract class AbstractAssetTask {
  114938. /**
  114939. * Task name
  114940. */ name: string;
  114941. /**
  114942. * Callback called when the task is successful
  114943. */
  114944. onSuccess: (task: any) => void;
  114945. /**
  114946. * Callback called when the task is not successful
  114947. */
  114948. onError: (task: any, message?: string, exception?: any) => void;
  114949. /**
  114950. * Creates a new AssetsManager
  114951. * @param name defines the name of the task
  114952. */
  114953. constructor(
  114954. /**
  114955. * Task name
  114956. */ name: string);
  114957. private _isCompleted;
  114958. private _taskState;
  114959. private _errorObject;
  114960. /**
  114961. * Get if the task is completed
  114962. */
  114963. readonly isCompleted: boolean;
  114964. /**
  114965. * Gets the current state of the task
  114966. */
  114967. readonly taskState: AssetTaskState;
  114968. /**
  114969. * Gets the current error object (if task is in error)
  114970. */
  114971. readonly errorObject: {
  114972. message?: string;
  114973. exception?: any;
  114974. };
  114975. /**
  114976. * Internal only
  114977. * @hidden
  114978. */
  114979. _setErrorObject(message?: string, exception?: any): void;
  114980. /**
  114981. * Execute the current task
  114982. * @param scene defines the scene where you want your assets to be loaded
  114983. * @param onSuccess is a callback called when the task is successfully executed
  114984. * @param onError is a callback called if an error occurs
  114985. */
  114986. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114987. /**
  114988. * Execute the current task
  114989. * @param scene defines the scene where you want your assets to be loaded
  114990. * @param onSuccess is a callback called when the task is successfully executed
  114991. * @param onError is a callback called if an error occurs
  114992. */
  114993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114994. /**
  114995. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114996. * This can be used with failed tasks that have the reason for failure fixed.
  114997. */
  114998. reset(): void;
  114999. private onErrorCallback;
  115000. private onDoneCallback;
  115001. }
  115002. /**
  115003. * Define the interface used by progress events raised during assets loading
  115004. */
  115005. export interface IAssetsProgressEvent {
  115006. /**
  115007. * Defines the number of remaining tasks to process
  115008. */
  115009. remainingCount: number;
  115010. /**
  115011. * Defines the total number of tasks
  115012. */
  115013. totalCount: number;
  115014. /**
  115015. * Defines the task that was just processed
  115016. */
  115017. task: AbstractAssetTask;
  115018. }
  115019. /**
  115020. * Class used to share progress information about assets loading
  115021. */
  115022. export class AssetsProgressEvent implements IAssetsProgressEvent {
  115023. /**
  115024. * Defines the number of remaining tasks to process
  115025. */
  115026. remainingCount: number;
  115027. /**
  115028. * Defines the total number of tasks
  115029. */
  115030. totalCount: number;
  115031. /**
  115032. * Defines the task that was just processed
  115033. */
  115034. task: AbstractAssetTask;
  115035. /**
  115036. * Creates a AssetsProgressEvent
  115037. * @param remainingCount defines the number of remaining tasks to process
  115038. * @param totalCount defines the total number of tasks
  115039. * @param task defines the task that was just processed
  115040. */
  115041. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115042. }
  115043. /**
  115044. * Define a task used by AssetsManager to load meshes
  115045. */
  115046. export class MeshAssetTask extends AbstractAssetTask {
  115047. /**
  115048. * Defines the name of the task
  115049. */
  115050. name: string;
  115051. /**
  115052. * Defines the list of mesh's names you want to load
  115053. */
  115054. meshesNames: any;
  115055. /**
  115056. * Defines the root url to use as a base to load your meshes and associated resources
  115057. */
  115058. rootUrl: string;
  115059. /**
  115060. * Defines the filename of the scene to load from
  115061. */
  115062. sceneFilename: string;
  115063. /**
  115064. * Gets the list of loaded meshes
  115065. */
  115066. loadedMeshes: Array<AbstractMesh>;
  115067. /**
  115068. * Gets the list of loaded particle systems
  115069. */
  115070. loadedParticleSystems: Array<IParticleSystem>;
  115071. /**
  115072. * Gets the list of loaded skeletons
  115073. */
  115074. loadedSkeletons: Array<Skeleton>;
  115075. /**
  115076. * Gets the list of loaded animation groups
  115077. */
  115078. loadedAnimationGroups: Array<AnimationGroup>;
  115079. /**
  115080. * Callback called when the task is successful
  115081. */
  115082. onSuccess: (task: MeshAssetTask) => void;
  115083. /**
  115084. * Callback called when the task is successful
  115085. */
  115086. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115087. /**
  115088. * Creates a new MeshAssetTask
  115089. * @param name defines the name of the task
  115090. * @param meshesNames defines the list of mesh's names you want to load
  115091. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115092. * @param sceneFilename defines the filename of the scene to load from
  115093. */
  115094. constructor(
  115095. /**
  115096. * Defines the name of the task
  115097. */
  115098. name: string,
  115099. /**
  115100. * Defines the list of mesh's names you want to load
  115101. */
  115102. meshesNames: any,
  115103. /**
  115104. * Defines the root url to use as a base to load your meshes and associated resources
  115105. */
  115106. rootUrl: string,
  115107. /**
  115108. * Defines the filename of the scene to load from
  115109. */
  115110. sceneFilename: string);
  115111. /**
  115112. * Execute the current task
  115113. * @param scene defines the scene where you want your assets to be loaded
  115114. * @param onSuccess is a callback called when the task is successfully executed
  115115. * @param onError is a callback called if an error occurs
  115116. */
  115117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115118. }
  115119. /**
  115120. * Define a task used by AssetsManager to load text content
  115121. */
  115122. export class TextFileAssetTask extends AbstractAssetTask {
  115123. /**
  115124. * Defines the name of the task
  115125. */
  115126. name: string;
  115127. /**
  115128. * Defines the location of the file to load
  115129. */
  115130. url: string;
  115131. /**
  115132. * Gets the loaded text string
  115133. */
  115134. text: string;
  115135. /**
  115136. * Callback called when the task is successful
  115137. */
  115138. onSuccess: (task: TextFileAssetTask) => void;
  115139. /**
  115140. * Callback called when the task is successful
  115141. */
  115142. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115143. /**
  115144. * Creates a new TextFileAssetTask object
  115145. * @param name defines the name of the task
  115146. * @param url defines the location of the file to load
  115147. */
  115148. constructor(
  115149. /**
  115150. * Defines the name of the task
  115151. */
  115152. name: string,
  115153. /**
  115154. * Defines the location of the file to load
  115155. */
  115156. url: string);
  115157. /**
  115158. * Execute the current task
  115159. * @param scene defines the scene where you want your assets to be loaded
  115160. * @param onSuccess is a callback called when the task is successfully executed
  115161. * @param onError is a callback called if an error occurs
  115162. */
  115163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115164. }
  115165. /**
  115166. * Define a task used by AssetsManager to load binary data
  115167. */
  115168. export class BinaryFileAssetTask extends AbstractAssetTask {
  115169. /**
  115170. * Defines the name of the task
  115171. */
  115172. name: string;
  115173. /**
  115174. * Defines the location of the file to load
  115175. */
  115176. url: string;
  115177. /**
  115178. * Gets the lodaded data (as an array buffer)
  115179. */
  115180. data: ArrayBuffer;
  115181. /**
  115182. * Callback called when the task is successful
  115183. */
  115184. onSuccess: (task: BinaryFileAssetTask) => void;
  115185. /**
  115186. * Callback called when the task is successful
  115187. */
  115188. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115189. /**
  115190. * Creates a new BinaryFileAssetTask object
  115191. * @param name defines the name of the new task
  115192. * @param url defines the location of the file to load
  115193. */
  115194. constructor(
  115195. /**
  115196. * Defines the name of the task
  115197. */
  115198. name: string,
  115199. /**
  115200. * Defines the location of the file to load
  115201. */
  115202. url: string);
  115203. /**
  115204. * Execute the current task
  115205. * @param scene defines the scene where you want your assets to be loaded
  115206. * @param onSuccess is a callback called when the task is successfully executed
  115207. * @param onError is a callback called if an error occurs
  115208. */
  115209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115210. }
  115211. /**
  115212. * Define a task used by AssetsManager to load images
  115213. */
  115214. export class ImageAssetTask extends AbstractAssetTask {
  115215. /**
  115216. * Defines the name of the task
  115217. */
  115218. name: string;
  115219. /**
  115220. * Defines the location of the image to load
  115221. */
  115222. url: string;
  115223. /**
  115224. * Gets the loaded images
  115225. */
  115226. image: HTMLImageElement;
  115227. /**
  115228. * Callback called when the task is successful
  115229. */
  115230. onSuccess: (task: ImageAssetTask) => void;
  115231. /**
  115232. * Callback called when the task is successful
  115233. */
  115234. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115235. /**
  115236. * Creates a new ImageAssetTask
  115237. * @param name defines the name of the task
  115238. * @param url defines the location of the image to load
  115239. */
  115240. constructor(
  115241. /**
  115242. * Defines the name of the task
  115243. */
  115244. name: string,
  115245. /**
  115246. * Defines the location of the image to load
  115247. */
  115248. url: string);
  115249. /**
  115250. * Execute the current task
  115251. * @param scene defines the scene where you want your assets to be loaded
  115252. * @param onSuccess is a callback called when the task is successfully executed
  115253. * @param onError is a callback called if an error occurs
  115254. */
  115255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115256. }
  115257. /**
  115258. * Defines the interface used by texture loading tasks
  115259. */
  115260. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115261. /**
  115262. * Gets the loaded texture
  115263. */
  115264. texture: TEX;
  115265. }
  115266. /**
  115267. * Define a task used by AssetsManager to load 2D textures
  115268. */
  115269. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115270. /**
  115271. * Defines the name of the task
  115272. */
  115273. name: string;
  115274. /**
  115275. * Defines the location of the file to load
  115276. */
  115277. url: string;
  115278. /**
  115279. * Defines if mipmap should not be generated (default is false)
  115280. */
  115281. noMipmap?: boolean | undefined;
  115282. /**
  115283. * Defines if texture must be inverted on Y axis (default is false)
  115284. */
  115285. invertY?: boolean | undefined;
  115286. /**
  115287. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115288. */
  115289. samplingMode: number;
  115290. /**
  115291. * Gets the loaded texture
  115292. */
  115293. texture: Texture;
  115294. /**
  115295. * Callback called when the task is successful
  115296. */
  115297. onSuccess: (task: TextureAssetTask) => void;
  115298. /**
  115299. * Callback called when the task is successful
  115300. */
  115301. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115302. /**
  115303. * Creates a new TextureAssetTask object
  115304. * @param name defines the name of the task
  115305. * @param url defines the location of the file to load
  115306. * @param noMipmap defines if mipmap should not be generated (default is false)
  115307. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115308. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115309. */
  115310. constructor(
  115311. /**
  115312. * Defines the name of the task
  115313. */
  115314. name: string,
  115315. /**
  115316. * Defines the location of the file to load
  115317. */
  115318. url: string,
  115319. /**
  115320. * Defines if mipmap should not be generated (default is false)
  115321. */
  115322. noMipmap?: boolean | undefined,
  115323. /**
  115324. * Defines if texture must be inverted on Y axis (default is false)
  115325. */
  115326. invertY?: boolean | undefined,
  115327. /**
  115328. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115329. */
  115330. samplingMode?: number);
  115331. /**
  115332. * Execute the current task
  115333. * @param scene defines the scene where you want your assets to be loaded
  115334. * @param onSuccess is a callback called when the task is successfully executed
  115335. * @param onError is a callback called if an error occurs
  115336. */
  115337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115338. }
  115339. /**
  115340. * Define a task used by AssetsManager to load cube textures
  115341. */
  115342. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115343. /**
  115344. * Defines the name of the task
  115345. */
  115346. name: string;
  115347. /**
  115348. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115349. */
  115350. url: string;
  115351. /**
  115352. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115353. */
  115354. extensions?: string[] | undefined;
  115355. /**
  115356. * Defines if mipmaps should not be generated (default is false)
  115357. */
  115358. noMipmap?: boolean | undefined;
  115359. /**
  115360. * Defines the explicit list of files (undefined by default)
  115361. */
  115362. files?: string[] | undefined;
  115363. /**
  115364. * Gets the loaded texture
  115365. */
  115366. texture: CubeTexture;
  115367. /**
  115368. * Callback called when the task is successful
  115369. */
  115370. onSuccess: (task: CubeTextureAssetTask) => void;
  115371. /**
  115372. * Callback called when the task is successful
  115373. */
  115374. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115375. /**
  115376. * Creates a new CubeTextureAssetTask
  115377. * @param name defines the name of the task
  115378. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115379. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115380. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115381. * @param files defines the explicit list of files (undefined by default)
  115382. */
  115383. constructor(
  115384. /**
  115385. * Defines the name of the task
  115386. */
  115387. name: string,
  115388. /**
  115389. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115390. */
  115391. url: string,
  115392. /**
  115393. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115394. */
  115395. extensions?: string[] | undefined,
  115396. /**
  115397. * Defines if mipmaps should not be generated (default is false)
  115398. */
  115399. noMipmap?: boolean | undefined,
  115400. /**
  115401. * Defines the explicit list of files (undefined by default)
  115402. */
  115403. files?: string[] | undefined);
  115404. /**
  115405. * Execute the current task
  115406. * @param scene defines the scene where you want your assets to be loaded
  115407. * @param onSuccess is a callback called when the task is successfully executed
  115408. * @param onError is a callback called if an error occurs
  115409. */
  115410. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115411. }
  115412. /**
  115413. * Define a task used by AssetsManager to load HDR cube textures
  115414. */
  115415. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115416. /**
  115417. * Defines the name of the task
  115418. */
  115419. name: string;
  115420. /**
  115421. * Defines the location of the file to load
  115422. */
  115423. url: string;
  115424. /**
  115425. * Defines the desired size (the more it increases the longer the generation will be)
  115426. */
  115427. size: number;
  115428. /**
  115429. * Defines if mipmaps should not be generated (default is false)
  115430. */
  115431. noMipmap: boolean;
  115432. /**
  115433. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115434. */
  115435. generateHarmonics: boolean;
  115436. /**
  115437. * 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)
  115438. */
  115439. gammaSpace: boolean;
  115440. /**
  115441. * Internal Use Only
  115442. */
  115443. reserved: boolean;
  115444. /**
  115445. * Gets the loaded texture
  115446. */
  115447. texture: HDRCubeTexture;
  115448. /**
  115449. * Callback called when the task is successful
  115450. */
  115451. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115452. /**
  115453. * Callback called when the task is successful
  115454. */
  115455. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115456. /**
  115457. * Creates a new HDRCubeTextureAssetTask object
  115458. * @param name defines the name of the task
  115459. * @param url defines the location of the file to load
  115460. * @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.
  115461. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115462. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115463. * @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)
  115464. * @param reserved Internal use only
  115465. */
  115466. constructor(
  115467. /**
  115468. * Defines the name of the task
  115469. */
  115470. name: string,
  115471. /**
  115472. * Defines the location of the file to load
  115473. */
  115474. url: string,
  115475. /**
  115476. * Defines the desired size (the more it increases the longer the generation will be)
  115477. */
  115478. size: number,
  115479. /**
  115480. * Defines if mipmaps should not be generated (default is false)
  115481. */
  115482. noMipmap?: boolean,
  115483. /**
  115484. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115485. */
  115486. generateHarmonics?: boolean,
  115487. /**
  115488. * 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)
  115489. */
  115490. gammaSpace?: boolean,
  115491. /**
  115492. * Internal Use Only
  115493. */
  115494. reserved?: boolean);
  115495. /**
  115496. * Execute the current task
  115497. * @param scene defines the scene where you want your assets to be loaded
  115498. * @param onSuccess is a callback called when the task is successfully executed
  115499. * @param onError is a callback called if an error occurs
  115500. */
  115501. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115502. }
  115503. /**
  115504. * Define a task used by AssetsManager to load Equirectangular cube textures
  115505. */
  115506. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115507. /**
  115508. * Defines the name of the task
  115509. */
  115510. name: string;
  115511. /**
  115512. * Defines the location of the file to load
  115513. */
  115514. url: string;
  115515. /**
  115516. * Defines the desired size (the more it increases the longer the generation will be)
  115517. */
  115518. size: number;
  115519. /**
  115520. * Defines if mipmaps should not be generated (default is false)
  115521. */
  115522. noMipmap: boolean;
  115523. /**
  115524. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115525. * but the standard material would require them in Gamma space) (default is true)
  115526. */
  115527. gammaSpace: boolean;
  115528. /**
  115529. * Gets the loaded texture
  115530. */
  115531. texture: EquiRectangularCubeTexture;
  115532. /**
  115533. * Callback called when the task is successful
  115534. */
  115535. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115536. /**
  115537. * Callback called when the task is successful
  115538. */
  115539. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115540. /**
  115541. * Creates a new EquiRectangularCubeTextureAssetTask object
  115542. * @param name defines the name of the task
  115543. * @param url defines the location of the file to load
  115544. * @param size defines the desired size (the more it increases the longer the generation will be)
  115545. * If the size is omitted this implies you are using a preprocessed cubemap.
  115546. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115547. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115548. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115549. * (default is true)
  115550. */
  115551. constructor(
  115552. /**
  115553. * Defines the name of the task
  115554. */
  115555. name: string,
  115556. /**
  115557. * Defines the location of the file to load
  115558. */
  115559. url: string,
  115560. /**
  115561. * Defines the desired size (the more it increases the longer the generation will be)
  115562. */
  115563. size: number,
  115564. /**
  115565. * Defines if mipmaps should not be generated (default is false)
  115566. */
  115567. noMipmap?: boolean,
  115568. /**
  115569. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115570. * but the standard material would require them in Gamma space) (default is true)
  115571. */
  115572. gammaSpace?: boolean);
  115573. /**
  115574. * Execute the current task
  115575. * @param scene defines the scene where you want your assets to be loaded
  115576. * @param onSuccess is a callback called when the task is successfully executed
  115577. * @param onError is a callback called if an error occurs
  115578. */
  115579. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115580. }
  115581. /**
  115582. * This class can be used to easily import assets into a scene
  115583. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115584. */
  115585. export class AssetsManager {
  115586. private _scene;
  115587. private _isLoading;
  115588. protected _tasks: AbstractAssetTask[];
  115589. protected _waitingTasksCount: number;
  115590. protected _totalTasksCount: number;
  115591. /**
  115592. * Callback called when all tasks are processed
  115593. */
  115594. onFinish: (tasks: AbstractAssetTask[]) => void;
  115595. /**
  115596. * Callback called when a task is successful
  115597. */
  115598. onTaskSuccess: (task: AbstractAssetTask) => void;
  115599. /**
  115600. * Callback called when a task had an error
  115601. */
  115602. onTaskError: (task: AbstractAssetTask) => void;
  115603. /**
  115604. * Callback called when a task is done (whatever the result is)
  115605. */
  115606. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115607. /**
  115608. * Observable called when all tasks are processed
  115609. */
  115610. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115611. /**
  115612. * Observable called when a task had an error
  115613. */
  115614. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115615. /**
  115616. * Observable called when all tasks were executed
  115617. */
  115618. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115619. /**
  115620. * Observable called when a task is done (whatever the result is)
  115621. */
  115622. onProgressObservable: Observable<IAssetsProgressEvent>;
  115623. /**
  115624. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115625. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115626. */
  115627. useDefaultLoadingScreen: boolean;
  115628. /**
  115629. * Creates a new AssetsManager
  115630. * @param scene defines the scene to work on
  115631. */
  115632. constructor(scene: Scene);
  115633. /**
  115634. * Add a MeshAssetTask to the list of active tasks
  115635. * @param taskName defines the name of the new task
  115636. * @param meshesNames defines the name of meshes to load
  115637. * @param rootUrl defines the root url to use to locate files
  115638. * @param sceneFilename defines the filename of the scene file
  115639. * @returns a new MeshAssetTask object
  115640. */
  115641. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115642. /**
  115643. * Add a TextFileAssetTask to the list of active tasks
  115644. * @param taskName defines the name of the new task
  115645. * @param url defines the url of the file to load
  115646. * @returns a new TextFileAssetTask object
  115647. */
  115648. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115649. /**
  115650. * Add a BinaryFileAssetTask to the list of active tasks
  115651. * @param taskName defines the name of the new task
  115652. * @param url defines the url of the file to load
  115653. * @returns a new BinaryFileAssetTask object
  115654. */
  115655. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115656. /**
  115657. * Add a ImageAssetTask to the list of active tasks
  115658. * @param taskName defines the name of the new task
  115659. * @param url defines the url of the file to load
  115660. * @returns a new ImageAssetTask object
  115661. */
  115662. addImageTask(taskName: string, url: string): ImageAssetTask;
  115663. /**
  115664. * Add a TextureAssetTask to the list of active tasks
  115665. * @param taskName defines the name of the new task
  115666. * @param url defines the url of the file to load
  115667. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115668. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115669. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115670. * @returns a new TextureAssetTask object
  115671. */
  115672. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115673. /**
  115674. * Add a CubeTextureAssetTask to the list of active tasks
  115675. * @param taskName defines the name of the new task
  115676. * @param url defines the url of the file to load
  115677. * @param extensions defines the extension to use to load the cube map (can be null)
  115678. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115679. * @param files defines the list of files to load (can be null)
  115680. * @returns a new CubeTextureAssetTask object
  115681. */
  115682. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115683. /**
  115684. *
  115685. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115686. * @param taskName defines the name of the new task
  115687. * @param url defines the url of the file to load
  115688. * @param size defines the size you want for the cubemap (can be null)
  115689. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115690. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115691. * @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)
  115692. * @param reserved Internal use only
  115693. * @returns a new HDRCubeTextureAssetTask object
  115694. */
  115695. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115696. /**
  115697. *
  115698. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115699. * @param taskName defines the name of the new task
  115700. * @param url defines the url of the file to load
  115701. * @param size defines the size you want for the cubemap (can be null)
  115702. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115703. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115704. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115705. * @returns a new EquiRectangularCubeTextureAssetTask object
  115706. */
  115707. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115708. /**
  115709. * Remove a task from the assets manager.
  115710. * @param task the task to remove
  115711. */
  115712. removeTask(task: AbstractAssetTask): void;
  115713. private _decreaseWaitingTasksCount;
  115714. private _runTask;
  115715. /**
  115716. * Reset the AssetsManager and remove all tasks
  115717. * @return the current instance of the AssetsManager
  115718. */
  115719. reset(): AssetsManager;
  115720. /**
  115721. * Start the loading process
  115722. * @return the current instance of the AssetsManager
  115723. */
  115724. load(): AssetsManager;
  115725. /**
  115726. * Start the loading process as an async operation
  115727. * @return a promise returning the list of failed tasks
  115728. */
  115729. loadAsync(): Promise<void>;
  115730. }
  115731. }
  115732. declare module BABYLON {
  115733. /**
  115734. * Wrapper class for promise with external resolve and reject.
  115735. */
  115736. export class Deferred<T> {
  115737. /**
  115738. * The promise associated with this deferred object.
  115739. */
  115740. readonly promise: Promise<T>;
  115741. private _resolve;
  115742. private _reject;
  115743. /**
  115744. * The resolve method of the promise associated with this deferred object.
  115745. */
  115746. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115747. /**
  115748. * The reject method of the promise associated with this deferred object.
  115749. */
  115750. readonly reject: (reason?: any) => void;
  115751. /**
  115752. * Constructor for this deferred object.
  115753. */
  115754. constructor();
  115755. }
  115756. }
  115757. declare module BABYLON {
  115758. /**
  115759. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115760. */
  115761. export class MeshExploder {
  115762. private _centerMesh;
  115763. private _meshes;
  115764. private _meshesOrigins;
  115765. private _toCenterVectors;
  115766. private _scaledDirection;
  115767. private _newPosition;
  115768. private _centerPosition;
  115769. /**
  115770. * Explodes meshes from a center mesh.
  115771. * @param meshes The meshes to explode.
  115772. * @param centerMesh The mesh to be center of explosion.
  115773. */
  115774. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115775. private _setCenterMesh;
  115776. /**
  115777. * Get class name
  115778. * @returns "MeshExploder"
  115779. */
  115780. getClassName(): string;
  115781. /**
  115782. * "Exploded meshes"
  115783. * @returns Array of meshes with the centerMesh at index 0.
  115784. */
  115785. getMeshes(): Array<Mesh>;
  115786. /**
  115787. * Explodes meshes giving a specific direction
  115788. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115789. */
  115790. explode(direction?: number): void;
  115791. }
  115792. }
  115793. declare module BABYLON {
  115794. /**
  115795. * Class used to help managing file picking and drag'n'drop
  115796. */
  115797. export class FilesInput {
  115798. /**
  115799. * List of files ready to be loaded
  115800. */
  115801. static readonly FilesToLoad: {
  115802. [key: string]: File;
  115803. };
  115804. /**
  115805. * Callback called when a file is processed
  115806. */
  115807. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115808. private _engine;
  115809. private _currentScene;
  115810. private _sceneLoadedCallback;
  115811. private _progressCallback;
  115812. private _additionalRenderLoopLogicCallback;
  115813. private _textureLoadingCallback;
  115814. private _startingProcessingFilesCallback;
  115815. private _onReloadCallback;
  115816. private _errorCallback;
  115817. private _elementToMonitor;
  115818. private _sceneFileToLoad;
  115819. private _filesToLoad;
  115820. /**
  115821. * Creates a new FilesInput
  115822. * @param engine defines the rendering engine
  115823. * @param scene defines the hosting scene
  115824. * @param sceneLoadedCallback callback called when scene is loaded
  115825. * @param progressCallback callback called to track progress
  115826. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115827. * @param textureLoadingCallback callback called when a texture is loading
  115828. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115829. * @param onReloadCallback callback called when a reload is requested
  115830. * @param errorCallback callback call if an error occurs
  115831. */
  115832. 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);
  115833. private _dragEnterHandler;
  115834. private _dragOverHandler;
  115835. private _dropHandler;
  115836. /**
  115837. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115838. * @param elementToMonitor defines the DOM element to track
  115839. */
  115840. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115841. /**
  115842. * Release all associated resources
  115843. */
  115844. dispose(): void;
  115845. private renderFunction;
  115846. private drag;
  115847. private drop;
  115848. private _traverseFolder;
  115849. private _processFiles;
  115850. /**
  115851. * Load files from a drop event
  115852. * @param event defines the drop event to use as source
  115853. */
  115854. loadFiles(event: any): void;
  115855. private _processReload;
  115856. /**
  115857. * Reload the current scene from the loaded files
  115858. */
  115859. reload(): void;
  115860. }
  115861. }
  115862. declare module BABYLON {
  115863. /**
  115864. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115866. */
  115867. export class SceneOptimization {
  115868. /**
  115869. * Defines the priority of this optimization (0 by default which means first in the list)
  115870. */
  115871. priority: number;
  115872. /**
  115873. * Gets a string describing the action executed by the current optimization
  115874. * @returns description string
  115875. */
  115876. getDescription(): string;
  115877. /**
  115878. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115879. * @param scene defines the current scene where to apply this optimization
  115880. * @param optimizer defines the current optimizer
  115881. * @returns true if everything that can be done was applied
  115882. */
  115883. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115884. /**
  115885. * Creates the SceneOptimization object
  115886. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115887. * @param desc defines the description associated with the optimization
  115888. */
  115889. constructor(
  115890. /**
  115891. * Defines the priority of this optimization (0 by default which means first in the list)
  115892. */
  115893. priority?: number);
  115894. }
  115895. /**
  115896. * Defines an optimization used to reduce the size of render target textures
  115897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115898. */
  115899. export class TextureOptimization extends SceneOptimization {
  115900. /**
  115901. * Defines the priority of this optimization (0 by default which means first in the list)
  115902. */
  115903. priority: number;
  115904. /**
  115905. * 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
  115906. */
  115907. maximumSize: number;
  115908. /**
  115909. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115910. */
  115911. step: number;
  115912. /**
  115913. * Gets a string describing the action executed by the current optimization
  115914. * @returns description string
  115915. */
  115916. getDescription(): string;
  115917. /**
  115918. * Creates the TextureOptimization object
  115919. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115920. * @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
  115921. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115922. */
  115923. constructor(
  115924. /**
  115925. * Defines the priority of this optimization (0 by default which means first in the list)
  115926. */
  115927. priority?: number,
  115928. /**
  115929. * 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
  115930. */
  115931. maximumSize?: number,
  115932. /**
  115933. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115934. */
  115935. step?: number);
  115936. /**
  115937. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115938. * @param scene defines the current scene where to apply this optimization
  115939. * @param optimizer defines the current optimizer
  115940. * @returns true if everything that can be done was applied
  115941. */
  115942. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115943. }
  115944. /**
  115945. * Defines an optimization used to increase or decrease the rendering resolution
  115946. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115947. */
  115948. export class HardwareScalingOptimization extends SceneOptimization {
  115949. /**
  115950. * Defines the priority of this optimization (0 by default which means first in the list)
  115951. */
  115952. priority: number;
  115953. /**
  115954. * Defines the maximum scale to use (2 by default)
  115955. */
  115956. maximumScale: number;
  115957. /**
  115958. * Defines the step to use between two passes (0.5 by default)
  115959. */
  115960. step: number;
  115961. private _currentScale;
  115962. private _directionOffset;
  115963. /**
  115964. * Gets a string describing the action executed by the current optimization
  115965. * @return description string
  115966. */
  115967. getDescription(): string;
  115968. /**
  115969. * Creates the HardwareScalingOptimization object
  115970. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115971. * @param maximumScale defines the maximum scale to use (2 by default)
  115972. * @param step defines the step to use between two passes (0.5 by default)
  115973. */
  115974. constructor(
  115975. /**
  115976. * Defines the priority of this optimization (0 by default which means first in the list)
  115977. */
  115978. priority?: number,
  115979. /**
  115980. * Defines the maximum scale to use (2 by default)
  115981. */
  115982. maximumScale?: number,
  115983. /**
  115984. * Defines the step to use between two passes (0.5 by default)
  115985. */
  115986. step?: number);
  115987. /**
  115988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115989. * @param scene defines the current scene where to apply this optimization
  115990. * @param optimizer defines the current optimizer
  115991. * @returns true if everything that can be done was applied
  115992. */
  115993. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115994. }
  115995. /**
  115996. * Defines an optimization used to remove shadows
  115997. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115998. */
  115999. export class ShadowsOptimization extends SceneOptimization {
  116000. /**
  116001. * Gets a string describing the action executed by the current optimization
  116002. * @return description string
  116003. */
  116004. getDescription(): string;
  116005. /**
  116006. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116007. * @param scene defines the current scene where to apply this optimization
  116008. * @param optimizer defines the current optimizer
  116009. * @returns true if everything that can be done was applied
  116010. */
  116011. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116012. }
  116013. /**
  116014. * Defines an optimization used to turn post-processes off
  116015. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116016. */
  116017. export class PostProcessesOptimization extends SceneOptimization {
  116018. /**
  116019. * Gets a string describing the action executed by the current optimization
  116020. * @return description string
  116021. */
  116022. getDescription(): string;
  116023. /**
  116024. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116025. * @param scene defines the current scene where to apply this optimization
  116026. * @param optimizer defines the current optimizer
  116027. * @returns true if everything that can be done was applied
  116028. */
  116029. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116030. }
  116031. /**
  116032. * Defines an optimization used to turn lens flares off
  116033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116034. */
  116035. export class LensFlaresOptimization extends SceneOptimization {
  116036. /**
  116037. * Gets a string describing the action executed by the current optimization
  116038. * @return description string
  116039. */
  116040. getDescription(): string;
  116041. /**
  116042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116043. * @param scene defines the current scene where to apply this optimization
  116044. * @param optimizer defines the current optimizer
  116045. * @returns true if everything that can be done was applied
  116046. */
  116047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116048. }
  116049. /**
  116050. * Defines an optimization based on user defined callback.
  116051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116052. */
  116053. export class CustomOptimization extends SceneOptimization {
  116054. /**
  116055. * Callback called to apply the custom optimization.
  116056. */
  116057. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116058. /**
  116059. * Callback called to get custom description
  116060. */
  116061. onGetDescription: () => string;
  116062. /**
  116063. * Gets a string describing the action executed by the current optimization
  116064. * @returns description string
  116065. */
  116066. getDescription(): string;
  116067. /**
  116068. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116069. * @param scene defines the current scene where to apply this optimization
  116070. * @param optimizer defines the current optimizer
  116071. * @returns true if everything that can be done was applied
  116072. */
  116073. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116074. }
  116075. /**
  116076. * Defines an optimization used to turn particles off
  116077. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116078. */
  116079. export class ParticlesOptimization extends SceneOptimization {
  116080. /**
  116081. * Gets a string describing the action executed by the current optimization
  116082. * @return description string
  116083. */
  116084. getDescription(): string;
  116085. /**
  116086. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116087. * @param scene defines the current scene where to apply this optimization
  116088. * @param optimizer defines the current optimizer
  116089. * @returns true if everything that can be done was applied
  116090. */
  116091. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116092. }
  116093. /**
  116094. * Defines an optimization used to turn render targets off
  116095. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116096. */
  116097. export class RenderTargetsOptimization extends SceneOptimization {
  116098. /**
  116099. * Gets a string describing the action executed by the current optimization
  116100. * @return description string
  116101. */
  116102. getDescription(): string;
  116103. /**
  116104. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116105. * @param scene defines the current scene where to apply this optimization
  116106. * @param optimizer defines the current optimizer
  116107. * @returns true if everything that can be done was applied
  116108. */
  116109. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116110. }
  116111. /**
  116112. * Defines an optimization used to merge meshes with compatible materials
  116113. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116114. */
  116115. export class MergeMeshesOptimization extends SceneOptimization {
  116116. private static _UpdateSelectionTree;
  116117. /**
  116118. * Gets or sets a boolean which defines if optimization octree has to be updated
  116119. */
  116120. /**
  116121. * Gets or sets a boolean which defines if optimization octree has to be updated
  116122. */
  116123. static UpdateSelectionTree: boolean;
  116124. /**
  116125. * Gets a string describing the action executed by the current optimization
  116126. * @return description string
  116127. */
  116128. getDescription(): string;
  116129. private _canBeMerged;
  116130. /**
  116131. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116132. * @param scene defines the current scene where to apply this optimization
  116133. * @param optimizer defines the current optimizer
  116134. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116135. * @returns true if everything that can be done was applied
  116136. */
  116137. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116138. }
  116139. /**
  116140. * Defines a list of options used by SceneOptimizer
  116141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116142. */
  116143. export class SceneOptimizerOptions {
  116144. /**
  116145. * Defines the target frame rate to reach (60 by default)
  116146. */
  116147. targetFrameRate: number;
  116148. /**
  116149. * Defines the interval between two checkes (2000ms by default)
  116150. */
  116151. trackerDuration: number;
  116152. /**
  116153. * Gets the list of optimizations to apply
  116154. */
  116155. optimizations: SceneOptimization[];
  116156. /**
  116157. * Creates a new list of options used by SceneOptimizer
  116158. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116159. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116160. */
  116161. constructor(
  116162. /**
  116163. * Defines the target frame rate to reach (60 by default)
  116164. */
  116165. targetFrameRate?: number,
  116166. /**
  116167. * Defines the interval between two checkes (2000ms by default)
  116168. */
  116169. trackerDuration?: number);
  116170. /**
  116171. * Add a new optimization
  116172. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116173. * @returns the current SceneOptimizerOptions
  116174. */
  116175. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116176. /**
  116177. * Add a new custom optimization
  116178. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116179. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116180. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116181. * @returns the current SceneOptimizerOptions
  116182. */
  116183. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116184. /**
  116185. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116186. * @param targetFrameRate defines the target frame rate (60 by default)
  116187. * @returns a SceneOptimizerOptions object
  116188. */
  116189. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116190. /**
  116191. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116192. * @param targetFrameRate defines the target frame rate (60 by default)
  116193. * @returns a SceneOptimizerOptions object
  116194. */
  116195. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116196. /**
  116197. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116198. * @param targetFrameRate defines the target frame rate (60 by default)
  116199. * @returns a SceneOptimizerOptions object
  116200. */
  116201. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116202. }
  116203. /**
  116204. * Class used to run optimizations in order to reach a target frame rate
  116205. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116206. */
  116207. export class SceneOptimizer implements IDisposable {
  116208. private _isRunning;
  116209. private _options;
  116210. private _scene;
  116211. private _currentPriorityLevel;
  116212. private _targetFrameRate;
  116213. private _trackerDuration;
  116214. private _currentFrameRate;
  116215. private _sceneDisposeObserver;
  116216. private _improvementMode;
  116217. /**
  116218. * Defines an observable called when the optimizer reaches the target frame rate
  116219. */
  116220. onSuccessObservable: Observable<SceneOptimizer>;
  116221. /**
  116222. * Defines an observable called when the optimizer enables an optimization
  116223. */
  116224. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116225. /**
  116226. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116227. */
  116228. onFailureObservable: Observable<SceneOptimizer>;
  116229. /**
  116230. * Gets a boolean indicating if the optimizer is in improvement mode
  116231. */
  116232. readonly isInImprovementMode: boolean;
  116233. /**
  116234. * Gets the current priority level (0 at start)
  116235. */
  116236. readonly currentPriorityLevel: number;
  116237. /**
  116238. * Gets the current frame rate checked by the SceneOptimizer
  116239. */
  116240. readonly currentFrameRate: number;
  116241. /**
  116242. * Gets or sets the current target frame rate (60 by default)
  116243. */
  116244. /**
  116245. * Gets or sets the current target frame rate (60 by default)
  116246. */
  116247. targetFrameRate: number;
  116248. /**
  116249. * Gets or sets the current interval between two checks (every 2000ms by default)
  116250. */
  116251. /**
  116252. * Gets or sets the current interval between two checks (every 2000ms by default)
  116253. */
  116254. trackerDuration: number;
  116255. /**
  116256. * Gets the list of active optimizations
  116257. */
  116258. readonly optimizations: SceneOptimization[];
  116259. /**
  116260. * Creates a new SceneOptimizer
  116261. * @param scene defines the scene to work on
  116262. * @param options defines the options to use with the SceneOptimizer
  116263. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116264. * @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)
  116265. */
  116266. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116267. /**
  116268. * Stops the current optimizer
  116269. */
  116270. stop(): void;
  116271. /**
  116272. * Reset the optimizer to initial step (current priority level = 0)
  116273. */
  116274. reset(): void;
  116275. /**
  116276. * Start the optimizer. By default it will try to reach a specific framerate
  116277. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116278. */
  116279. start(): void;
  116280. private _checkCurrentState;
  116281. /**
  116282. * Release all resources
  116283. */
  116284. dispose(): void;
  116285. /**
  116286. * Helper function to create a SceneOptimizer with one single line of code
  116287. * @param scene defines the scene to work on
  116288. * @param options defines the options to use with the SceneOptimizer
  116289. * @param onSuccess defines a callback to call on success
  116290. * @param onFailure defines a callback to call on failure
  116291. * @returns the new SceneOptimizer object
  116292. */
  116293. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116294. }
  116295. }
  116296. declare module BABYLON {
  116297. /**
  116298. * Class used to serialize a scene into a string
  116299. */
  116300. export class SceneSerializer {
  116301. /**
  116302. * Clear cache used by a previous serialization
  116303. */
  116304. static ClearCache(): void;
  116305. /**
  116306. * Serialize a scene into a JSON compatible object
  116307. * @param scene defines the scene to serialize
  116308. * @returns a JSON compatible object
  116309. */
  116310. static Serialize(scene: Scene): any;
  116311. /**
  116312. * Serialize a mesh into a JSON compatible object
  116313. * @param toSerialize defines the mesh to serialize
  116314. * @param withParents defines if parents must be serialized as well
  116315. * @param withChildren defines if children must be serialized as well
  116316. * @returns a JSON compatible object
  116317. */
  116318. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116319. }
  116320. }
  116321. declare module BABYLON {
  116322. /**
  116323. * Class used to host texture specific utilities
  116324. */
  116325. export class TextureTools {
  116326. /**
  116327. * Uses the GPU to create a copy texture rescaled at a given size
  116328. * @param texture Texture to copy from
  116329. * @param width defines the desired width
  116330. * @param height defines the desired height
  116331. * @param useBilinearMode defines if bilinear mode has to be used
  116332. * @return the generated texture
  116333. */
  116334. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116335. }
  116336. }
  116337. declare module BABYLON {
  116338. /**
  116339. * This represents the different options avilable for the video capture.
  116340. */
  116341. export interface VideoRecorderOptions {
  116342. /** Defines the mime type of the video */
  116343. mimeType: string;
  116344. /** Defines the video the video should be recorded at */
  116345. fps: number;
  116346. /** Defines the chunk size for the recording data */
  116347. recordChunckSize: number;
  116348. /** The audio tracks to attach to the record */
  116349. audioTracks?: MediaStreamTrack[];
  116350. }
  116351. /**
  116352. * This can helps recording videos from BabylonJS.
  116353. * This is based on the available WebRTC functionalities of the browser.
  116354. *
  116355. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116356. */
  116357. export class VideoRecorder {
  116358. private static readonly _defaultOptions;
  116359. /**
  116360. * Returns wehther or not the VideoRecorder is available in your browser.
  116361. * @param engine Defines the Babylon Engine to check the support for
  116362. * @returns true if supported otherwise false
  116363. */
  116364. static IsSupported(engine: Engine): boolean;
  116365. private readonly _options;
  116366. private _canvas;
  116367. private _mediaRecorder;
  116368. private _recordedChunks;
  116369. private _fileName;
  116370. private _resolve;
  116371. private _reject;
  116372. /**
  116373. * True wether a recording is already in progress.
  116374. */
  116375. readonly isRecording: boolean;
  116376. /**
  116377. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116378. * a video file.
  116379. * @param engine Defines the BabylonJS Engine you wish to record
  116380. * @param options Defines options that can be used to customized the capture
  116381. */
  116382. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116383. /**
  116384. * Stops the current recording before the default capture timeout passed in the startRecording
  116385. * functions.
  116386. */
  116387. stopRecording(): void;
  116388. /**
  116389. * Starts recording the canvas for a max duration specified in parameters.
  116390. * @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.
  116391. * @param maxDuration Defines the maximum recording time in seconds.
  116392. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116393. * @return a promise callback at the end of the recording with the video data in Blob.
  116394. */
  116395. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116396. /**
  116397. * Releases internal resources used during the recording.
  116398. */
  116399. dispose(): void;
  116400. private _handleDataAvailable;
  116401. private _handleError;
  116402. private _handleStop;
  116403. }
  116404. }
  116405. declare module BABYLON {
  116406. /**
  116407. * Class containing a set of static utilities functions for screenshots
  116408. */
  116409. export class ScreenshotTools {
  116410. /**
  116411. * Captures a screenshot of the current rendering
  116412. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116413. * @param engine defines the rendering engine
  116414. * @param camera defines the source camera
  116415. * @param size This parameter can be set to a single number or to an object with the
  116416. * following (optional) properties: precision, width, height. If a single number is passed,
  116417. * it will be used for both width and height. If an object is passed, the screenshot size
  116418. * will be derived from the parameters. The precision property is a multiplier allowing
  116419. * rendering at a higher or lower resolution
  116420. * @param successCallback defines the callback receives a single parameter which contains the
  116421. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116422. * src parameter of an <img> to display it
  116423. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116424. * Check your browser for supported MIME types
  116425. */
  116426. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116427. /**
  116428. * Generates an image screenshot from the specified camera.
  116429. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116430. * @param engine The engine to use for rendering
  116431. * @param camera The camera to use for rendering
  116432. * @param size This parameter can be set to a single number or to an object with the
  116433. * following (optional) properties: precision, width, height. If a single number is passed,
  116434. * it will be used for both width and height. If an object is passed, the screenshot size
  116435. * will be derived from the parameters. The precision property is a multiplier allowing
  116436. * rendering at a higher or lower resolution
  116437. * @param successCallback The callback receives a single parameter which contains the
  116438. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116439. * src parameter of an <img> to display it
  116440. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116441. * Check your browser for supported MIME types
  116442. * @param samples Texture samples (default: 1)
  116443. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116444. * @param fileName A name for for the downloaded file.
  116445. */
  116446. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116447. }
  116448. }
  116449. declare module BABYLON {
  116450. /**
  116451. * A cursor which tracks a point on a path
  116452. */
  116453. export class PathCursor {
  116454. private path;
  116455. /**
  116456. * Stores path cursor callbacks for when an onchange event is triggered
  116457. */
  116458. private _onchange;
  116459. /**
  116460. * The value of the path cursor
  116461. */
  116462. value: number;
  116463. /**
  116464. * The animation array of the path cursor
  116465. */
  116466. animations: Animation[];
  116467. /**
  116468. * Initializes the path cursor
  116469. * @param path The path to track
  116470. */
  116471. constructor(path: Path2);
  116472. /**
  116473. * Gets the cursor point on the path
  116474. * @returns A point on the path cursor at the cursor location
  116475. */
  116476. getPoint(): Vector3;
  116477. /**
  116478. * Moves the cursor ahead by the step amount
  116479. * @param step The amount to move the cursor forward
  116480. * @returns This path cursor
  116481. */
  116482. moveAhead(step?: number): PathCursor;
  116483. /**
  116484. * Moves the cursor behind by the step amount
  116485. * @param step The amount to move the cursor back
  116486. * @returns This path cursor
  116487. */
  116488. moveBack(step?: number): PathCursor;
  116489. /**
  116490. * Moves the cursor by the step amount
  116491. * If the step amount is greater than one, an exception is thrown
  116492. * @param step The amount to move the cursor
  116493. * @returns This path cursor
  116494. */
  116495. move(step: number): PathCursor;
  116496. /**
  116497. * Ensures that the value is limited between zero and one
  116498. * @returns This path cursor
  116499. */
  116500. private ensureLimits;
  116501. /**
  116502. * Runs onchange callbacks on change (used by the animation engine)
  116503. * @returns This path cursor
  116504. */
  116505. private raiseOnChange;
  116506. /**
  116507. * Executes a function on change
  116508. * @param f A path cursor onchange callback
  116509. * @returns This path cursor
  116510. */
  116511. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116512. }
  116513. }
  116514. declare module BABYLON {
  116515. /** @hidden */
  116516. export var blurPixelShader: {
  116517. name: string;
  116518. shader: string;
  116519. };
  116520. }
  116521. declare module BABYLON {
  116522. /** @hidden */
  116523. export var bones300Declaration: {
  116524. name: string;
  116525. shader: string;
  116526. };
  116527. }
  116528. declare module BABYLON {
  116529. /** @hidden */
  116530. export var instances300Declaration: {
  116531. name: string;
  116532. shader: string;
  116533. };
  116534. }
  116535. declare module BABYLON {
  116536. /** @hidden */
  116537. export var pointCloudVertexDeclaration: {
  116538. name: string;
  116539. shader: string;
  116540. };
  116541. }
  116542. // Mixins
  116543. interface Window {
  116544. mozIndexedDB: IDBFactory;
  116545. webkitIndexedDB: IDBFactory;
  116546. msIndexedDB: IDBFactory;
  116547. webkitURL: typeof URL;
  116548. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116549. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116550. WebGLRenderingContext: WebGLRenderingContext;
  116551. MSGesture: MSGesture;
  116552. CANNON: any;
  116553. AudioContext: AudioContext;
  116554. webkitAudioContext: AudioContext;
  116555. PointerEvent: any;
  116556. Math: Math;
  116557. Uint8Array: Uint8ArrayConstructor;
  116558. Float32Array: Float32ArrayConstructor;
  116559. mozURL: typeof URL;
  116560. msURL: typeof URL;
  116561. VRFrameData: any; // WebVR, from specs 1.1
  116562. DracoDecoderModule: any;
  116563. setImmediate(handler: (...args: any[]) => void): number;
  116564. }
  116565. interface HTMLCanvasElement {
  116566. requestPointerLock(): void;
  116567. msRequestPointerLock?(): void;
  116568. mozRequestPointerLock?(): void;
  116569. webkitRequestPointerLock?(): void;
  116570. /** Track wether a record is in progress */
  116571. isRecording: boolean;
  116572. /** Capture Stream method defined by some browsers */
  116573. captureStream(fps?: number): MediaStream;
  116574. }
  116575. interface CanvasRenderingContext2D {
  116576. msImageSmoothingEnabled: boolean;
  116577. }
  116578. interface MouseEvent {
  116579. mozMovementX: number;
  116580. mozMovementY: number;
  116581. webkitMovementX: number;
  116582. webkitMovementY: number;
  116583. msMovementX: number;
  116584. msMovementY: number;
  116585. }
  116586. interface Navigator {
  116587. mozGetVRDevices: (any: any) => any;
  116588. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116589. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116590. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116591. webkitGetGamepads(): Gamepad[];
  116592. msGetGamepads(): Gamepad[];
  116593. webkitGamepads(): Gamepad[];
  116594. }
  116595. interface HTMLVideoElement {
  116596. mozSrcObject: any;
  116597. }
  116598. interface Math {
  116599. fround(x: number): number;
  116600. imul(a: number, b: number): number;
  116601. }
  116602. interface WebGLRenderingContext {
  116603. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116604. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116605. vertexAttribDivisor(index: number, divisor: number): void;
  116606. createVertexArray(): any;
  116607. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116608. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116609. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116610. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116611. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116612. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116613. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116614. // Queries
  116615. createQuery(): WebGLQuery;
  116616. deleteQuery(query: WebGLQuery): void;
  116617. beginQuery(target: number, query: WebGLQuery): void;
  116618. endQuery(target: number): void;
  116619. getQueryParameter(query: WebGLQuery, pname: number): any;
  116620. getQuery(target: number, pname: number): any;
  116621. MAX_SAMPLES: number;
  116622. RGBA8: number;
  116623. READ_FRAMEBUFFER: number;
  116624. DRAW_FRAMEBUFFER: number;
  116625. UNIFORM_BUFFER: number;
  116626. HALF_FLOAT_OES: number;
  116627. RGBA16F: number;
  116628. RGBA32F: number;
  116629. R32F: number;
  116630. RG32F: number;
  116631. RGB32F: number;
  116632. R16F: number;
  116633. RG16F: number;
  116634. RGB16F: number;
  116635. RED: number;
  116636. RG: number;
  116637. R8: number;
  116638. RG8: number;
  116639. UNSIGNED_INT_24_8: number;
  116640. DEPTH24_STENCIL8: number;
  116641. /* Multiple Render Targets */
  116642. drawBuffers(buffers: number[]): void;
  116643. readBuffer(src: number): void;
  116644. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116645. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116646. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116647. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116648. // Occlusion Query
  116649. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116650. ANY_SAMPLES_PASSED: number;
  116651. QUERY_RESULT_AVAILABLE: number;
  116652. QUERY_RESULT: number;
  116653. }
  116654. interface WebGLProgram {
  116655. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116656. }
  116657. interface EXT_disjoint_timer_query {
  116658. QUERY_COUNTER_BITS_EXT: number;
  116659. TIME_ELAPSED_EXT: number;
  116660. TIMESTAMP_EXT: number;
  116661. GPU_DISJOINT_EXT: number;
  116662. QUERY_RESULT_EXT: number;
  116663. QUERY_RESULT_AVAILABLE_EXT: number;
  116664. queryCounterEXT(query: WebGLQuery, target: number): void;
  116665. createQueryEXT(): WebGLQuery;
  116666. beginQueryEXT(target: number, query: WebGLQuery): void;
  116667. endQueryEXT(target: number): void;
  116668. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116669. deleteQueryEXT(query: WebGLQuery): void;
  116670. }
  116671. interface WebGLUniformLocation {
  116672. _currentState: any;
  116673. }
  116674. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116675. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116676. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116677. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116678. interface WebGLRenderingContext {
  116679. readonly RASTERIZER_DISCARD: number;
  116680. readonly DEPTH_COMPONENT24: number;
  116681. readonly TEXTURE_3D: number;
  116682. readonly TEXTURE_2D_ARRAY: number;
  116683. readonly TEXTURE_COMPARE_FUNC: number;
  116684. readonly TEXTURE_COMPARE_MODE: number;
  116685. readonly COMPARE_REF_TO_TEXTURE: number;
  116686. readonly TEXTURE_WRAP_R: number;
  116687. readonly HALF_FLOAT: number;
  116688. readonly RGB8: number;
  116689. readonly RED_INTEGER: number;
  116690. readonly RG_INTEGER: number;
  116691. readonly RGB_INTEGER: number;
  116692. readonly RGBA_INTEGER: number;
  116693. readonly R8_SNORM: number;
  116694. readonly RG8_SNORM: number;
  116695. readonly RGB8_SNORM: number;
  116696. readonly RGBA8_SNORM: number;
  116697. readonly R8I: number;
  116698. readonly RG8I: number;
  116699. readonly RGB8I: number;
  116700. readonly RGBA8I: number;
  116701. readonly R8UI: number;
  116702. readonly RG8UI: number;
  116703. readonly RGB8UI: number;
  116704. readonly RGBA8UI: number;
  116705. readonly R16I: number;
  116706. readonly RG16I: number;
  116707. readonly RGB16I: number;
  116708. readonly RGBA16I: number;
  116709. readonly R16UI: number;
  116710. readonly RG16UI: number;
  116711. readonly RGB16UI: number;
  116712. readonly RGBA16UI: number;
  116713. readonly R32I: number;
  116714. readonly RG32I: number;
  116715. readonly RGB32I: number;
  116716. readonly RGBA32I: number;
  116717. readonly R32UI: number;
  116718. readonly RG32UI: number;
  116719. readonly RGB32UI: number;
  116720. readonly RGBA32UI: number;
  116721. readonly RGB10_A2UI: number;
  116722. readonly R11F_G11F_B10F: number;
  116723. readonly RGB9_E5: number;
  116724. readonly RGB10_A2: number;
  116725. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116726. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116727. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116728. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116729. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116730. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116731. 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;
  116732. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116733. readonly TRANSFORM_FEEDBACK: number;
  116734. readonly INTERLEAVED_ATTRIBS: number;
  116735. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116736. createTransformFeedback(): WebGLTransformFeedback;
  116737. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116738. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116739. beginTransformFeedback(primitiveMode: number): void;
  116740. endTransformFeedback(): void;
  116741. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116742. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116743. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116744. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116745. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116746. }
  116747. interface ImageBitmap {
  116748. readonly width: number;
  116749. readonly height: number;
  116750. close(): void;
  116751. }
  116752. interface WebGLQuery extends WebGLObject {
  116753. }
  116754. declare var WebGLQuery: {
  116755. prototype: WebGLQuery;
  116756. new(): WebGLQuery;
  116757. };
  116758. interface WebGLSampler extends WebGLObject {
  116759. }
  116760. declare var WebGLSampler: {
  116761. prototype: WebGLSampler;
  116762. new(): WebGLSampler;
  116763. };
  116764. interface WebGLSync extends WebGLObject {
  116765. }
  116766. declare var WebGLSync: {
  116767. prototype: WebGLSync;
  116768. new(): WebGLSync;
  116769. };
  116770. interface WebGLTransformFeedback extends WebGLObject {
  116771. }
  116772. declare var WebGLTransformFeedback: {
  116773. prototype: WebGLTransformFeedback;
  116774. new(): WebGLTransformFeedback;
  116775. };
  116776. interface WebGLVertexArrayObject extends WebGLObject {
  116777. }
  116778. declare var WebGLVertexArrayObject: {
  116779. prototype: WebGLVertexArrayObject;
  116780. new(): WebGLVertexArrayObject;
  116781. };
  116782. // Type definitions for WebVR API
  116783. // Project: https://w3c.github.io/webvr/
  116784. // Definitions by: six a <https://github.com/lostfictions>
  116785. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116786. interface VRDisplay extends EventTarget {
  116787. /**
  116788. * Dictionary of capabilities describing the VRDisplay.
  116789. */
  116790. readonly capabilities: VRDisplayCapabilities;
  116791. /**
  116792. * z-depth defining the far plane of the eye view frustum
  116793. * enables mapping of values in the render target depth
  116794. * attachment to scene coordinates. Initially set to 10000.0.
  116795. */
  116796. depthFar: number;
  116797. /**
  116798. * z-depth defining the near plane of the eye view frustum
  116799. * enables mapping of values in the render target depth
  116800. * attachment to scene coordinates. Initially set to 0.01.
  116801. */
  116802. depthNear: number;
  116803. /**
  116804. * An identifier for this distinct VRDisplay. Used as an
  116805. * association point in the Gamepad API.
  116806. */
  116807. readonly displayId: number;
  116808. /**
  116809. * A display name, a user-readable name identifying it.
  116810. */
  116811. readonly displayName: string;
  116812. readonly isConnected: boolean;
  116813. readonly isPresenting: boolean;
  116814. /**
  116815. * If this VRDisplay supports room-scale experiences, the optional
  116816. * stage attribute contains details on the room-scale parameters.
  116817. */
  116818. readonly stageParameters: VRStageParameters | null;
  116819. /**
  116820. * Passing the value returned by `requestAnimationFrame` to
  116821. * `cancelAnimationFrame` will unregister the callback.
  116822. * @param handle Define the hanle of the request to cancel
  116823. */
  116824. cancelAnimationFrame(handle: number): void;
  116825. /**
  116826. * Stops presenting to the VRDisplay.
  116827. * @returns a promise to know when it stopped
  116828. */
  116829. exitPresent(): Promise<void>;
  116830. /**
  116831. * Return the current VREyeParameters for the given eye.
  116832. * @param whichEye Define the eye we want the parameter for
  116833. * @returns the eye parameters
  116834. */
  116835. getEyeParameters(whichEye: string): VREyeParameters;
  116836. /**
  116837. * Populates the passed VRFrameData with the information required to render
  116838. * the current frame.
  116839. * @param frameData Define the data structure to populate
  116840. * @returns true if ok otherwise false
  116841. */
  116842. getFrameData(frameData: VRFrameData): boolean;
  116843. /**
  116844. * Get the layers currently being presented.
  116845. * @returns the list of VR layers
  116846. */
  116847. getLayers(): VRLayer[];
  116848. /**
  116849. * Return a VRPose containing the future predicted pose of the VRDisplay
  116850. * when the current frame will be presented. The value returned will not
  116851. * change until JavaScript has returned control to the browser.
  116852. *
  116853. * The VRPose will contain the position, orientation, velocity,
  116854. * and acceleration of each of these properties.
  116855. * @returns the pose object
  116856. */
  116857. getPose(): VRPose;
  116858. /**
  116859. * Return the current instantaneous pose of the VRDisplay, with no
  116860. * prediction applied.
  116861. * @returns the current instantaneous pose
  116862. */
  116863. getImmediatePose(): VRPose;
  116864. /**
  116865. * The callback passed to `requestAnimationFrame` will be called
  116866. * any time a new frame should be rendered. When the VRDisplay is
  116867. * presenting the callback will be called at the native refresh
  116868. * rate of the HMD. When not presenting this function acts
  116869. * identically to how window.requestAnimationFrame acts. Content should
  116870. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116871. * asynchronously from other displays and at differing refresh rates.
  116872. * @param callback Define the eaction to run next frame
  116873. * @returns the request handle it
  116874. */
  116875. requestAnimationFrame(callback: FrameRequestCallback): number;
  116876. /**
  116877. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116878. * Repeat calls while already presenting will update the VRLayers being displayed.
  116879. * @param layers Define the list of layer to present
  116880. * @returns a promise to know when the request has been fulfilled
  116881. */
  116882. requestPresent(layers: VRLayer[]): Promise<void>;
  116883. /**
  116884. * Reset the pose for this display, treating its current position and
  116885. * orientation as the "origin/zero" values. VRPose.position,
  116886. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116887. * updated when calling resetPose(). This should be called in only
  116888. * sitting-space experiences.
  116889. */
  116890. resetPose(): void;
  116891. /**
  116892. * The VRLayer provided to the VRDisplay will be captured and presented
  116893. * in the HMD. Calling this function has the same effect on the source
  116894. * canvas as any other operation that uses its source image, and canvases
  116895. * created without preserveDrawingBuffer set to true will be cleared.
  116896. * @param pose Define the pose to submit
  116897. */
  116898. submitFrame(pose?: VRPose): void;
  116899. }
  116900. declare var VRDisplay: {
  116901. prototype: VRDisplay;
  116902. new(): VRDisplay;
  116903. };
  116904. interface VRLayer {
  116905. leftBounds?: number[] | Float32Array | null;
  116906. rightBounds?: number[] | Float32Array | null;
  116907. source?: HTMLCanvasElement | null;
  116908. }
  116909. interface VRDisplayCapabilities {
  116910. readonly canPresent: boolean;
  116911. readonly hasExternalDisplay: boolean;
  116912. readonly hasOrientation: boolean;
  116913. readonly hasPosition: boolean;
  116914. readonly maxLayers: number;
  116915. }
  116916. interface VREyeParameters {
  116917. /** @deprecated */
  116918. readonly fieldOfView: VRFieldOfView;
  116919. readonly offset: Float32Array;
  116920. readonly renderHeight: number;
  116921. readonly renderWidth: number;
  116922. }
  116923. interface VRFieldOfView {
  116924. readonly downDegrees: number;
  116925. readonly leftDegrees: number;
  116926. readonly rightDegrees: number;
  116927. readonly upDegrees: number;
  116928. }
  116929. interface VRFrameData {
  116930. readonly leftProjectionMatrix: Float32Array;
  116931. readonly leftViewMatrix: Float32Array;
  116932. readonly pose: VRPose;
  116933. readonly rightProjectionMatrix: Float32Array;
  116934. readonly rightViewMatrix: Float32Array;
  116935. readonly timestamp: number;
  116936. }
  116937. interface VRPose {
  116938. readonly angularAcceleration: Float32Array | null;
  116939. readonly angularVelocity: Float32Array | null;
  116940. readonly linearAcceleration: Float32Array | null;
  116941. readonly linearVelocity: Float32Array | null;
  116942. readonly orientation: Float32Array | null;
  116943. readonly position: Float32Array | null;
  116944. readonly timestamp: number;
  116945. }
  116946. interface VRStageParameters {
  116947. sittingToStandingTransform?: Float32Array;
  116948. sizeX?: number;
  116949. sizeY?: number;
  116950. }
  116951. interface Navigator {
  116952. getVRDisplays(): Promise<VRDisplay[]>;
  116953. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116954. }
  116955. interface Window {
  116956. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116957. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116958. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116959. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116960. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116961. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116962. }
  116963. interface Gamepad {
  116964. readonly displayId: number;
  116965. }
  116966. interface XRDevice {
  116967. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116968. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116969. }
  116970. interface XRSession {
  116971. getInputSources(): Array<any>;
  116972. baseLayer: XRWebGLLayer;
  116973. requestFrameOfReference(type: string): Promise<void>;
  116974. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116975. end(): Promise<void>;
  116976. requestAnimationFrame: Function;
  116977. addEventListener: Function;
  116978. }
  116979. interface XRSessionCreationOptions {
  116980. outputContext?: WebGLRenderingContext | null;
  116981. immersive?: boolean;
  116982. environmentIntegration?: boolean;
  116983. }
  116984. interface XRLayer {
  116985. getViewport: Function;
  116986. framebufferWidth: number;
  116987. framebufferHeight: number;
  116988. }
  116989. interface XRView {
  116990. projectionMatrix: Float32Array;
  116991. }
  116992. interface XRFrame {
  116993. getDevicePose: Function;
  116994. getInputPose: Function;
  116995. views: Array<XRView>;
  116996. baseLayer: XRLayer;
  116997. }
  116998. interface XRFrameOfReference {
  116999. }
  117000. interface XRWebGLLayer extends XRLayer {
  117001. framebuffer: WebGLFramebuffer;
  117002. }
  117003. declare var XRWebGLLayer: {
  117004. prototype: XRWebGLLayer;
  117005. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  117006. };